根据之前几篇所学,可以通过NS2来仿真分析一个无限队长的排队系统中,聚合流服务的时延约束与队列溢出概率的关系。
1. Tcl代码:
# n0[poi]-
# |-r1-n2
# n1[onf]-
set ns [new Simulator]
#打开trace文件
set nd [open out.tr w]
$ns trace-all $nd
set namtracefd [open poisson.nam w]
$ns namtrace-all $namtracefd
#设置路由器(在ns2中,路由器就是节点)
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set r1 [$ns node]
$ns duplex-link $n0 $r1 10Mb 1ms DropTail
$ns duplex-link $n1 $r1 10Mb 1ms DropTail
$ns duplex-link $r1 $n2 1Mb 1ms RED
$ns duplex-link-op $n0 $r1 orient right-down
$ns duplex-link-op $n1 $r1 orient right-up
$ns duplex-link-op $r1 $n2 orient right
#相当于定义了一个方法
proc attach-expoo-traffic { node sink size burst idle rate } {
#Get an instance of the simulator
set ns [Simulator instance]
#Create a UDP agent and attach it to the node
set source [new Agent/UDP]
$ns attach-agent $node $source
#Create an Expoo traffic agent and set its configuration