[ns] Help: How to implement flooding for wired nodes (IP_BROADCAST usage)?
dongyu liu
hometa at gmail.com
Tue Jan 31 18:59:53 PST 2006
Hi,NS2 users:
I am going to implement a flooding (broadcast) algorithm for wired nodes in
ns2 for a long time. But I still haven't found a solution for that.
I found that most work are focused on wireless network ( I can find a lot of
flooding method (by using IP_BROADCAST) for mobile nodes because wireless
nodes have link layer and mac layer. We can modify the ll.cc according to
this post:
http://mailman.isi.edu/pipermail/ns-users/2000-June/009635.html.)
I think that method only apply to mobile nodes and it is not suitable
for wired nodes and we can't find the
ll.cc to modify.
I emailed the author of above post about this and he replied:
" your statement that a wired node doesn't have a link layer may
not be totally correct. It may not use ll.cc, or may use it differently,
but I'm pretty sure there is a way to emulate different link layers with
wired nodes. I know that with modern day networks, link layers are very
reliable, however, I'm sure NS can include a link layer on a wired node.
The trick is finding out how. Unfortunately I haven't done any wired node
simulations with NS."
Until now I can't find out how to modify the link layer of wired node.
To my understanding there is no Link layer for wired node. Am I right?
In summary I just want to know how to flood(broadcast) the packet to
every nodes.
My broadcast code will just look like this:
************************************
Packet* pkt = allocpkt();
struct hdr_cmn* ch = (hdr_cmn*)hdr_cmn::access(pkt);
hdr_ip* ih = (hdr_ip*)hdr_ip::access(pkt);
hdr_dflood* eh = (hdr_dflood*)hdr_dflood::access(pkt);
ch->ptype() = PT_DFLOOD;
// ch->iface() = -2;
ch->direction() = hdr_cmn::DOWN;
ch->size() = IP_HDR_LEN + eh->pkt_len_;
ch->error() = 0;
ch->next_hop() = IP_BROADCAST;
ch->addr_type() = NS_AF_INET;
ih->saddr() = ra_addr_;
ih->daddr() = IP_BROADCAST;
ih->sport() = RT_PORT;
ih->dport() = RT_PORT;
ih->ttl() =1;// IP_DEF_TTL;
send(pkt, 0);
************************************
The erros is always like this:
--- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
_o18: no target for slot -1
_o18 type: Classifier/Hash/Dest
content dump:
classifier _o18
0 offset
0 shift
2147483647 mask
1 slots
slot 2: _o110 (Classifier/Port)
-1 default
---------- Finished standard no-slot{} default handler ----------
It seems that it is impossible to make the -classifier of node to
understand IP_BROADCAST
because the returned slot number is always -1 and _classifier don't
know where to send the packet to.
Generally the slot number should be a value larger than 0.
My questions are (1)
As we know for unicast, we need to specify the destination node for
one package by connecting two nodes.
Between wired nodes, how to send a packet whose destination is IP_BROADCAST?
(2)Till now I found that only wireless agent used IP_BROADCAST, can we
really use IP_BROADCAST in wired nodes?
The only exception I found is that /apps/ping.cc file also used
IP_BROADCAST. But the "start-WL-brdcast" option didn't work.
(This post talks about this also.
http://mailman.isi.edu/pipermail/ns-users/2003-November/037731.html
)
(3)If I want to implement flooding(broadcast) for wired nodes, must I
use multicast instead of unicast?
Thank you in advance! Any suggestion is appreciated.
Best regards,
My tcl code is here for your reference:
**************************************************
#Create a simulator object
set ns [new Simulator]
#-multicast on]
#Open the nam trace file
set nf [open flood.nam w]
$ns namtrace-all $nf
#Open the trace file
set tracefd [open flood.tr w]
$ns trace-all $tracefd
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam flood.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 40ms DropTail
$ns duplex-link $n1 $n3 1Mb 30ms DropTail
$ns duplex-link $n4 $n0 1Mb 30ms DropTail
set p0 [new Agent/DFLOOD 0]
$ns attach-agent $n0 $p
set p1 [new Agent/DFLOOD 1]
$ns attach-agent $n1 $p1
set p2 [new Agent/DFLOOD 2]
$ns attach-agent $n2 $p2
set p3 [new Agent/DFLOOD 3]
$ns attach-agent $n3 $p3
set p4 [new Agent/DFLOOD 4]
$ns attach-agent $n4 $p4
$ns connect $p4 $p2
$ns at 0.2 "$p2 send"
#Call the finish procedure after 5 seconds simulation time
$ns at 10.0 "finish"
$ns run
*****************************************************************
More information about the Ns-users
mailing list