When you want to broadcast packet, the ttl must be equal to 1.
ih->ttl()= 1;
best regards
> Subject: Re: [ns] Multihop Broacasting in ns2
> To: adel belkhiri <adel.belkh...@hotmail.com>,
> ns-users@ISI.EDU
> Message-ID:
>     <ae4085060910182048u52e0cb83y4ed8b03a7c4c5...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Hi,
> 
> I am trying to send broadcast packets from a node to its
> neighbors.. Using
> similar code as in below mail. But, after below statement,
> c++ code is
> throwing "Segmentation fault (core dumped)" error.
> 
>  Scheduler::instance().schedule(target_, p, 0);
> 
> I am not able to atleast send broadcast packets to
> neighbors. Please help me
> understand the issue. did anyone have this issue?
> 
> I commented above schedulercode and tried direct send()
> function..like
> "send(p,0);". This also gives same segmentation fault.
> 
> I am attaching my tcl, .h & .cc files. I am new nsuser.
> using ns2.34 with
> cygwin in XP.
> 
> Thanks for help in advance.
> 
> On Thu, Oct 15, 2009 at 5:19 PM, adel belkhiri 
> <adel.belkh...@hotmail.com>wrote:
> 
> >
> >
> >
> >
> >
> > Hi my dears,
> >
> > I'm writing an agent that broadcast a packet to all
> the neighbor nodes in
> > the MANET network. I have search for a long time in
> the net to do that with
> > ns2 but I fail. In fact, the problem is that only
> neighbors in the range of
> > one hop  from the sender node can receive the
> packet!! The solution proposed
> > for the broadcast problem by Jeff Bolen didn't resolve
> the problem (
> > http://www.isi.edu/nsnam/archive/ns-users/webarch/2000/msg02832.html
> ). In
> > his proposition Jeff says that we should make a
> duplicate the packet and
> > send copy with the original packet up but I didn't
> know how to do it :( ...
> > I absolutely agree with Sanjay Raghani in its post (
> > http://www.mail-archive.com/ns-users@isi.edu/msg02771.html
> ) when he says
> > that the solution of Jeff is not the correct one for
> many reasons but till
> > now I don't have any idea how to proceed to solve my
> problem :(
> >
> >  My C++ function which I use to broadcast the
> packet is below :
> >
> > void DistacAgent::broadcast_packet( )
> > {
> >
> >  Packet *p = allocpkt();
> >  if(p==NULL){
> >      abort();
> >    }
> >
> >  hdr_cmn *ch = HDR_CMN(p);
> >  hdr_ip *ih = HDR_IP(p);
> >
> >  //filling the Common header
> >  ch->ptype() = PT_DISTAC; // My agent packet
> type !!
> >  ch->size() = IP_HDR_LEN +
> sizeof(hdr_distac);
> >  ch->iface() = -2;
> >  ch->error() = 0;
> >  ch->addr_type() = NS_AF_NONE;
> >  ch->prev_hop_ = Agent::addr();
> >  ch->next_hop() = IP_BROADCAST;
> >  ch->direction() = hdr_cmn::DOWN ;
> >
> >  //filling the IP header
> >  ih->saddr() = Agent::addr();
> >  ih->daddr() =  IP_BROADCAST;
> >
> >  ih->sport() = DISTAC_PORT;
> >  ih->dport() = DISTAC_PORT;
> >
> >  ih->ttl_ = 32;
> >
> > // and finally sending the packet by putting it on the
> scheduler
> >  Scheduler::instance().schedule(target_, p, 0);
> >
> > }
> >
> > Please if you have any idea don't hesitate to send to
> me and thanks in
> > advance !!
> >
> > Adel.
_________________________________________________________________


      


Reply via email to