Hi list!
I got a problem handling broadcast packets. Here it is the code:
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
proc finish {} {
global ns f nf
$ns flush-trace
close $f
close $nf
exit 0
}
set node1 [$ns node]
set node2 [$ns node]
set node3 [$ns node]
set node4 [$ns node]
set node5 [$ns node]
set node6 [$ns node]
#Network objects to access the TAP devices at the link layer
set raw1 [new Network/Raw]
set raw2 [new Network/Raw]
set raw3 [new Network/Raw]
set raw4 [new Network/Raw]
$raw1 open tap0 readwrite
$raw2 open tap1 readwrite
$raw3 open tap2 readwrite
$raw4 open tap3 readwrite
#Tap Agent for each node
Agent/Tap set maxpkt_ 3100
set a1 [new Agent/Tap/Raw "FE:FD:0A:00:00:02"]
set a2 [new Agent/Tap/Raw "FE:FD:0A:00:00:03"]
set a3 [new Agent/Tap/Raw "FE:FD:0A:00:00:04"]
set a4 [new Agent/Tap/Raw "FE:FD:0A:00:00:05"]
puts "install nets into taps..."
#Assign network objects to TAP agents
$a1 network $raw1
$a2 network $raw2
$a3 network $raw3
$a4 network $raw4
#Assign TAP agents to ns-2 nodes
$ns attach-agent $node1 $a1
$ns attach-agent $node2 $a2
$ns attach-agent $node3 $a3
$ns attach-agent $node4 $a4
# Setup connections between the nodes
$ns duplex-link $node1 $node5 2Mb 2ms DropTail
$ns duplex-link $node2 $node5 2Mb 2ms DropTail
$ns duplex-link $node5 $node6 2Mb 15ms DropTail
$ns duplex-link $node6 $node3 2Mb 2ms DropTail
$ns duplex-link $node6 $node4 2Mb 2ms DropTail
$ns at 20.0 "finish"
$ns run
I'm using a nse extension to have some real (UML) machines talking each other
via ns-2. If I use this code I get the error:
[EMAIL PROTECTED] ns2emulation]# ../nse mah.tcl
Using gettimeofday() insdead of the CPU cycle counter to guarantee portability
install nets into taps...
TapAgent: changing the src and dst address to 0:0 ---> -1:0
0.478134: Tap(_o33): recvpkt, writing to target: _o13
--- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
_o13: no target for slot -1
_o13 type: Classifier/Hash/Dest
content dump:
classifier _o13
0 offset
0 shift
2147483647 mask
1 slots
slot 0: _o37 (Classifier/Port)
-1 default
---------- Finished standard no-slot{} default handler ----------
Usually I get this error when something is not correctly linked. If on the UML
machines I set the ARP statically, it's work (I get the error on the
arp-request Who has 10.0.0.2...that is broadcast)
The code than handle this is:
void
RawTapAgent::processpkt (Packet* p, const NodeInfo& srcinfo) {
hdr_cmn* ch = HDR_CMN(p);
hdr_ip* ip = HDR_IP(p);
NodeInfo dstinfo = ((uint8_t*)p->accessdata ());
if (dstinfo.mac () == NodeInfo::broadcast_addr) { //A broadcast packet
ip->daddr () = IP_BROADCAST;
ip->dport () = 0;
TDEBUG5 ("TapAgent: changing the src and dst address to %d:%d
---> %d:%d\n", srcinfo.get_node_addr (), 0, -1, 0);
} else {
nit = lower_bound (nodes.begin (), nodes.end (), dstinfo);
if (nit == nodes.end () || (dstinfo < *nit)) { //Destination
address not found in the map table
Packet::free (p);
TDEBUG ("Dropped packet: invalid destination\n");
return;
}
ip->daddr () = (*nit).get_node_addr ();
ip->dport () = 0;
TDEBUG5 ("TapAgent: changing the src and dst address to %d:%d
---> %d:%d\n", srcinfo.get_node_addr (), 0, (*nit).get_node_addr (), 0);
}
ip->saddr () = srcinfo.get_node_addr ();
ip->sport () = 0;
TDEBUG4("%f: Tap(%s): recvpkt, writing to target: %s\n",
now(), name(), target_->name());
Scheduler::instance().sync ();
ch->timestamp() = now();
target_->recv(p);
return;
}
How can I solve this? Please, I really need a soluzione for this!
If I use the wireless scenario they provided me, all works fine.
Regards,
Paolo Carpo