// C++/CSIM Model of generating synthetic trace file // Two classes of traffic: A and B // Interarrival time of Class A is exponentially distributed // with mean 10.0 // flow of class A will generate N_a pkts (uniformly distributed // between (100 to 500) with inter-packet time being // exponentially distributed with mean of 2.0) // Interarrival time of Class B is exponentially distributed // with mean 20.0 // flow of class B will generate N_b pkts (uniformly distributed // between (400 to 800) with inter-packet time being // exponentially distributed with mean of 1.0) // Traffic generation time is T = 1000.0 #include "cpp.h" // class definitions #define T 1000.0 #define TA_IAR_TM 10.0 #define TB_IAR_TM 20.0 #define PA_IAR_TM 2.0 #define PB_IAR_TM 1.0 #define N_a_min 100.0 #define N_a_max 500.0 #define N_b_min 400.0 #define N_b_max 800.0 void generate_traffic_A(); void generate_traffic_B(); void generate_flow_A(int i); void generate_flow_B(int i); extern "C" void sim(int, char **); void sim(int argc, char *argv[]) { set_model_name("Synthetic Workload"); create("sim"); generate_traffic_A(); generate_traffic_B(); hold(T); } void generate_traffic_A() { int i; create("traffic A"); i = 0; while(1){ //hold(expntl(TA_IAR_TM)); hold(5.0); generate_flow_A(i); i++; } } void generate_traffic_B() { int i; create("traffic B"); i = 0; while(1){ //hold(expntl(TB_IAR_TM)); hold(8.0); generate_flow_B(i); i++; } } void generate_flow_A(int i) { double total_pkts, num; create("flow A"); // total # of packets to generate for this flow A total_pkts = uniform(N_a_min, N_a_max); for (num=0; num < total_pkts; num+=1.0){ hold(expntl(PA_IAR_TM)); printf("flow A: flow id %6d: pkt number=%6.1f: time=%.2lf\n", i, num, clock); } } void generate_flow_B(int i) { double total_pkts, num; create("flow B"); // total # of packets to generate for this flow B total_pkts = uniform(N_b_min, N_b_max); for (num=0; num < total_pkts; num+=1.0){ hold(expntl(PB_IAR_TM)); printf("flow B: flow id %6d: pkt number=%6.1f: time=%.2lf\n", i, num, clock); } }