ns 2.35 柯志亨书-实验3笔记-TCP UDP模拟

这篇博客记录了使用ns2.35进行TCP UDP模拟实验的过程,主要涉及TCL代码的使用。通过添加'-persist'选项防止gnuplot弹出多余信息,保持图形显示。同时,博主对'<<EOF'的含义表示疑惑,它是TCL中的结束标记,用于输入流的结束。
摘要由CSDN通过智能技术生成

上图是笔记

下面是tcl代码:

#Create a simulator object
set ns [new Simulator]

#Set different color for dif flow
$ns color 1 Blue
$ns color 2 Red

set tracefd [open example1.tr w]
$ns trace-all $tracefd
set namtracefd [open example1.nam w]
$ns namtrace-all $namtracefd

proc finish {} {
		global ns tracefd namtracefd
		$ns flush-trace
		close $tracefd
		close $namtracefd
		exec nam example1.nam &
		exit 0
}

# Set nodes, s1's id is 0, s2'id is 1
set s1 [$ns node]
set s2 [$ns node]

# Set router node, id of r is 2
set r [$ns node]
# Set dest node, id of r is 3
set d [$ns node]

# Set link parameters
$ns duplex-link $s1 $r 2Mb   10ms DropTail
$ns duplex-link $s2 $r 2Mb   10ms DropTail
$ns duplex-link $r  $d 1.7Mb 20ms DropTail

# Set Queue l
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值