Hi list!

I'm having some problems using the emulation examples.
I try to use ns-2 as a forwarder: real host A send a ping to real host B, 
passing through the simulator, C. After adding the correct route to A and B to 
use C as a gateway, I use this script (because the one with ns-2 doesn't work 
at all)

# Inside the simulator
#
# node(5)
# / \
# / \
# node(2) node(1)


set ns [new Simulator]
$ns use-scheduler RealTime

set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf

# Create the nodes
set n1 [$ns node]; #reading from real network
set n2 [$ns node]; #writing to the real network
set n5 [$ns node]; #nothing important


# Configure the entry node
set bpf1 [new Network/Pcap/Live]; # Create the bpf
set dev1 [$bpf1 open readonly eth0]; # Open the device
$bpf1 filter "icmp and host 192.168.0.3";# put the filter
set tap1 [new Agent/Tap]; # Create the Tap Agent
$tap1 network $bpf1; # Connect bpf to Tap Agent
$ns attach-agent $n1 $tap1; # Attach Tap Agent to the node(1)

# Configure the exit node
set ipnet [new Network/IP]; # Create a Network agent
$ipnet open writeonly
set tap2 [new Agent/Tap]; # Create a Tap Agent
$tap2 network $ipnet; # Connect network agent to tap agent
$ns attach-agent $n2 $tap2; # Attach agent to the node.


# Connect the agents.
$ns simplex-connect $tap1 $tap2

#Just for debug
puts "tap1: $tap1"
puts "tap2: $tap2"


puts "Node1: $n1"
puts "Node2: $n2"
puts "Node5: $n5"

puts "bpf1: $bpf1"
puts "ipnet: $ipnet"


# Setup connections between the nodes
$ns simplex-link $n1 $n2 10Mb 5ms DropTail
$ns simplex-link $n5 $n2 10Mb 5ms DropTail


$ns at 10 "finish"

proc finish {} {
global ns f nf
$ns flush-trace
close $f
close $nf
exit 0
}

$ns run


If I run this script, the packets are forwarded, but the simulator begins to 
create a very big traffic of dup packet:
...
TapAgent(_o24): sent packet (sz: 60)
TapAgent(_o24): sent packet (sz: 60)
TapAgent(_o24): sent packet (sz: 60)
TapAgent(_o24): sent packet (sz: 60)
TapAgent(_o24): sent packet (sz: 60)
TapAgent(_o24): sent packet (sz: 60)
TapAgent(_o24): sent packet (sz: 60)
TapAgent(_o24): sent packet (sz: 60)
4.835407: Tap(_o21): recvpkt, cc:60
4.835407: Tap(_o21): recvpkt, writing to target: _o13
4.835578: Tap(_o21): recvpkt, cc:60
4.835578: Tap(_o21): recvpkt, writing to target: _o13
4.835698: Tap(_o21): recvpkt, cc:60
4.835698: Tap(_o21): recvpkt, writing to target: _o13
4.835807: Tap(_o21): recvpkt, cc:60
4.835807: Tap(_o21): recvpkt, writing to target: _o13
4.835976: Tap(_o21): recvpkt, cc:60
4.835976: Tap(_o21): recvpkt, writing to target: _o13
4.836086: Tap(_o21): recvpkt, cc:60
...

I really don't understand why. And if I use IPTap for the 2 tap I get:

IPTapAgent(_o21): sendpkt called while in read-only mode!
0.770541: IPTapAgent(_o21): recvpkt, cc:1

Thank you very much for any idea/suggestion/tip.

Paolo Carpo

P.S. Sorry for the poor english

Reply via email to