[ns] About emulation for tcp traffic
=?gb2312?b?1uzF9A==?=
zhupeng00 at mails.tsinghua.edu.cn
Sun Jul 19 22:54:04 PDT 2009
Dear NS users:
I met some problem for TCP emulation.
NS version I used is 2.30, and the OS is fedora Linux. In the emulation, I want to let the real traffic (from machine A to C) pass through the emulation machine B (with two network cards) which emulate some virtual network topology. I slightly modify the tcl code in the directory of "emulate". I found with emulation, A and C can ping each other. Also emulation is ok for UDP traffic (e.g. tftp, a kind of UDP-based ftp application). However, for tcp traffic (e.g. http or ftp), there exist some communication error. For example, for http, when http client sends get message, http server will reply with multiple http 200 ok msg, then the connection will be terminated.
I heard that emulation function is only tested in FreeBSD. I wonder if there is anyone who successfully run such emulation in Linux. If you have such experience, could you share your tcl code with me?
Thank you very much for your help.
Best regards,
Peng
--------------------------------------------------------------------------------------------
The following is the used tcl code:
# em2.tcl - test emulation
# be careful here, as the tap agents will
# send out whatever they are given
#
set dotrace 0
set ns [new Simulator]
if { $dotrace } {
set allchan [open em-all.tr w]
$ns trace-all $allchan
set namchan [open em.nam w]
$ns namtrace-all $namchan
}
$ns use-scheduler RealTime
#
# we want the test machine to have ip forwarding disabled, so
# check this
#
set ipforw [exec sysctl -n net.ipv4.ip_forward]
if { $ipforw } {
puts "can not run with ip forwarding enabled"
exit 1
}
#
# allocate a BPF type network object and a raw-IP object
#
set bpf0 [new Network/Pcap/Live]
set bpf1 [new Network/Pcap/Live]
$bpf0 set promisc_ true
$bpf1 set promisc_ true
set ipnet [new Network/IP]
set nd0 [$bpf0 open readonly eth0]
set nd1 [$bpf1 open readonly eth2]
$ipnet open writeonly
puts "bpf0($bpf0) on dev $nd0, bpf1($bpf1) on dev $nd1, ipnet is $ipnet"
#
# try to filter out wierd stuff like netbios pkts, arp requests, dns, etc
# also to avoid pcap retrieve the packets sent by $ipnet
# network of eth0 is 192.168.200.*, and network of eth2 is 192.168.100.*
#
set notbcast "(not ether broadcast)"
set f0len [$bpf0 filter "not dst net 192.168.200 and $notbcast"]
set f1len [$bpf1 filter "not dst net 192.168.100 and $notbcast"]
puts "filter lengths: $f0len (bpf0), $f1len (bpf1)"
puts "dev $nd0 has address [$bpf0 linkaddr]"
puts "dev $nd1 has address [$bpf1 linkaddr]"
set a0 [new Agent/Tap]
set a1 [new Agent/Tap]
set a2 [new Agent/Tap]
puts "install nets into taps..."
$a0 network $bpf0
$a1 network $bpf1
$a2 network $ipnet
set node0 [$ns node]
set node1 [$ns node]
set node2 [$ns node]
puts "node0: $node0 (id:[$node0 id]), node1: $node1 (id:[$node1 id]), node2: $node2 (id: [$node2 id])"
$ns simplex-link $node0 $node2 80Mb 1ms DropTail
$ns simplex-link $node1 $node2 80Mb 1ms DropTail
$ns attach-agent $node0 $a0
$ns attach-agent $node1 $a1
$ns attach-agent $node2 $a2
$ns connect $a0 $a2
$ns connect $a1 $a2
puts "let's rock"
$ns run
More information about the Ns-users
mailing list