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

📄 test-suite-diffusion3.tcl

📁 跑leach需要的
💻 TCL
📖 第 1 页 / 共 3 页
字号:
## Copyright (c) 1998 University of Southern California.# All rights reserved.                                            #                                                                # Redistribution and use in source and binary forms are permitted# provided that the above copyright notice and this paragraph are# duplicated in all such forms and that any documentation, advertising# materials, and other materials related to such distribution and use# acknowledge that the software was developed by the University of# Southern California, Information Sciences Institute.  The name of the# University may not be used to endorse or promote products derived from# this software without specific prior written permission.# # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.# # To run all tests: test-all-diffusion3# to run individual test:# ns test-suite-diffusion3.tcl simple-ping# To view a list of available test to run with this script:# ns test-suite-diffusion3.tcl# This test validates a simple diffusion (ping) applicationAgent/TCP set tcpTick_ 0.1# The default for tcpTick_ is being changed to reflect a changing reality.Agent/TCP set rfc2988_ false# The default for rfc2988_ is being changed to true.Agent/TCP set exitFastRetrans_ falseif {![TclObject is-class Agent/DiffusionRouting]} {	puts "Diffusion3 module is not present; validation skipped"	exit 2}# ======================================================================# Define options# ======================================================================global optset 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(ifqlen)		50		;# max packet in ifqset opt(seed)		0.0set opt(lm)             "off"           ;# log movementset opt(x)		670	;# X dimension of the topographyset opt(y)		670     ;# Y dimension of the topographyset opt(stop)		300	;# simulation timeset opt(adhocRouting)   Directed_Diffusion# ======================================================================LL set mindelay_		50usLL set delay_			25usLL set bandwidth_		0	;# not usedAgent/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_ 1.0Antenna/OmniAntenna set Gr_ 1.0# 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 Pt_ 0.2818Phy/WirelessPhy set freq_ 914e+6 Phy/WirelessPhy set L_ 1.0# ======================================================================Class TestSuiteproc usage {} {    global argv0    puts stderr "usage: ns $argv0 <tests> "    puts "Valid Tests: simple-ping 2pp-5n-1s-1r 2pp-10n-4s-1r 2pp-10n-1s-4r\push-5n-1s-1r push-10n-4s-1r push-10n-1s-4r 1pp-5n-1s-1r 1pp-10n-4s-1r 1pp-10n-1s-4r gear-2pp-10n-4s-1r gear-push-10n-1s-4r"    exit 1}TestSuite instproc init {} {    global opt tracefd quiet    $self instvar ns_    set ns_ [new Simulator]    set tracefd [open temp.rands w]    $ns_ trace-all $tracefd    # stealing seed from another test-suite    ns-random 188312339} Class Test/simple-ping -superclass TestSuiteTest/simple-ping instproc init {} {    global opt    set opt(nn) 3    set opt(filters) GradientFilter    $self instvar ns_ testName_    set testName_ simple-ping    $self next}Test/simple-ping instproc run {} {    global opt    $self instvar ns_ topo god_    set topo	[new Topography]    $topo load_flatgrid $opt(x) $opt(y)    set god_ [create-god $opt(nn)]    $ns_ node-config -adhocRouting $opt(adhocRouting) \		 -llType $opt(ll) \		 -macType $opt(mac) \		 -ifqType $opt(ifq) \		 -ifqLen $opt(ifqlen) \		 -antType $opt(ant) \		 -propType $opt(prop) \		 -phyType $opt(netif) \		 -channelType $opt(chan) \		 -topoInstance $topo \	         -diffusionFilter $opt(filters) \		 -agentTrace ON \                 -routerTrace ON \                 -macTrace OFF                  for {set i 0} {$i < $opt(nn) } {incr i} {	set node_($i) [$ns_ node $i]        $node_($i) color black	$node_($i) random-motion 0		;# disable random motion        $god_ new_node $node_($i)    }# defining node positions    $node_(0) set X_ 500.716707738489    $node_(0) set Y_ 620.707335765875    $node_(0) set Z_ 0.000000000000        $node_(1) set X_ 320.192740186325    $node_(1) set Y_ 450.384818286195    $node_(1) set Z_ 0.000000000000    #3rd node NOT in hearing range of other two    $node_(2) set X_ 177.438972165239    $node_(2) set Y_ 245.843469852367    $node_(2) set Z_ 0.000000000000    #Diffusion application - ping src    set src_(0) [new Application/DiffApp/PingSender/TPP]    $ns_ attach-diffapp $node_(0) $src_(0)    $ns_ at 0.123 "$src_(0) publish"    #Diffusion application - ping sink    set snk_(0) [new Application/DiffApp/PingReceiver/TPP]    $ns_ attach-diffapp $node_(2) $snk_(0)    $ns_ at 1.456 "$snk_(0) subscribe"    #    # Tell nodes when the simulation ends    #    for {set i 0} {$i < $opt(nn) } {incr i} {	$ns_ at $opt(stop).000000001 "$node_($i) reset";    }    $ns_ at  $opt(stop).000000001 "puts \"NS EXITING...\" ; $ns_ halt"    $ns_ run}Class Test/2pp-5n-1s-1r -superclass TestSuiteTest/2pp-5n-1s-1r instproc init {} {     global opt     set opt(nn) 5     set opt(filters) GradientFilter     $self instvar ns_ testName_     set testName_ 2pp-5n-1s-1r     $self next }Test/2pp-5n-1s-1r instproc run {} {     global opt     $self instvar ns_ topo god_     set topo	[new Topography]     $topo load_flatgrid $opt(x) $opt(y)     set god_ [create-god $opt(nn)]     $ns_ node-config -adhocRouting $opt(adhocRouting) \	 -llType $opt(ll) \	 -macType $opt(mac) \	 -ifqType $opt(ifq) \	 -ifqLen $opt(ifqlen) \	 -antType $opt(ant) \	 -propType $opt(prop) \	 -phyType $opt(netif) \	 -channelType $opt(chan) \	 -topoInstance $topo \	 -diffusionFilter $opt(filters) \	 -agentTrace ON \	 -routerTrace ON \	 -macTrace OFF                  for {set i 0} {$i < $opt(nn) } {incr i} {	 set node_($i) [$ns_ node $i]	 $node_($i) color black	 $node_($i) random-motion 0		;# disable random motion	 $god_ new_node $node_($i)     }     # defining node positions     $node_(0) set X_ 618.716707738489     $node_(0) set Y_ 620.707335765875     $node_(0) set Z_ 0.000000000000         $node_(1) set X_ 524.192740186325     $node_(1) set Y_ 540.384818286195     $node_(1) set Z_ 0.000000000000         $node_(2) set X_ 406.438972165239     $node_(2) set Y_ 425.843469852367     $node_(2) set Z_ 0.000000000000         $node_(3) set X_ 320.192740186325     $node_(3) set Y_ 350.384818286195     $node_(3) set Z_ 0.000000000000         $node_(4) set X_ 177.438972165239     $node_(4) set Y_ 145.843469852367     $node_(4) set Z_ 0.000000000000         #Diffusion application - ping sender     set src_(0) [new Application/DiffApp/PingSender/TPP]     $ns_ attach-diffapp $node_(0) $src_(0)     $ns_ at 0.123 "$src_(0) publish"     #Diffusion application - ping receiver     set snk_(0) [new Application/DiffApp/PingReceiver/TPP]     $ns_ attach-diffapp $node_(2) $snk_(0)     $ns_ at 1.456 "$snk_(0) subscribe"#     ##     # Tell nodes when the simulation ends#     #     for {set i 0} {$i < $opt(nn) } {incr i} {	 $ns_ at $opt(stop).000000001 "$node_($i) reset";     }     $ns_ at  $opt(stop).000000001 "puts \"NS EXITING...\" ; $ns_ halt"     $ns_ run }Class Test/2pp-10n-4s-1r -superclass TestSuite Test/2pp-10n-4s-1r instproc init {} {     global opt     set opt(nn) 10     set opt(sndr) 4     set opt(rcvr) 1     set opt(filters) GradientFilter     $self instvar ns_ testName_     set testName_ 2pp-10n-4s-1r     $self next } Test/2pp-10n-4s-1r instproc run {} {     global opt     $self instvar ns_ topo god_     set topo	[new Topography]     $topo load_flatgrid $opt(x) $opt(y)     set god_ [create-god $opt(nn)]     $ns_ node-config -adhocRouting $opt(adhocRouting) \ 		 -llType $opt(ll) \ 		 -macType $opt(mac) \ 		 -ifqType $opt(ifq) \ 		 -ifqLen $opt(ifqlen) \ 		 -antType $opt(ant) \ 		 -propType $opt(prop) \ 		 -phyType $opt(netif) \ 		 -channelType $opt(chan) \ 		 -topoInstance $topo \ 	         -diffusionFilter $opt(filters) \ 		 -agentTrace ON \                  -routerTrace OFF \                  -macTrace OFF                  for {set i 0} {$i < $opt(nn) } {incr i} { 	set node_($i) [$ns_ node $i]         $node_($i) color black 	$node_($i) random-motion 0		;# disable random motion         $god_ new_node $node_($i)     }     # defining node positions     $node_(0) set X_ 18.587605569735     $node_(0) set Y_ 401.886827012678     $node_(0) set Z_ 0.000000000000     $node_(1) set X_ 11.901958617639     $node_(1) set Y_ 36.218497218617     $node_(1) set Z_ 0.000000000000     $node_(2) set X_ 224.282785411393     $node_(2) set Y_ 20.774608253697     $node_(2) set Z_ 0.000000000000     $node_(3) set X_ 158.840938304009     $node_(3) set Y_ 139.650216383776     $node_(3) set Z_ 0.000000000000     $node_(4) set X_ 101.186886005903     $node_(4) set Y_ 147.993190973633     $node_(4) set Z_ 0.000000000000     $node_(5) set X_ 321.560825121175     $node_(5) set Y_ 472.788096833600     $node_(5) set Z_ 0.000000000000     $node_(6) set X_ 149.543901734330     $node_(6) set Y_ 384.356581531832     $node_(6) set Z_ 0.000000000000     $node_(7) set X_ 381.066146464027     $node_(7) set Y_ 78.723958958779     $node_(7) set Z_ 0.000000000000     $node_(8) set X_ 113.578290026963     $node_(8) set Y_ 410.320583900348     $node_(8) set Z_ 0.000000000000     $node_(9) set X_ 258.053977148981     $node_(9) set Y_ 113.194171851670     $node_(9) set Z_ 0.000000000000         # 4 ping senders     for {set i 0} {$i < $opt(sndr)} {incr i} {	 set src_($i) [new Application/DiffApp/PingSender/TPP]	 $ns_ attach-diffapp $node_([expr $i+2]) $src_($i)	 $ns_ at [expr 0.123 * $i] "$src_($i) publish"     }#     # 1 ping receiver     set snk_(0) [new Application/DiffApp/PingReceiver/TPP]     $ns_ attach-diffapp $node_(9) $snk_(0)     $ns_ at 1.456 "$snk_(0) subscribe"          #     #     #     # Tell nodes when the simulation ends     #     #     for {set i 0} {$i < $opt(nn) } {incr i} {	 $ns_ at $opt(stop).000000001 "$node_($i) reset";     }     $ns_ at  $opt(stop).000000001 "puts \"NS EXITING...\" ; $ns_ halt"     $ns_ run }Class Test/2pp-10n-1s-4r -superclass TestSuiteTest/2pp-10n-1s-4r instproc init {} {    global opt    set opt(nn) 10    set opt(sndr) 1    set opt(rcvr) 4    set opt(filters) GradientFilter    $self instvar ns_ testName_    set testName_ 2pp-10n-1s-4r    $self next}Test/2pp-10n-1s-4r instproc run {} {    global opt    $self instvar ns_ topo god_        set topo	[new Topography]    $topo load_flatgrid $opt(x) $opt(y)    set god_ [create-god $opt(nn)]        $ns_ node-config -adhocRouting $opt(adhocRouting) \	-llType $opt(ll) \	-macType $opt(mac) \	-ifqType $opt(ifq) \	-ifqLen $opt(ifqlen) \	-antType $opt(ant) \	-propType $opt(prop) \	-phyType $opt(netif) \	-channelType $opt(chan) \	-topoInstance $topo \	-diffusionFilter $opt(filters) \	-agentTrace ON \	-routerTrace OFF \	-macTrace OFF         for {set i 0} {$i < $opt(nn) } {incr i} { 	set node_($i) [$ns_ node $i]         $node_($i) color black 	$node_($i) random-motion 0		;# disable random motion         $god_ new_node $node_($i)    }     # defining node positions     $node_(0) set X_ 18.587605569735     $node_(0) set Y_ 401.886827012678     $node_(0) set Z_ 0.000000000000     $node_(1) set X_ 11.901958617639     $node_(1) set Y_ 36.218497218617     $node_(1) set Z_ 0.000000000000     $node_(2) set X_ 224.282785411393     $node_(2) set Y_ 20.774608253697     $node_(2) set Z_ 0.000000000000     $node_(3) set X_ 158.840938304009     $node_(3) set Y_ 139.650216383776     $node_(3) set Z_ 0.000000000000     $node_(4) set X_ 101.186886005903     $node_(4) set Y_ 147.993190973633     $node_(4) set Z_ 0.000000000000     $node_(5) set X_ 321.560825121175     $node_(5) set Y_ 472.788096833600     $node_(5) set Z_ 0.000000000000     $node_(6) set X_ 149.543901734330     $node_(6) set Y_ 384.356581531832     $node_(6) set Z_ 0.000000000000     $node_(7) set X_ 381.066146464027     $node_(7) set Y_ 78.723958958779     $node_(7) set Z_ 0.000000000000     $node_(8) set X_ 113.578290026963     $node_(8) set Y_ 410.320583900348     $node_(8) set Z_ 0.000000000000     $node_(9) set X_ 258.053977148981     $node_(9) set Y_ 113.194171851670     $node_(9) set Z_ 0.000000000000        # 1 ping sender    for {set i 0} {$i < $opt(sndr)} {incr i} { 	set src_($i) [new Application/DiffApp/PingSender/TPP]	$ns_ attach-diffapp $node_([expr $i+2]) $src_($i) 	$ns_ at [expr 0.123 * [expr 1+$i]] "$src_($i) publish"    }     # 4 ping receiver     for {set i 0} {$i < $opt(rcvr)} {incr i} { 	set snk_($i) [new Application/DiffApp/PingReceiver/TPP]

⌨️ 快捷键说明

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