# # Call Generator and Gapping Simulator Script. # # Try call gapping with different distributions. # # Run using a batch file. # echo on # bmawk -f cg2.awk cgmwi.txt > post.csv # bmawk -f cg2.awk post.csv > post1.csv # bmawk -f cg2.awk post1.csv > post2.csv # # # # BEGIN { FS = "," OFS = "," notFinished = ( 1 == 1 ) CallsPerSecond = 10 # average period = 0.1 seconds TotalSeconds = 120 gen = 4 print "rate,interval" > "cgmwi.txt" for ( i = 1 ; i < 250 ; i ++ ) { print CallsPerSecond ", " i / 1000 >> "cgmwi.txt" } close("cgmwi.txt") } { # executed for each line. # # # interval = $2 CallsPerSecond = $1 gen = ( NF-2 ) /3 + 1 now = 0 endOfGappingTime = 0 CallsSoFar = 0 gapped = 0 notGapped = 0 nextSecond = 1 TotalCallsSoFar = 0 TotalGapped = 0 TotalNotGapped = 0 notFinished = ( 1 == 1 ) while ( notFinished ) { # Randomly Neg Exp generated InterArrivalTime if ( gen == 1 ) { if ( $1 == "rate" ) { print $0 ",NegExp:Admitted,NegExp:gapped,NegExp:Total" next } #-LN(1-A7)/$B$2 interArrivalTime = 1.0*-log(1-rand( )) / CallsPerSecond } # Randomly generated InterArrivalTime if ( gen == 2 ) { if ( $1 == "rate" ) { print $0 ",2*rand():Admitted,2*rand():gapped,2*rand():Total" next } interArrivalTime = 2.0 * rand() / CallsPerSecond } # Constant InterArrivalTime if ( gen == 3 ) { if ( $1 == "rate" ) { print $0 ",Const:Admitted,Const:gapped,Const:Total" next } interArrivalTime = 1.0 / CallsPerSecond } now = now + interArrivalTime*1.0 CallsSoFar = CallsSoFar + 1 # Modelling the calls like: # I I I II I I I # GGGGG GGGGG GGGGG GGGGG # Of the 8 Demanded calls, 4 calls get through and restart Gapping # If we are gapping calls have we reached the end of the period. if ( now < endOfGappingTime ) { # still gapping gapped = gapped + 1 gapping = 1 gappedInInterval = gappedInInterval + 1 } else { if ( gappedInInterval > 0 ) { print now "," gappedInInterval "," gapped "," notGapped "," gen "," interval > "gapped.csv" gappedInInterval = 0 } notGapped = notGapped + 1 # finished gapping endOfGappingTime = now + interval gapping = 0 } print "," now "," interArrivalTime "," gappedInInterval "," CallsSoFar "," gapping "," gapped > "everycall.csv" if ( now > nextSecond ) { nextSecond = nextSecond + 1 TotalCallsSoFar = TotalCallsSoFar + CallsSoFar TotalGapped = TotalGapped + gapped TotalNotGapped = TotalNotGapped + notGapped CallsSoFar = 0 gapped = 0 notGapped = 0 } if ( nextSecond > TotalSeconds ) { notFinished = ( 1==0 ) } } print $0 "," TotalNotGapped / nextSecond "," TotalGapped / nextSecond "," TotalCallsSoFar /nextSecond } END { }