[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] How to run MFTP on ns
mftp_snd.tcl and mftp_rcv.tcl are all in the ~/tcl/mcast sub-directory.
Here is a SAMPLE code !!
# SOURCE CODE partly from Christoph Haenle
#
# (c) 1999-2000 Aberdeen University Electronics Research Lab
#
# Contributed by: Martin Koyabe, [email protected]
# File: mftp_2.tcl
# Last update: Jan 12, 2000
#
# This script creates a source and two receivers with asymmetric links based
# on a 10Mb/s LAN
# finish simulation routine
proc finish { } {
global ns sender recv01 recv02 mftp_trace nf
$ns flush-trace
close $nf
puts stdout "view output in mftp.tr"
puts stdout " "
puts stdout "Simulation successfully completed ...."
exit 0
}
# setup simulator
set ns [new Simulator -multicast on]
$ns multicast
DM set PruneTimeout 100 ;# PruneTimeout set to 100s
set verbose 1
set group_size 16
set file_size 2000000
set group_addr [Node allocaddr] ;# allocate multicast group address
# if needed, trace link events:
# set f [open out.tr w]
# $ns trace-all $f
set mftp_trace [open mftp_2.tr w]
$ns trace-all $mftp_trace
# create the nam output file
#set nf [open mftp_2.nam w]
#$ns namtrace-all $nf
# create network topology like this:
# 3
# /
# /
# 0--------1
# \
# \
# 2
# setup nodes
if {$verbose} {puts "Creating Nodes ....."}
set i 0
while {$i < 4} {
set nodes_($i) [$ns node]
incr i
}
# setup links
if {$verbose} {puts "Creating Links ....."; flush stdout}
$ns duplex-link $nodes_(0) $nodes_(1) 1.5Mb 10ms DropTail
$ns duplex-link $nodes_(1) $nodes_(2) 1.5Mb 10ms DropTail
$ns duplex-link $nodes_(1) $nodes_(3) 1.5Mb 10ms DropTail
# $ns duplex-link $n0 $n1 1.5Mb 10ms DropTail
# $ns duplex-link $n1 $n2 1.5Mb 10ms DropTail
# $ns duplex-link $n1 $n3 1.5Mb 10ms DropTail
set mh [$ns mrtproto DM {}]
## <Optional Syntax>
# set mproto DM
# set mh [$ns mrtproto $mproto {}]
# color codes
$ns color 0 black
$ns color 1 blue
$ns color 2 purple
$ns color 3 green
# setup MFTP sender
set sender [new Agent/MFTP/Snd]; # new sender instance
$ns attach-agent $nodes_(0) $sender; # attach MFTP-sender to node
$sender set dst_addr_ $group_addr; # set destination address
$sender set fid_ 1; # flow-id (for use in nam)
$sender set fileSize_ $file_size; # size of file in bytes
$sender set dtusPerGroup_ $group_size; # set transmission group size (in
pkts/group)
$sender set dtusPerBlock_ 1424; # set block size (in pkts/block),
must
be multiple of 8
$sender set interval_ 0.20; # set interval between 2 packet
transmissions (in s)
$sender trace $mftp_trace; # optional set trace-file
set sender_addr [$sender set dst_addr_]
# setup 1st MFTP receiver:
set recv01 [new Agent/MFTP/Rcv]
$ns attach-agent $nodes_(2) $recv01
$recv01 set dst_addr_ $group_addr
$recv01 set reply_addr_ $sender_addr; # address to which packets are sent
(unicast)
$recv01 set fid_ 2
$recv01 set fileSize_ $file_size
$recv01 set dtusPerGroup_ $group_size
$recv01 set dtusPerBlock_ 1424
$recv01 trace $mftp_trace
# setup 2nd MFTP receiver:
set recv02 [new Agent/MFTP/Rcv]
$ns attach-agent $nodes_(3) $recv02
$recv02 set dst_addr_ $group_addr
$recv02 set reply_addr_ $sender_addr; # address to which packets are sent
(unicast)
$recv02 set fid_ 3
$recv02 set fileSize_ $file_size
$recv02 set dtusPerGroup_ $group_size
$recv02 set dtusPerBlock_ 1424
$recv02 trace $mftp_trace
# setup a couple of TCP-connections:
foreach node [list $nodes_(2) $nodes_(2) $nodes_(3) $nodes_(3)] {
# register TCP senders:
set tcp_src [new Agent/TCP/Reno]
$tcp_src set cls 2
$ns attach-agent $nodes_(1) $tcp_src
set ftp [new Source/FTP]
$ftp set agent_ $tcp_src
$ns at 0 "$ftp produce 10000000"
# register receiver:
set tcp_snk [new Agent/TCPSink]
$ns attach-agent $node $tcp_snk
# connect sender with receiver
$ns connect $tcp_src $tcp_snk
}
puts stdout "Transmitting $file_size byte file with group-size $group_size"
puts stdout "simulation is running..."
$ns at 0.0 "$sender start"; # set time of start of transmission
$ns at 0.1 "$recv01 start"
$ns at 0.1 "$recv02 start"
$ns at 100.0 "finish"
$ns run
-- Martin
> From: Masahiro Ogawa <[email protected]>
> Date: Fri, 15 Dec 2000 15:24:25 +0900
> To: [email protected]
> Subject: [ns] How to run MFTP on ns
>
>
> Hi,
> I want to run MFTP on NS.
> I could find a mftp_snd.tcl and a mftp_rcv.tcl.
> But, I can't understand them completely.
> I want to deepen the understanding of MFTP more with
> what is done referring to an sample program like other agents.
> If there is a person who has the sample program
> which used MFTP, I want myself to teach it.
>
>
> thanks.
>
>
>