?? peer_setup.tcl~
字號:
# Create a session list for the input type of traffics, from 1 application server to a random user picked up randomly from# the dst pool(an array of UEs), sessions come according to Poisson process, max_sess is the max session number of this type# in this simulation, and it return a session list, each item inside it has: StartT, EndT,Src, Dst(UE)# usage: proc CreatRTSessList { sessname src interval duration } {global ns testTime ue num_UE upvar $sessname sess# Maximum number of sessions to be createdset max_sess [expr round(1.4*$testTime/$interval)]#puts "Creating max $max_sess sessions for [$src id]"#generators for random seedsset ArrivalRng [new RNG]$ArrivalRng seed 0set HoldRng [new RNG]$HoldRng seed 0set UERng [new RNG]$UERng seed 0# Random Interarrival time of RT transfers at source set RV_ariv [new RandomVariable/Exponential]$RV_ariv set avg_ $interval$RV_ariv use-rng $ArrivalRng# Random time duration for traffics to transferset RV_hold [new RandomVariable/Exponential]$RV_hold set avg_ $duration$RV_hold use-rng $HoldRng# Random UE id as the session receiverset RV_UEid [new RandomVariable/Uniform]$RV_UEid set min_ 1$RV_UEid set max_ $num_UE$RV_UEid use-rng $UERng#set tf [open "RTsession_list.tr" w]set t [$ns now]#set sess {} for {set j 1} {$j<=$max_sess} {incr j} { set sess($j) [new Application/Traffic/Exponential] # record src node $sess($j) set Src $src # select dest UE for this session set UEid [expr round([$RV_UEid value])] $sess($j) set Dst $ue($UEid) # set the beginning time of next transfer from fource i set t [expr $t + [$RV_ariv value]] $sess($j) set StartT $t # set the duration of this transfer from source i $sess($j) set EndT [expr [$sess($j) set StartT] + [$RV_hold value]] $sess($j) set started -1; # set a start/admit/block flag for session j #puts $tf "sess($j)=$sess($j), dst=[$sess($j) set Dst], start= [$sess($j) set StartT],end=[$sess($j) set EndT]" }#close $tf#puts "internal session list size: [array size sess]"}######### End of lauch session #################################set vf [open "smon_exp.mon" w]# Create an UDP-connection, define VoIP-session parameters and start an# exponential ON-OFF-connection (exponential idle and call holding times)proc launchVoip { sessname src dst id} { global ns testTime upvar $sessname expoo # Load to the system is defined as mean_holding_time/mean_interarrival_time set load 0.4 set FID [expr 1000 + $id]; # different traffic type has different first 2 digits of flowID set udp [new Agent/UDP] $udp set fid_ $FID set null [new Agent/Null] $ns attach-agent $src $udp $ns attach-agent $dst $null $ns connect $udp $null #VoIP-client configuration # the on-time here is so long that it act as a whole phone call holding time, means during a Voip session(a burst time # period) it is actually simulated with a CBR session of 180 sec. and the average interval(of expenontial distribution) set expoo [new Application/Traffic/Exponential] $expoo attach-agent $udp $expoo set packetSize_ [expr 160+40]; # data + header $expoo set burst_time_ 1.0 $expoo set idle_time_ [format %.1f [expr [$expoo set burst_time_]*(1/$load - 1)]] $expoo set rate_ 30000; # voice on rate 30kbps, average about 30*.6=18kbps $expoo set id_ $FID # puts "Creating voip $id with pSize=[$expoo set packetSize_], bTime=[$expoo set burst_time_], idleTime=[$expoo set idle_time_], rate=[$expoo set rate_]" $expoo set sink_ $null $expoo proc voip-start { size estTime } { global ns vf $self instvar id_ puts $vf "[format %.6f [$ns now]] VOIP $id_ starting, size $size pkts, estTxTime $estTime" } $expoo proc voip-stop { packetsSent txTime } { global ns vf $self instvar sink_ id_ puts $vf "[format %.6f [$ns now]] VOIP $id_ stopped, sent $packetsSent pkts, txTime $txTime" } $expoo proc finish-stats {} { global ns vf $self instvar sink_ id_ if { [$sink_ set udpPackRecs_] > 0 } { set avgDelay_ [format %.6f [expr [$sink_ set udpSumDelays_]/[$sink_ set udpPackRecs_]]] } else { set avgDelay_ 0 } puts $vf "Final statistics VOIP $id_ received [$sink_ set udpPackRecs_] pkts, avgDelay $avgDelay_" }}proc launchVideo { sessname src dst id } { global ns testTime upvar $sessname expoo # Load to the system is defined as mean_holding_time/mean_interarrival_time set load 0.5 set FID [expr 2000 + $id]; # different traffic type has different first 2 digits of flowID set udp [new Agent/UDP] $udp set fid_ $FID set null [new Agent/Null] $ns attach-agent $src $udp $ns attach-agent $dst $null $ns connect $udp $null #Video-client configuration set expoo [new Application/Traffic/Exponential] $expoo attach-agent $udp $expoo set packetSize_ [expr 400] $expoo set burst_time_ 1.5 $expoo set idle_time_ [format %.1f [expr [$expoo set burst_time_]*(1/$load - 1)]] $expoo set rate_ 128000; # video on rate 64kbps $expoo set id_ $FID #puts "Creating video $id with pSize=[$expoo set packetSize_], bTime=[$expoo set burst_time_], idleTime=[$expoo set idle_time_], rate=[$expoo set rate_]" #$expoo set sink_ $null #$expoo proc finish-stats {} {# global ns vf# $self instvar sink_ id_# if { [$sink_ set udpPackRecs_] > 0 } {# set avgDelay_ [format %.6f [expr [$sink_ set udpSumDelays_]/[$sink_ set udpPackRecs_]]]# } else {# set avgDelay_ 0# }# puts $vf "Final statistics Video $id_ received [$sink_ set udpPackRecs_] pkts, avgDelay $avgDelay_"# }}proc launchHttp { sessname src dst id } { global ns testTime upvar $sessname poo set FID [expr 3000 + $id]; # different traffic type has different first 2 digits of flowID set tcp [new Agent/TCP] $tcp set packetSize_ 500 $ns attach-agent $src $tcp set sink [new Agent/TCPSink] $ns attach-agent $dst $sink
$ns connect $tcp $sink $tcp set fid_ $FID $sink set fid_ $FID set poo [new Application/Traffic/Pareto] $poo set burst_time_ 1.6 $poo set idle_time_ 12 $poo set rate_ 60k $poo set packetSize_ 200 $poo set shape_ 1.1 $poo set id_ $FID $poo attach-agent $tcp #puts "Creating http $id with pSize=[$poo set packetSize_], bTime=[$poo set burst_time_], idleTime=[$poo set idle_time_], rate=[$poo set rate_]"}# Create an FTP sessionproc launchFtp {sessname src dst id } { global ns testTime #upvar $sessname poo upvar $sessname cbr set FID [expr 4000 + $id]; # different traffic type has different first 2 digits of flowID set tcp [new Agent/TCP] $tcp set packetSize_ 500 $ns attach-agent $src $tcp set sink [new Agent/TCPSink] $ns attach-agent $dst $sink
$ns connect $tcp $sink $tcp set fid_ $FID $sink set fid_ $FID set cbr [new Application/Traffic/CBR]
$cbr attach-agent $tcp $cbr set packetSize_ 500
$cbr set rate_ 200k
$cbr set random_ false #set poo [new Application/Traffic/Pareto] #$poo set burst_time_ 2.97 #$poo set idle_time_ 25.6 #$poo set rate_ 200k #$poo set packetSize_ 400 #$poo set shape_ 1.1 #$poo set id_ $FID #$poo attach-agent $tcp #puts "Creating ftp $id with pSize=[$poo set packetSize_], bTime=[$poo set burst_time_], idleTime=[$poo set idle_time_], rate=[$poo set rate_]"}proc CreatNRTSessList { sessname src SessType interval duration STD } {global ns testTime ue num_UE upvar $sessname sess# Maximum number of sessions to be createdset max_sess [expr round(1.4*$testTime/$interval)]#puts "Creating max $max_sess sessions for [$src id]"#generators for random seedsset ArrivalRng [new RNG]$ArrivalRng seed 0set HoldRng [new RNG]$HoldRng seed 0set UERng [new RNG]$UERng seed 0# Random Interarrival time of RT transfers at source set RV_ariv [new RandomVariable/Exponential]$RV_ariv set avg_ $interval$RV_ariv use-rng $ArrivalRng# Random time duration for traffics to transfer: lognormal distributed for http and pareto for FTPif {$SessType == "HTTP"} { set RV_hold [new RandomVariable/LogNormal] $RV_hold set avg_ $duration $RV_hold set std_ $STD } elseif {$SessType == "FTP"} { set RV_hold [new RandomVariable/Pareto] $RV_hold set avg_ $duration $RV_hold set shape_ $STD; # actually this STD means std for lognormal and shape for pareto RV $RV_hold use-rng $HoldRng } $RV_hold use-rng $HoldRng# Random UE id as the session receiverset RV_UEid [new RandomVariable/Uniform]$RV_UEid set min_ 1$RV_UEid set max_ $num_UE$RV_UEid use-rng $UERngset tf [open "NRTsession_list.tr" w]set t [$ns now]#set sess {} for {set j 1} {$j<=$max_sess} {incr j} { set sess($j) [new Application/Traffic/Pareto] # record src node $sess($j) set Src $src # select dest UE for this session set UEid [expr round([$RV_UEid value])] $sess($j) set Dst $ue($UEid) # set the beginning time of next transfer from fource i set t [expr $t + [$RV_ariv value]] $sess($j) set StartT $t # set the duration of this transfer from source i $sess($j) set EndT [expr [$sess($j) set StartT] + [$RV_hold value]] $sess($j) set started -1; # set a start/admit/block flag for session j #puts $tf "sess($j)=$sess($j), dst=[$sess($j) set Dst], start= [$sess($j) set StartT],end=[$sess($j) set EndT]" }close $tf}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -