Article Figure 1 Figure 2 Listing 1 Table 1 jun2004.tar

Listing 1 Tests the times needed by FreeRADIUS to authenticate, under artificially created heavy load

/*************************************************************************\
| stress.c: Designed for a Linux Platform, making use of the fork() method |
|                                                                         |
| Engineered: Karlovassi, Samos                                           |
| Copyright (C) 2003-2004                                                 |
|                                                                         |
| Developer:    Konstantinos Lizos    (icsdm03020@icsd.aegean.gr)         |
|                Markos Gogoulos        (cs00013@icsd.aegean.gr)          |
|                                                                         |
| Description:    Performs a stress test over the RADIUS server           |
|                Leaves a period of 10 seconds time - space               |
|                                                                         |
| Project Name: (RAST) RADIUS Authentication Stress Test                  |
|                                                                         |
\*************************************************************************/

//    Section one: Library Insertion

#include <sys/types.h>        //    Header includes definitions for data types    
#include <unistd.h>           //    Standard symbolic constants and types 
#include <stdio.h>            //    Standard Input-Output Library
#include <stdlib.h>           //    Standard Library Definitions
#include <time.h>             //    Standard Time Library

//    End of Section one


//    Section two: Preprocessor flags

#define    NOC    1000        //    NOC = Number of Clients
#define AF    20              //    AF = Attack Frequency

//    Both are affected by the proper 

//    End of Section two


//    Section three: Variable declaration & definition

time_t start, during;
//    General Purposed time_t structures
//    Start denotes the start time of the program execution 
//    During denotes the time measument during the execution cycle 

time_t    threshold[NOC/AF];
//    Denotes a time (period) threshold
//    It is directly affected by the AF and the NOC preprocessor tags  

int current_service_client=0;
//    Just as the name implies, it is a common variable that plays the role
//    of enumeration

clock_t beg[NOC], ending[NOC];
//    The proper variables to keep track of the timing service module

//    End of section three


//    Section four: Function Declaration

void slp (double);

//    End of section four


//    Section five: Function Definition

//    Special Purpose Sleep function (Reaches the level of processor clocks)
void slp ( double seconds )
{
  clock_t endwait;
  endwait = clock () + (long)seconds * CLK_TCK ;
  while (clock() < endwait)
        {}
}

//    End of section five

//    Section six: Main function

int
main()
{

    int i;                      //  Local variable used for initializing 
                                //  period modules
    pid_t pid=1;                //  Variable used for the fork() function

    time(&start);               //  Starting counting the time. Beware

    threshold[0]=start+10;      //  Giving a proper 10 seconds head-start

    for(i=1;i<NOC/AF;i++)       //  For all discrete periods, do
    {
        threshold[i]=threshold[i-1]+1;  // Initialize the period thresholds
    }

    for(current_service_client=0;current_service_client<NOC;current_service_client++)
    {
        if (pid)
        {
            pid = fork();
        }
        //    Used especially so that a client can born only one child


        switch( pid )                   //    Service Activation
        {
            case 0:

                while(1)                //    Remaining in the loop until 
                                        //    proper time exit is reached
                {
                    time(&during);      //    Getting the system time

                    if(threshold[(int)current_service_client/(int)AF]<=during)
                    //   If the proper time period has expired, break the loop
                    {
                        break;
                    }
                }


                system("./radclient -f digest localhost auth  ******");  
                //    The most important function for the stress test
                //    Begin a radclient test

                if(current_service_client==NOC-1)
                //    In case we reached the end, calculate time period of 
                //    execution
                {
                     time(&during);     //    Getting current time variable

                    printf("Difference: %d\n", during-threshold[0]);
                                        //    Printing the time difference
                }

                return(0);              //    Exiting
                
                break;

            case -1: // error
                printf("Cannot create process!\n");
                                        //    System Fork Function Failure
                break;
            
            default:
                  break;
        };
    }
    
    return (0x0);                                
                                        //    Returning in case the program 
                                        //    reaches this point safely
}

//   This program can easily be transformed so that it can flush the 
//   contents of the beg and ending variables to a file storage container.
//   (With a slight transform of processor clocks to seconds. See slp function)