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

📄 cip-page.tcl

📁 运行于linux上的CIMS套件
💻 TCL
字号:
#optionset opt(chan)		Channel/WirelessChannelset opt(prop)		Propagation/TwoRayGroundset opt(netif)		Phy/WirelessPhyset opt(mac)		Mac/802_11set opt(ifq)		Queue/DropTail/PriQueueset opt(ll)		LLset opt(ant)            Antenna/OmniAntennaset opt(x)	        500	;# X & Y dimension of the topographyset opt(y)		500     ;# hard wired for now...set opt(rp)             NOAH    ;# rotuing protocls:set opt(ifqlen)		50		;# max packet in ifqset opt(seed)		0.0set opt(stop)		20.0		;# simulation timeset opt(cc)             "off"set opt(tr)		cip-out.tr	;# trace fileset opt(cp)             ""set opt(sc)             ""set opt(ftp1-start)     1# =================================================================set num_wired_nodes    7set num_bs_nodes       4set num_wireless_nodes 1set opt(nn)            5         ;# total number of wireless nodes#==================================================================# Other class settingsset AgentTrace			ONset RouterTrace			OFFset MacTrace			OFFLL set mindelay_		50usLL set delay_			25usAgent/Null set sport_		0Agent/Null set dport_		0Agent/CBR set sport_		0Agent/CBR set dport_		0Agent/TCPSink set sport_	0Agent/TCPSink set dport_	0Agent/TCP set sport_		0Agent/TCP set dport_		0Agent/TCP set packetSize_	1460Queue/DropTail/PriQueue set Prefer_Routing_Protocols    1# unity gain, omni-directional antennas# set up the antennas to be centered in the node and 1.5 meters above itAntenna/OmniAntenna set X_ 0Antenna/OmniAntenna set Y_ 0Antenna/OmniAntenna set Z_ 1.5Antenna/OmniAntenna set Gt_ 0.2Antenna/OmniAntenna set Gr_ 0.2# Initialize the SharedMedia interface with parameters to make# it work like the 914MHz Lucent WaveLAN DSSS radio interfacePhy/WirelessPhy set CPThresh_ 10.0Phy/WirelessPhy set CSThresh_ 1.559e-11Phy/WirelessPhy set RXThresh_ 3.652e-10Phy/WirelessPhy set Rb_ 2*1e6Phy/WirelessPhy set freq_ 914e+6 Phy/WirelessPhy set L_ 1.0# ==================================================================source ../lib/ns-wireless-mip.tclsource cipInit.tclPhy/WirelessPhy set Pt_ 0.002822# intial setup - set addressing to hierarchicalset ns [new Simulator]$ns color $cipfid($CIP_DATA)        blue$ns color $cipfid($CIP_PAGING)      magenta$ns color $cipfid($CIP_PAGE)        orange$ns color $cipfid($CIP_ROUTE)       red$ns set-address-format hierarchical# set mobileIP flag; CIP sitll use some function of MIPSimulator set mobile_ip_ 1set namtrace [open cip.nam w]$ns namtrace-all $namtraceset trace [open /dev/null  w  ]$ns trace-all $traceAddrParams set domain_num_ 5lappend cluster_num 7 1 1 1 1AddrParams set cluster_num_ $cluster_numlappend eilastlevel 1 1 1 1 1 1 1 4 1 1 1AddrParams set nodes_num_ $eilastlevel## setup the wired nodes    set W(0) [$ns node 0.0.0]     set W(1) [$ns node 0.1.0]     set W(2) [$ns node 0.2.0]     set W(3) [$ns node 0.3.0]     set W(4) [$ns node 0.4.0]     set W(5) [$ns node 0.5.0] ## create corresponding host    set CH   [$ns node 0.6.0] ## create common objects reqd for wireless sim.if { $opt(x) == 0 || $opt(y) == 0 } {	puts "No X-Y boundary values given for wireless topology\n"}set chan        [new $opt(chan)]set prop        [new $opt(prop)]set topo	[new Topography]set tracefd	[open $opt(tr) w]# setup topography and propagation model$topo load_flatgrid $opt(x) $opt(y)$prop topography $topo# Create Godcreate-god $opt(nn)$ns node-config -mobileIP ON \                 -adhocRouting NOAH \                 -llType LL \                 -macType Mac/802_11 \                 -ifqType Queue/DropTail/PriQueue \                 -ifqLen 50 \                 -antType Antenna/OmniAntenna \                 -propType Propagation/TwoRayGround \                 -phyType Phy/WirelessPhy \                 -channelType Channel/WirelessChannel \                 -topoInstance $topo \                 -wiredRouting ON \                 -agentTrace ON \                 -routerTrace OFF \                 -macTrace ON# Set tranmission Power so that overlapping area is desired# Overlapping region between base stationsset overlap 30 set coverage [CellCoverage 1 1 140 140 $overlap]Phy/WirelessPhy set Pt_ [SetPt $coverage]set power [Phy/WirelessPhy set Pt_]## setup Base Station nodes# Base Station 1$ns node-config -rxPower $power -txPower $powerset BS1 [$ns node 1.0.0][$BS1 set regagent_] priority 1# Mobile Host$ns node-config -wiredRouting OFF$ns node-config -rxPower $power -txPower $powerset MH [$ns node  1.0.2]$MH MakeMobile$MH create-watchdog $W(0); # W(0) is GateWay node$MH set cur_bs_node 0 # enable semisoft handoff#$MH enable-semisoft$ns node-config -wiredRouting ON# Base Station 2$ns node-config -rxPower $power -txPower $powerset BS2 [$ns node 2.0.0]# Base Station 3$ns node-config -rxPower $power -txPower $powerset BS3 [$ns node 3.0.0]# Base Station 4$ns node-config -rxPower $power -txPower $powerset BS4 [$ns node 4.0.0]$ns at 0.0 "$CH   label Corresponding_Host" $ns at 0.0 "$W(0) label GateWay" $ns at 0.0 "$W(1) label CIP_Node" $ns at 0.0 "$W(2) label CIP_Node" $ns at 0.0 "$W(3) label CIP_Node" $ns at 0.0 "$W(4) label CIP_Node" $ns at 0.0 "$W(5) label CIP_Node" $ns at 0.0 "$BS1 label BaseStation1"$ns at 0.0 "$BS2 label BaseStation2"$ns at 0.0 "$BS3 label BaseStation3"$ns at 0.0 "$BS4 label BaseStation4"$BS1 color "red"$BS2 color "red"$BS3 color "red"$BS4 color "red"#Make node cipNode$W(0) cipEnabledNode$W(1) cipEnabledNode$W(2) cipEnabledNode$W(3) cipEnabledNode$W(4) cipEnabledNode$W(5) cipEnabledNode$BS1 cipEnabledNode$BS2 cipEnabledNode$BS3 cipEnabledNode$BS4 cipEnabledNode#Create Page-update Cache & Route-update Cache$W(0) MakePMC; $W(0) MakeRMC$W(1) MakePMC; $W(1) MakeRMC$W(2) MakePMC; $W(2) MakeRMC$W(3) MakePMC; $W(3) MakeRMC$W(4) MakePMC; $W(3) MakeRMC$W(5) MakePMC; $W(3) MakeRMC#Make base station$BS1 MakeBS$BS2 MakeBS$BS3 MakeBS$BS4 MakeBS#provide some co-ord (fixed) to these base-station nodes.$BS1 set X_ 1.000000000000$BS1 set Y_ 1.000000000000$BS1 set Z_ 0.000000000000$BS2 set X_ 140.000000000000$BS2 set Y_ 140.000000000000$BS2 set Z_ 0.000000000000$BS3 set X_ 280.000000000000$BS3 set Y_ 280.000000000000$BS3 set Z_ 0.000000000000$BS4 set X_ 420.000000000000$BS4 set Y_ 420.000000000000$BS4 set Z_ 0.000000000000# movement of the MH# starts to move towards other BS set speed 20 set spoint 10.0set dpoint 420.0$MH set Y_ $spoint$MH set X_ $spoint$ns at 2.0 "$MH setdest $dpoint $dpoint $speed"$ns at 2.0 "puts ...MH=============>>>($dpoint,$dpoint)"$ns at 30.0 "$MH setdest $spoint $spoint $speed"$ns at 30.0 "puts ($spoint,$spoint)<<<=============MH..."if { $opt(x) == 0 || $opt(y) == 0 } {	usage $argv0	exit 1}if {$opt(seed) > 0} {	puts "Seeding Random number generator with $opt(seed)\n"	ns-random $opt(seed)}## Source the Connection and Movement scripts#if { $opt(cp) == "" } {	puts "*** NOTE: no connection pattern specified."        set opt(cp) "none"} else {	puts "Loading connection pattern..."	source $opt(cp)}if { $opt(sc) == "" } {	puts "*** NOTE: no scenario file specified."        set opt(sc) "none"} else {	puts "Loading scenario file..."	source $opt(sc)	puts "Load complete..."}# create links between wired and BaseStation nodes$ns duplex-link $CH   $W(0) 10Mb 2ms DropTail$ns duplex-link $W(0) $W(1) 10Mb 2ms DropTail$ns duplex-link $W(0) $W(2) 10Mb 2ms DropTail$ns duplex-link $W(1) $W(3) 10Mb 2ms DropTail$ns duplex-link $W(1) $W(4) 10Mb 2ms DropTail$ns duplex-link $W(2) $W(5) 10Mb 2ms DropTail$ns duplex-link $W(3) $BS1  10Mb 2ms DropTail$ns duplex-link $W(3) $BS2  10Mb 2ms DropTail$ns duplex-link $W(4) $BS3  10Mb 2ms DropTail$ns duplex-link $W(5) $BS4  10Mb 2ms DropTail$ns duplex-link-op $CH   $W(0) orient right $ns duplex-link-op $W(0) $W(1) orient left-down$ns duplex-link-op $W(0) $W(2) orient right-down$ns duplex-link-op $W(1) $W(3) orient left-down$ns duplex-link-op $W(1) $W(4) orient right-down $ns duplex-link-op $W(2) $W(5) orient right-down $ns duplex-link-op $W(3) $BS1  orient left-down$ns duplex-link-op $W(3) $BS2  orient right-down$ns duplex-link-op $W(4) $BS3  orient right-down$ns duplex-link-op $W(5) $BS4  orient right-down#make a node GW$W(0) MakeGW $CH#connect leaf nodes to root node$W(0) cipConnectToRoot $CH$W(1) cipConnectToRoot $W(0)$W(2) cipConnectToRoot $W(0)$W(3) cipConnectToRoot $W(1)$W(4) cipConnectToRoot $W(1)$W(5) cipConnectToRoot $W(2)$BS1 cipConnectToRoot $W(3)$BS2 cipConnectToRoot $W(3)$BS3 cipConnectToRoot $W(4)$BS4 cipConnectToRoot $W(5)##############################################Create a CBR agent and attach it to node CHset cbr0 [new Agent/CBR]$ns attach-agent $CH $cbr0$cbr0 set interval_ 0.01set null0 [new Agent/LossMonitor]$ns attach-agent $MH $null0$ns connect $cbr0 $null0$ns at 17.0 "$cbr0 start"$ns at 18.5 "$cbr0 stop"##############################################set cbr1 [new Agent/CBR]$ns attach-agent $MH $cbr1$cbr0 set interval_ 0.01set null1 [new Agent/LossMonitor]$ns attach-agent $CH $null1$ns connect $cbr1 $null1#$ns at 1.0 "$cbr1 start"#$ns at 1.5 "$cbr1 stop"############################################### Tell all the nodes when the simulation ends##for {set i 0} {$i < $num_wireless_nodes } {incr i} {#    $ns at $opt(stop).0000010 "$node_($i) reset";#}#$ns at $opt(stop).0000010 "$BS1 reset";#$ns at $opt(stop).0000010 "$BS2 reset";#$ns at $opt(stop).0000010 "$BS3 reset";#$ns at $opt(stop).0000010 "$BS4 reset";$ns at $opt(stop).21 "finish"$ns at $opt(stop).20 "puts \"NS EXITING...\" ; "###$ns halt"proc finish {} {	global ns trace namtrace	$ns flush-trace	close $namtrace#	close $trace	#puts "running nam..."	#exec nam out.nam &        puts "Finishing ns.."	exit 0}puts $tracefd "M 0.0 nn $opt(nn) x $opt(x) y $opt(y) rp $opt(rp)"puts $tracefd "M 0.0 sc $opt(sc) cp $opt(cp) seed $opt(seed)"puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)"puts "Starting Simulation..."$ns run

⌨️ 快捷键说明

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