//=================================================== file = syntraf1.c ===== //= Program to generate synthetic packet traffic = //= - Bounded Pareto burst size and exponential interburst time = //=========================================================================== //= Notes: 1) Writes to a user specified output file = //= - File format is = //= 2) Bounded Pareto pdf is (k is lower bound, p is upper bound): = //= - pdf is f(x) = ((a*k^a) / (1 - (k/p)^a))*x^(-a-1) = //= 3) See M. Crovella and M. Harchol-Balter, and C. Murta, "Task = //= Assignment in a Distributed System: Improving Performance = //= by Unbalancing Load," BUCS-TR-1997-018, October 1997. = //=-------------------------------------------------------------------------= //= Example user input: = //= = //= ----------------------------------------------- syntraf1.c ----- = //= - Program to generate synthetic packet traffic - = //= - - Bounded Pareto burst size, exponential interburst time - = //= ---------------------------------------------------------------- = //= Enter output file name =========================> output.dat = //= Random number seed (greater than 0) ============> 1 = //= Exponential mean value (mean burst gap time) ===> 1.0 = //= Pareto alpha value =============================> 1.1 = //= Pareto k value (min burst size in bytes) =======> 1000 = //= Pareto p value (max burst size in bytes) =======> 1000000 = //= Min packet length (bytes) ======================> 64 = //= Max packet length (bytes) ======================> 1500 = //= Link data rate (bits per second) ===============> 10000000.0 = //= Number of packets to generate ==================> 10 = //= ---------------------------------------------------------------- = //= - Generating 10 packets... = //= ---------------------------------------------------------------- = //= ---------------------------------------------------------------- = //= - Summary statistics... = //= - - Total time of trace = 5.446277 sec = //= - - Total number of bursts = 6 = //= - - Total number of bytes = 11948 bytes = //= - - Utilization = 0.175503 % = //= ----------------------------------------------------------------- = //=-------------------------------------------------------------------------= //= Example output file ("output.dat" for above): = //= = //= 2.029262 1001 = //= 0.780668 1500 = //= 0.001200 1500 = //= 0.000476 595 = //= 1.520070 1500 = //= 0.000398 497 = //= 0.388169 1045 = //= 0.068737 1500 = //= 0.001048 1310 = //= 0.656249 1500 = //=-------------------------------------------------------------------------= //= Build: bcc32 syntraf1.c = //=-------------------------------------------------------------------------= //= Execute: syntraf1 = //=-------------------------------------------------------------------------= //= Author: Ken Christensen = //= University of South Florida = //= WWW: http://www.csee.usf.edu/~christen = //= Email: christen@csee.usf.edu = //=-------------------------------------------------------------------------= //= History: KJC (10/11/05) - Genesis (from genpar2.c) = //=========================================================================== //----- Include files ------------------------------------------------------- #include // Needed for printf() #include // Needed for exit() and ato*() #include // Needed for log() and pow() #include // Needed for assert() macro //----- Function prototypes ------------------------------------------------- double bpareto(double a, double k, double p); // Returns a bounded Pareto rv double expon(double mean_value); // Returns an exponential rv double rand_val(int seed); // Jain's RNG //===== Main program ======================================================== void main(void) { char in_string[80]; // Input string FILE *fp; // File pointer to output file double intergap_time; // Exponential burst gap time (sec) double a; // Bounded Pareto alpha value double k; // Bounded Pareto k value (bytes) double p; // Bounded Pareto p value (bytes) int min_pktlen; // Minimum packet length (bytes) int max_pktlen; // Maximum packet length (bytes double data_rate; // Link data rate (bit/sec) int num_pkt; // Number of packets to generate double pareto_rv; // Pareto random variable double expon_rv; // Exponential random variable double time; // Current time double time_last; // Last time double sum_bytes; // Sum of bytes double sum_bursts; // Sum of bursts int burst_len; // Number of packets in a burst int last_pktlen; // Length of last packet in a burst (bytes) int pktlen; // Packet length (bytes) int i; // Loop counter // Output banner printf("----------------------------------------------- syntraf1.c ----- \n"); printf("- Program to generate synthetic packet traffic - \n"); printf("- - Bounded Pareto burst size, exponential burst gap time - \n"); printf("---------------------------------------------------------------- \n"); // Prompt for output filename and then create/open the file printf("Enter output file name =========================> "); scanf("%s", in_string); fp = fopen(in_string, "w"); if (fp == NULL) { printf("ERROR in creating output file (%s) \n", in_string); exit(1); } // Prompt for random number seed and then use it printf("Random number seed (greater than 0) ============> "); scanf("%s", in_string); rand_val(atoi(in_string)); // Prompt for mean time between bursts printf("Exponential mean value (mean burst gap time) ===> "); scanf("%s", in_string); intergap_time = atof(in_string); // Prompt for Pareto alpha value printf("Pareto alpha value =============================> "); scanf("%s", in_string); a = atof(in_string); // Prompt for Pareto k value printf("Pareto k value (min burst size in bytes) =======> "); scanf("%s", in_string); k = atof(in_string); // Prompt for Pareto p value printf("Pareto p value (max burst size in bytes) =======> "); scanf("%s", in_string); p = atof(in_string); // Prompt for minimum packet length (for last packet in a burst) printf("Min packet length (bytes) ======================> "); scanf("%s", in_string); min_pktlen = atoi(in_string); // Prompt for maximum packet length (used for a burst) printf("Max packet length (bytes) ======================> "); scanf("%s", in_string); max_pktlen = atoi(in_string); // Prompt for link data rate printf("Link data rate (bits per second) ===============> "); scanf("%s", in_string); data_rate = atof(in_string); // Prompt for number of packets to generate printf("Number of packets to generate ==================> "); scanf("%s", in_string); num_pkt = atoi(in_string); //Output message and generate samples printf("---------------------------------------------------------------- \n"); printf("- Generating %d packets... \n", num_pkt); printf("---------------------------------------------------------------- \n"); // Generate the synthentic traffic time = time_last = sum_bytes = sum_bursts = 0.0; while(1) { // Pull random values pareto_rv = bpareto(a, k, p); expon_rv = expon(intergap_time); assert((pareto_rv >= k) && (pareto_rv <= p)); assert(expon_rv >= 0.0); // Determine the interburst time time = time + expon_rv; // Determine the number of packets in the burst burst_len = ceil(pareto_rv / max_pktlen); // Determine the size of the last packet in the burst if ((pareto_rv / max_pktlen) == burst_len) last_pktlen = max_pktlen; else { last_pktlen = ceil((double) max_pktlen * ((pareto_rv / max_pktlen) - floor(pareto_rv / max_pktlen))); if (last_pktlen < min_pktlen) last_pktlen = min_pktlen; } // Generate the burst for (i=0; i 0) { x = seed; return(0.0); } // RNG using integer arithmetic x_div_q = x / q; x_mod_q = x % q; x_new = (a * x_mod_q) - (r * x_div_q); if (x_new > 0) x = x_new; else x = x_new + m; // Return a random value between 0.0 and 1.0 return((double) x / m); }