NS by Example 笔记(14)LAN Example

LAN Example

(Obsolete: work with ns-2.1b4a)

 

LAN例子的模拟脚本并演示了它的网络拓扑和模拟场景。 模拟脚本 "ex-lan.tcl"。

 




 
Figure 32. LAN simulation network topology and scenario

 

 

# Author: Jae Chung
# Date:   7/20/99
#
# This file is modified from 
# "ns-2/tcl/ex/lantest.tcl"

set opt(tr)	"out.tr"
set opt(namtr)	"out.nam"
set opt(seed)	0
set opt(stop)	5
set opt(node)	8

set opt(qsize)	100
set opt(bw)	10Mb
set opt(delay)	1ms
set opt(ll)	LL
set opt(ifq)	Queue/DropTail
set opt(mac)	Mac/Csma/Ca
set opt(chan)	Channel
set opt(tcp)	TCP/Reno
set opt(sink)	TCPSink

set opt(app)	FTP


proc finish {} {
	global ns opt trfd ntrfd

	$ns flush-trace
	close $trfd
        close $ntrfd
	exec nam $opt(namtr) &
	exit 0
}

proc create-trace {} {
	global ns opt

	set trfd [open $opt(tr) w]
	$ns trace-all $trfd
	return $trfd
}

proc create-namtrace {} {
        global ns opt

        set ntrfd [open $opt(namtr) w]
        $ns namtrace-all $ntrfd
}

proc create-topology {} {
	global ns opt
	global lan node source node0

	set num $opt(node)
	for {set i 0} {$i < $num} {incr i} {
		set node($i) [$ns node]
		lappend nodelist $node($i)
	}

	set lan [$ns newLan $nodelist $opt(bw) $opt(delay) \
			-llType $opt(ll) -ifqType $opt(ifq) \
			-macType $opt(mac) -chanType $opt(chan)]

	set node0 [$ns node]
	$ns duplex-link $node0 $node(0) 2Mb 2ms DropTail

	$ns duplex-link-op $node0 $node(0) orient right

}

## MAIN ##

set ns [new Simulator]
set trfd [create-trace]
set ntrfd [create-namtrace]

create-topology

set tcp0 [$ns create-connection TCP/Reno $node0 TCPSink $node(7) 0]
$tcp0 set window_ 15

set ftp0 [$tcp0 attach-app FTP]

$ns at 0.0 "$ftp0 start"
$ns at $opt(stop) "finish"

$ns run

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值