#Create a simulator object
set ns [new Simulator]
#Define different colors for data flows (for NAM)
$ns color 0 blue
$ns color 1 red
$ns color 2 white
#Create four nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#预先定义trace file
f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w] #Open the NAM trace file
$ns namtrace-all $nf
#Create links between the nodes (双向链接)
$ns duplex-link $n0 $n2 5Mb 2ms DropTail
$ns duplex-link $n1 $n2 5Mb 2ms DropTail
$ns duplex-link $n2 $n3 1.5Mb 10ms DropTail
Drop Tail(队列长度管理机制,丢尾)
它有点类似于FIFO(先入先出)的存储方式。Drop Tail最大的优点是原理简单。
当路由器队列长度达到最大值时,通过丢包来指示拥塞,先到达路由器的分组首先被传输。
由于路由器缓存有限,如果包到达时缓存已满,那么路由器就丢弃该分组。
一旦发生丢包,发送端立即被告知网络拥塞,从而调整发送速率。这种做法不考虑被丢