set ns [new Simulator]
$ns color 1 blue
$ns color 2 red
set nf [open out.nam w]
$ns namtrace-all $nf
set nd [open out.tr w]
$ns trace-all $nd
proc Finish {} {
global ns nf nd
$ns flush-trace
close $nf
close $nd
exec nam out.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n2 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 1.7Mb 20ms DropTail
$ns queue-limit $n2 $n3 10
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n2 $n3 queuePos 0.5
set tcp [new Agent/TCP]
#$tcp set class_ 2
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink
$ns connect $tcp $sink
$tcp set fid_ 1
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
set udp [new Agent/UDP]
$ns attach-agent $n1 $udp
set null [new Agent/Null]
$ns attach-agent $n3 $null
$ns connect $udp $null
$udp set fid_ 2
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 1mb
$cbr set random_ false
$ns at 0.1 "$cbr start"
$ns at 1.0 "$ftp start"
$ns at 4.0 "$ftp stop"
$ns at 4.5 "$cbr stop"
$ns at 5.0 "Finish"
$ns run
分享到:
相关推荐
class_example.tcl ) 书上的例子,ns学习基础
ns2中simple.tcl的代码和awk文件以及结果
NS2学习中必备资料,非常适合于初学者。提供了大量的实例,并进行细致的讲解和分析,虽然是英文,但是理解起来不难。
aodv.tcl aodv protocol ns2 ver.2.34
ns-leach.tcl详细注解
ns2下的TCL相关的一些编程实例,亲测可以运行
运行tcl脚本来实现隐藏节点问题,再通过nam仿真动画...注意:请下载全所有的文件后进行仿真,仿真时需下载好mudp.cc、mudp.h、mudpsink.cc、mudpsink.h 模块在ns2上编译后即可使用Hidden_Terminal.tcl文件进行仿真。
tcl script to simulate dsdv in ns2
......\ex-tcl.tcl ......\ex-web.tcl ......\Example.htm ......\example_lan.html ......\example_mcast.html ......\example_srm.html ......\example_web.html ......\FAQ.html ......\Figure
NS3中的第三个例子讲解,相比于网上其他的讲解来说,本文档对first.cc的讲解更加详细,有助于加快NS3的上手过程
SMAC TCL script for NS2
dsr.tcl routing protocol for routing dsr in ad hoc using ns2
NS2_Wired_Example 生成有线NS2场景的示例TCL脚本 这是用于多层建筑物/社团中的自动火灾探测。每个街区有15座房屋,每座房屋有5个启用了传感器的房间。所有终端设备均配备有控制器,该控制器可根据每个房间中测得的...
ns的一些例子,有助于ns入门学习,ns example
在ns2下仿真IEEE802.15.4协议的代码
windows NS2中进行无线传感器网络模拟的tcl例子文件,是完整的,直接可以执行。
ns2下添加新协议common/packet.h tcl/lib/ns-default.tcl tcl/lib/ns-packet.tcl Makefile pong.cc
Linux系统下,基于NS2的多播算法模拟,.tcl文件,需要添加的类ns2-2.33中已带
ns-simple.tcl is a simple test file
学习NS2入门非常好的资料:ns_by_Example.rar