⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jobs-cn2002.tcl

📁 无线个域网(WPAN)就是在个人周围空间形成的无线网络
💻 TCL
📖 第 1 页 / 共 2 页
字号:
# jobs-cn2002.tcl## Topology is as follows:##                  cross_source(1...10) cross_source(11...20) cross_source(21...30)#                          \|/               \|/                  \|/# user_source(1)  ___       |                 |                    |                             __ user_sink(1)# user_source(2)  ---\  core_node(1) ==== core_node(2) ====    core_node(3)  ====  core_node(4) /-- user_sink(2)# user_source(3)  ---/                        |                    |                   |        \-- user_sink(3)# user_source(4)  __/                        /|\                  /|\                 /|\        \_ user_sink(4)#                                       cross_sink(1...10)   cross_sink(11...20)  cross_sink(21...30)## Links:# = : 45 MBps, 3 ms# - : 100 MBps, 1 ms## Classes:# 1: ADC=2 ms, ALC=0.5%, no ARC, no RDC, no RLC# 2, 3, 4: no ADC, no ALC, no ARC, RDC = 4, RLC = 2## Traffic mix:# user_source(1) -> user_sink(1) : Class 1, TCP, greedy# user_source(2) -> user_sink(2) : Class 2, TCP, greedy# user_source(3) -> user_sink(3) : Class 3, TCP, greedy# user_source(4) -> user_sink(4) : Class 4, UDP, greedy# cross_sources: 6 TCP flows, 4 UDP flows, 10% class 1, 20% class 2, 30% class 3, 40% class 4## This simulation is very similar to what was used in # "Rate Allocation and Buffer Management for Differentiated Services,"# by J. Liebeherr and N. Christin, Computer Networks, May 2002.## Auxiliary functions# topology primitivesSimulator instproc get-link { node1 node2 } {    	$self instvar link_    	set id1 [$node1 id]    	set id2 [$node2 id]    	return $link_($id1:$id2)}Simulator instproc get-queue { node1 node2 } {    	global ns    	set l [$ns get-link $node1 $node2]    	set q [$l queue]    	return $q}# JoBS duplex link: rate in kbps, delay in ms, buff_sz in packetsproc build-jobs-link {src dst rate delay buff_sz} {    	global ns    	$ns duplex-link $src $dst [expr $rate*1000.0] [expr $delay/1000.0] JoBS    	$ns queue-limit $src $dst $buff_sz    	$ns queue-limit $dst $src $buff_sz}# FCFS-marker duplex link: rate in kbps, delay in ms, buff_sz in packetsproc build-marker-link {src dst rate delay buff_sz} {    	global ns    	$ns simplex-link $src $dst [expr $rate*1000.0] [expr $delay/1000.0] Marker    	$ns simplex-link $dst $src [expr $rate*1000.0] [expr $delay/1000.0] Demarker    	$ns queue-limit $src $dst $buff_sz    	$ns queue-limit $dst $src $buff_sz}# FCFS-demarker duplex link: rate in kbps, delay in ms, buff_sz in packetsproc build-demarker-link {src dst rate delay buff_sz} {	global ns	$ns simplex-link $src $dst [expr $rate*1000.0] [expr $delay/1000.0] Demarker	$ns simplex-link $dst $src [expr $rate*1000.0] [expr $delay/1000.0] Marker	$ns queue-limit $src $dst $buff_sz	$ns queue-limit $dst $src $buff_sz}# Traffic models primitives# Basic procedure for connecting agents, etc.proc flow_setup {id src src_agent dst dst_agent app_flow pksize} {	global ns	$ns attach-agent $src $src_agent	$ns attach-agent $dst $dst_agent	$ns connect $src_agent $dst_agent	$src_agent set packetSize_ 	$pksize	$src_agent set fid_ $id	$app_flow set flowid_ $id	$app_flow attach-agent $src_agent	return $src_agent    }# TCP flows# Create "infinite-duration" FTP connectionproc inf_ftp {id src src_agent dst dst_agent app_flow maxwin pksize starttm} {	global ns 	flow_setup $id $src $src_agent $dst $dst_agent $app_flow $pksize	$src_agent set window_ $maxwin	$src_agent set ecn_	1	puts [format "\tFTP-$id starts at %.4fsec" $starttm]	$ns at $starttm "$app_flow start"	return $src_agent}# Web-like flows: Create successive short transfers within single TCP connection proc init_mouse {id src src_agent dst dst_agent app_flow maxwin pksize starttm sleeptm minpkts maxpkts} {	global ns 	flow_setup $id $src $src_agent $dst $dst_agent $app_flow $pksize	$src_agent set window_ 	$maxwin	$src_agent set ecn_	1	puts [format "\tMouse-$id starts at %.4fs - avg-sleep-time %.3fs - packets %d to %d " $starttm $sleeptm $minpkts $maxpkts]	$ns at $starttm "actv_mouse $src_agent $app_flow $id $sleeptm $minpkts $maxpkts"	return $src_agent}proc actv_mouse {tcp ftp id sleeptm minpkts maxpkts} {	global ns rnd 	set numpkts [expr round([$rnd uniform $minpkts $maxpkts+1])]	set prd_time [expr [$rnd exponential] * $sleeptm + [$ns now]]	$ns at $prd_time "$ftp producemore $numpkts"	$ns at $prd_time "actv_mouse $tcp $ftp $id $sleeptm $minpkts $maxpkts" }# UDP flows# Build a Pareto On-Off source ## packet trains with both on and off durations being pareto distributed# Packet size: bytes, Burst and Idle time: ms, Peak rate: kbps, Start time: secondsproc build-pareto-on-off {id src src_agent dst dst_agent app_flow peak_rate pksize shape_par start_tm idle_tm burst_tm} {	global ns	flow_setup $id $src $src_agent $dst $dst_agent $app_flow $pksize	$app_flow set burst-time_  [expr $burst_tm  / 1000.]	$app_flow set idle-time_   [expr $idle_tm  / 1000.]	$app_flow set rate_        [expr $peak_rate * 1000.0]	$app_flow set shape_       $shape_par	$ns at $start_tm "$app_flow start"	puts [format "\tPareto-$id starts at %.4fsec" $start_tm]}# statistics primitives# Dump the statistics of a (unidirectional) link periodically proc linkDump {link binteg pinteg qmon interval name} {	global ns	set now_time [$ns now]	$ns at [expr $now_time + $interval] "linkDump $link $binteg $pinteg $qmon $interval $name"	set bandw [[$link link] set bandwidth_]	set queue_bd [$binteg set sum_]	set abd_queue [expr $queue_bd/[expr 1.*$interval]]	set queue_pd [$pinteg set sum_]	set apd_queue [expr $queue_pd/[expr 1.*$interval]]	set utilz [expr 8*[$qmon set bdepartures_]/[expr 1.*$interval*$bandw]]	if {[$qmon set parrivals_] != 0} {		set drprt [expr [$qmon set pdrops_]/[expr 1.*[$qmon set parrivals_]]]	} else {		set drprt 0	}	if {$utilz != 0} {		set a_delay [expr ($abd_queue*8*1000)/($utilz*$bandw)]	} else {		set a_delay 0.	}	puts [format "Link %s: Util=%.3f\tDrRt=%.3f\tADel=%.1fms\tAQuP=%.0f\tAQuB=%.0f" $name $utilz $drprt $a_delay $apd_queue $abd_queue]	puts -nonewline [format "%.3f\t" $utilz]	$binteg reset	$pinteg reset	$qmon reset}proc printFlow {f outfile fm interval} {	global ns tot_drop tot_arv	puts $outfile [format "%d %.2f %d %d %d %d %.0f %.3f" [$f set flowid_] [$ns now] [expr 8*[$f set barrivals_]] [$f set parrivals_] [expr 8*[$f set bdrops_]] [$f set pdrops_] [expr [$f set barrivals_]*8/($interval*1000.)] [expr [$f set bdrops_]/double([$f set barrivals_])] ]}proc flowDump {link fm file_p interval} {	global ns tot_drop 	$ns at [expr [$ns now] + $interval]  "flowDump $link $fm $file_p $interval"	set theflows [$fm flows]	if {[llength $theflows] == 0} {		return	} else {		set total_arr [expr double([$fm set barrivals_])]		if {$total_arr > 0} {			foreach f $theflows {				set arr [expr [expr double([$f set barrivals_])] / $total_arr]				if {$arr >= 0.0001} {					printFlow $f $file_p $fm $interval					set z [$f set flowid_] 					if {$z <= 4} {						set tot_drop($z) [expr $tot_drop([$f set flowid_])+[$f set pdrops_]]					}				}       			    $f reset			}       		    $fm reset		}	}}proc totalDrops {id interval} {	global ns total_drops_file tot_drop N_USERS user_source core_node	set q [$ns get-queue $user_source(1) $core_node(1)]	set tot_arv(1) [$q set marker_arrvs1_]	set q [$ns get-queue $user_source(2) $core_node(1)]	set tot_arv(2) [$q set marker_arrvs2_]	set q [$ns get-queue $user_source(3) $core_node(1)]	set tot_arv(3) [$q set marker_arrvs3_]    	set q [$ns get-queue $user_source(4) $core_node(1)]	set tot_arv(4) [$q set marker_arrvs4_]    	if {$tot_arv($id) > 0} {		puts $total_drops_file($id) [format "%.2f %.2f %d %d" [$ns now] [expr 100.*$tot_drop($id)/double($tot_arv($id))] $tot_drop($id) $tot_arv($id)]	} else {		puts $total_drops_file($id) [format "%.2f 0.00" [$ns now]]	}	set tot_arv($id) 0	$ns at [expr [$ns now] + $interval] "totalDrops $id $interval"}proc record_cwnd {} {	global ns N_CL N_USERS_TCP user_source_agent cwnd_file	set time 0.5	set now [$ns now]	for {set i 1} {$i <= $N_USERS_TCP} {incr i} {		set window($i) [$user_source_agent($i) set cwnd_]		puts $cwnd_file($i) [format "%.2f %.2f" $now $window($i)]	}	$ns at [expr $now+$time] "record_cwnd"}proc record_thru {} {	global ns N_CL user_sink_agent thru_file	set time 0.5	set tot_recv 0	set now [$ns now]	for {set i 1} {$i <= $N_CL} {incr i} {		set recv($i) [$user_sink_agent($i) set bytes_]		set tot_recv [expr $tot_recv + [$user_sink_agent($i) set bytes_]]		puts $thru_file($i) [format "%.2f %.2f" $now [expr 8.*$recv($i)/$time]]		$user_sink_agent($i) set bytes_ 0	}	puts $thru_file([expr $N_CL+1]) [format "%.2f %.2f" $now [expr 8.*$tot_recv/$time]]	$ns at [expr $now+$time] "record_thru"}puts " "puts "JoBS multi-hop simulation."puts "(c) Multimedia Networks Group, University of Virginia, 2000-2"set ns [new Simulator]set rnd [new RNG]set seed 16puts "Random seed: $seed"$rnd seed $seed Queue/JoBS set drop_front_ falseQueue/JoBS set trace_hop_ trueQueue/JoBS set adc_resolution_type_ 0Queue/JoBS set shared_buffer_ 1Queue/JoBS set mean_pkt_size_ 4000Queue/Demarker set demarker_arrvs1_ 0Queue/Demarker set demarker_arrvs2_ 0Queue/Demarker set demarker_arrvs3_ 0Queue/Demarker set demarker_arrvs4_ 0Queue/Marker set marker_arrvs1_ 0Queue/Marker set marker_arrvs2_ 0Queue/Marker set marker_arrvs3_ 0Queue/Marker set marker_arrvs4_ 0# need to patch tcp-sink.h tcp-sink.cc for thisAgent/TCPSink/DelAck set bytes_ 0 #puts "\nTOPOLOGY SETUP"# Number of hops (=k)set hops 4puts "Number of hops: $hops"# Link  latency (ms)# note: an east coast-west coast # connection w/ 4 hops has a per-hop prop. del. roughly equal to 4.4msset EDGE_DEL  	1.0set CORE_DEL    3.0 puts "Edge link latency: $EDGE_DEL (ms)"puts "Core link latency: $CORE_DEL (ms)"# links: bandwidth (kbps) set CORE_BW	45000.0set EDGE_BW	100000.0puts "Core bandwidth: $CORE_BW (kbps)"puts "Edge bandwidth: $EDGE_BW (kbps)"# Buffer size in gateways (in packets)set GW_BUFF	800

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -