Radio range of a wireless node in ns-3

4,809 views
Skip to first unread message

Megha

unread,
Nov 6, 2011, 6:19:40 PM11/6/11
to ns-3-users
Hi, I am new to ns-3. And I am trying to figure out some of the
concepts in ns-3.

My first question is how to define radio range of a wireless node in
ns-3?

And my second question is when some node Y comes into the radio range
of node X, how X will determine if Y is in it's range?

It would really help me if someone could provide me some insight to
above questions.

Thanks,
Megha

Konstantinos

unread,
Nov 7, 2011, 11:31:05 AM11/7/11
to ns-3-...@googlegroups.com
Dear Megha,

Transmission range depends on the PHY configuration and mostly on the propagation model that you use. Have a look at examples/wifi/wifi-simple-adhoc.cc to see how you can configure your wifi for certain parameters of PHY.

One simple model is the Friis model <http://en.wikipedia.org/wiki/Friis_transmission_equation>. In ns-3 you can configure several of these parameters. So for example you can keep the default values of Tx power, gains and noise and change the receiver sensitivity in order to select different communication ranges.
You can use a simpler model <http://www.nsnam.org/doxygen-release/classns3_1_1_range_propagation_loss_model.html> in which you can set exactly the range without having to calculate anything.

For the second part of your question, this has to do with the routing protocol that you use. For ad-hoc simulations there are currently 3 protocols (OLSR, AODV and DSDV) implemented in ns-3. There are mechanisms within these protocols to dynamically updated the routing tables or with other methods (route requests in AODV) to let nodes know about others with in their communication range.

In order a node to be within the communication range of another, the received signal strength (or SNIR) has to be above certain threshold. If that is achieved, then the two nodes can communicate.

I hope that I answered your questions.

Regards,

Konstantinos

Megha

unread,
Nov 7, 2011, 11:24:49 PM11/7/11
to ns-3-users
Thanks Konstantinos. Your explanation helped.

On Nov 7, 10:31 am, Konstantinos <dinos.katsa...@gmail.com> wrote:
> Dear Megha,
>
> Transmission range depends on the PHY configuration and mostly on the
> propagation model that you use. Have a look at
> examples/wifi/wifi-simple-adhoc.cc to see how you can configure your wifi
> for certain parameters of PHY.
>
> One simple model is the Friis model
> <http://en.wikipedia.org/wiki/Friis_transmission_equation>. In ns-3 you can
> configure several of these parameters. So for example you can keep the
> default values of Tx power, gains and noise and change the receiver
> sensitivity in order to select different communication ranges.
> You can use a simpler model
> <http://www.nsnam.org/doxygen-release/classns3_1_1_range_propagation_l...>

Megha

unread,
Nov 7, 2011, 11:56:49 PM11/7/11
to ns-3-users
Hi, Actually I have one more question.

In case of flooding, say a node X copies all it's data packets that it
wish to transmit to it's surrounding nodes. And those surrounding
nodes will copy their data packets and X's data packets to their
surrounding nodes. This process will continue until the data packets
reach their destinations.

In this case I don't think I need any routing protocol since I am just
flooding the network. In this case how a node X will determine it's
neighbors?

All the nodes are mobile and wireless in this scenario.


Please let me know your thoughts.

Thanks,
Megha

On Nov 7, 10:31 am, Konstantinos <dinos.katsa...@gmail.com> wrote:
> Dear Megha,
>
> Transmission range depends on the PHY configuration and mostly on the
> propagation model that you use. Have a look at
> examples/wifi/wifi-simple-adhoc.cc to see how you can configure your wifi
> for certain parameters of PHY.
>
> One simple model is the Friis model
> <http://en.wikipedia.org/wiki/Friis_transmission_equation>. In ns-3 you can
> configure several of these parameters. So for example you can keep the
> default values of Tx power, gains and noise and change the receiver
> sensitivity in order to select different communication ranges.
> You can use a simpler model
> <http://www.nsnam.org/doxygen-release/classns3_1_1_range_propagation_l...>

Konstantinos

unread,
Nov 8, 2011, 6:19:40 AM11/8/11
to ns-3-...@googlegroups.com
Again what you explained is a "broadcast/flooding" algorithm. As far as I know there is no such implementation for ns-3.

When the node broadcasts something, any node that is within the communication range, will receive it (basically it will receive it if the SNIR value is over a certain threshold) just as I explained before.

You have to have a look at OLSR or AODV implementations. Routing protocols implementations in ns-3 have two basic methods, the RouteInput and RouteOutput. The first acts upon the reception of a message and the second when it wants to send it. You have to modify them to do what you want. In very high level description, if the destination address of your packet is not "you" (the node that checks it) then it broadcasts it. If you are the destination, then you forward it to upper layers.

In broadcast/flooding protocols you do NOT know your neighbors. There is not "need" to do that, since you are always broadcasting the message to everyone.

Regards,

Kontantinos

Megha

unread,
Nov 10, 2011, 11:25:01 AM11/10/11
to ns-3-users
Thanks Kontantinos. Your answers have been really helpful. I have few
more doubts.

First : If I write anything to socket of a node using below code. Will
RouteOutput() be automatically invoked while socket->Send is being
called?
***************************************************************************************
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
Ptr<Socket> source = Socket::CreateSocket (m_NodeContainer.Get
(sourceNode), tid);
InetSocketAddress remote = InetSocketAddress (Ipv4Address
("255.255.255.255"), 80);
source->SetAllowBroadcast (true);
source->Connect (remote);
socket->Send (packet); //where packet is some packet
***************************************************************************************

Second: If I create all the nodes in my simulation to act as receive
sinks. Then as soon as the source node above broadcasts a packet, all
the nodes will receive it (Assume all nodes are in the radio range of
source node). And does that mean RouteInput() will be automatically
invoked for each node upon reception of packet?
***************************************************************************************
for(int i = 0; i < numberOfNodes; i++)
{
Ptr<Socket> recvSink = Socket::CreateSocket (m_NodeContainer.Get (i),
tid);
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (),
80);
recvSink->Bind (local);
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket, this));
}
***************************************************************************************
Please let me know.

Thanks,
Megha

Konstantinos

unread,
Nov 10, 2011, 1:08:27 PM11/10/11
to ns-3-...@googlegroups.com
I can't help you with your questions at the moment. I'm not so advanced in the ns-3 development.

Have a look at the Routing Overview <http://www.nsnam.org/docs/release/3.10/manual/html/routing.html> from the ns-3 manual and the path of a packet in ns-3 stack <http://www.nsnam.org/docs/release/3.11/models/html/internet-stack.html#example-path-of-a-packet>

Lalith Suresh

unread,
Nov 13, 2011, 5:06:18 PM11/13/11
to ns-3-...@googlegroups.com
On Thu, Nov 10, 2011 at 5:25 PM, Megha <er.m...@gmail.com> wrote:
Thanks Kontantinos. Your answers have been really helpful. I have few
more doubts.

First : If I write anything to socket of a node using below code. Will
RouteOutput() be automatically invoked while socket->Send is being
called?
***************************************************************************************
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
Ptr<Socket> source = Socket::CreateSocket (m_NodeContainer.Get
(sourceNode), tid);
InetSocketAddress remote = InetSocketAddress (Ipv4Address
("255.255.255.255"), 80);
source->SetAllowBroadcast (true);
source->Connect (remote);
socket->Send (packet);  //where packet is some packet
***************************************************************************************


RouteOutput() is not invoked if the destination is a broadcast address. Try doing "grep RouteOutput" inside src/internet/model.
 
Second: If I create all the nodes in my simulation to act as receive
sinks. Then as soon as the source node above broadcasts a packet, all
the nodes will receive it (Assume all nodes are in the radio range of
source node). And does that mean RouteInput() will be automatically
invoked for each node upon reception of packet?
***************************************************************************************
for(int i = 0; i < numberOfNodes; i++)
{
       Ptr<Socket> recvSink = Socket::CreateSocket (m_NodeContainer.Get (i),
tid);
       InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (),
80);
        recvSink->Bind (local);
       recvSink->SetRecvCallback (MakeCallback (&ReceivePacket, this));
}
***************************************************************************************

Yes. RouteInput() is invoked on all packets that make it upto layer 3 (at Ipv4L3Protocol::Receive()). It is RouteInput() that invokes the appropriate callbacks to forward further up the stack.
 
Please let me know.

Thanks,
Megha

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.




--
Lalith Suresh

Megha

unread,
Nov 15, 2011, 11:16:23 AM11/15/11
to ns-3-users
Thanks Lalith for the explanation. I have one more doubt.

Consider there are 2 nodes in the simulation which are in the radio
range of one another.
At t=0, first node sends a packet to second node. Since destination
address is second node, in this case RouteOutput() will be invoked (I
have created a new protocol ‘Test’ in the src folder). Since my second
node is in the range of first node, how RouteOutput() will forward the
packet to destination? In my logs I am able to see that RouteOutput()
is invoked, and I am not doing anything in RouteOutput() as I don’t
need to route since destination is in my radio range. But packet is
not reaching the destination and neither RouteInput() is being called.



On Nov 13, 4:06 pm, Lalith Suresh <suresh.lal...@gmail.com> wrote:
> On Thu, Nov 10, 2011 at 5:25 PM, Megha <er.me...@gmail.com> wrote:
> > Thanks Kontantinos. Your answers have been really helpful. I have few
> > more doubts.
>
> > First : If I write anything to socket of a node using below code. Will
> > RouteOutput() be automatically invoked while socket->Send is being
> > called?
>
> > ***************************************************************************­************
> > TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
> > Ptr<Socket> source = Socket::CreateSocket (m_NodeContainer.Get
> > (sourceNode), tid);
> > InetSocketAddress remote = InetSocketAddress (Ipv4Address
> > ("255.255.255.255"), 80);
> > source->SetAllowBroadcast (true);
> > source->Connect (remote);
> > socket->Send (packet);  //where packet is some packet
>
> > ***************************************************************************­************
>
> RouteOutput() is not invoked if the destination is a broadcast address. Try
> doing "grep RouteOutput" inside src/internet/model.
>
>
>
>
>
> > Second: If I create all the nodes in my simulation to act as receive
> > sinks. Then as soon as the source node above broadcasts a packet, all
> > the nodes will receive it (Assume all nodes are in the radio range of
> > source node). And does that mean RouteInput() will be automatically
> > invoked for each node upon reception of packet?
>
> > ***************************************************************************­************
> > for(int i = 0; i < numberOfNodes; i++)
> > {
> >        Ptr<Socket> recvSink = Socket::CreateSocket (m_NodeContainer.Get
> > (i),
> > tid);
> >        InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (),
> > 80);
> >         recvSink->Bind (local);
> >        recvSink->SetRecvCallback (MakeCallback (&ReceivePacket, this));
> > }
>
> > ***************************************************************************­************
>
> Yes. RouteInput() is invoked on all packets that make it upto layer 3 (at
> Ipv4L3Protocol::Receive()). It is RouteInput() that invokes the appropriate
> callbacks to forward further up the stack.
>
> > Please let me know.
>
> > Thanks,
> > Megha
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ns-3-users" group.
> > To post to this group, send email to ns-3-...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > ns-3-users+...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/ns-3-users?hl=en.
>
> --
> Lalith Sureshwww.lalith.in- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Konstantinos

unread,
Nov 15, 2011, 11:35:57 AM11/15/11
to ns-3-...@googlegroups.com

Assume for your example node A sends and node B receives.
The RouteOutput() of A should create a route towards the NetDevice interface of A for node B. Meaning that RouteOutput, hence your protocol, should know, that since B is in your range then you have to send the packet to WifiDevice interface #0.

Have a look at OLSR to see how that's implemented --> create a route

Konstantinos 

Lalith Suresh

unread,
Nov 15, 2011, 1:21:38 PM11/15/11
to ns-3-...@googlegroups.com
On Tue, Nov 15, 2011 at 5:16 PM, Megha <er.m...@gmail.com> wrote:
Thanks Lalith for the explanation. I have one more doubt.

Consider there are 2 nodes in the simulation which are in the radio
range of one another.
At t=0, first node sends a packet to second node. Since destination
address is second node, in this case RouteOutput() will be invoked (I
have created a new protocol ‘Test’ in the src folder). Since my second
node is in the range of first node, how RouteOutput() will forward the
packet to destination? In my logs I am able to see that RouteOutput()
is invoked, and I am not doing anything in RouteOutput() as I don’t
need to route since destination is in my radio range. But packet is
not reaching the destination and neither RouteInput() is being called.



If you send it at t=0, you're not giving OLSR enough time to converge. Furthermore RouteOutput() does not do any forwarding by itself, but looks up the routing table (which is divided between m_routingTable and m_hnaRoutingTable in the OLSR code), and returns a route to the caller if it exists.

Give OLSR some time to converge say, 20 seconds (for your 2 node scenario, even 5 seconds will do theoretically), and your packets should get across.



--
Lalith Suresh

Megha

unread,
Nov 15, 2011, 2:01:16 PM11/15/11
to ns-3-users
I am not using OLSR. I have created a new protocol 'test' in the src
folder. I am trying to figure out how RouteOutput forwards packet to
the lower layers when both the nodes: source and destination are in
the radio range of each other.

As per Konstantinos reply, looks like I have to send the packet to
WifiDevice interface #0 of my source node.

One of the arguments of RouteOutput() is Ptr<NetDevice> oif. But I am
not sure how can I use it to send the packet down to lower layers.

I am trying to do something like below which is not working (getting
'terminated with signal SIGSEGV error) as I am not sure how to get
protocol number as per below method definition. Also second parameter
is mac address but I am specifying ip address of the destination. Any
thoughts?

oif->Send(p,header.GetDestination(),0);

virtual bool ns3::NetDevice::Send ( Ptr< Packet > packet,
const Address & dest,
uint16_t protocolNumber
)






On Nov 15, 12:21 pm, Lalith Suresh <suresh.lal...@gmail.com> wrote:
> > > Lalith Sureshwww.lalith.in-Hide quoted text -

Konstantinos

unread,
Nov 15, 2011, 3:46:43 PM11/15/11
to ns-3-...@googlegroups.com
Dear Megha,

If you see the declaration of RoutOutput() in OLSR the oif is passed there. So, when RouteOutput() is called from UdpSocketImpl() it passed the interface. You don't need to do oif->Send()...

Ptr<Ipv4Route> RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr)

---

Konstantinos

Lalith Suresh

unread,
Nov 15, 2011, 5:04:15 PM11/15/11
to ns-3-...@googlegroups.com
On Tue, Nov 15, 2011 at 8:01 PM, Megha <er.m...@gmail.com> wrote:
I am not using OLSR. I have created a new protocol 'test' in the src
folder. I am trying to figure out how RouteOutput forwards packet to
the lower layers when both the nodes: source and destination are in
the radio range of each other.


Sorry for the OLSR confusion. It's been a really long day and I'm tired.

The point is, RouteOutput() *does not forward packets*. Do a grep for "RouteOutput()" inside src/internet/model and you'll see what happens. When the packet reaches the TCP/UDP code, a check is made to see if a valid route exists from the source to the requested destination address. RouteOutput() simply tells the caller (in this case, the TCP/UDP code) whether or not a route exists, and if it does, provides it the route as well. This "route" information is then later used to set the source address on the packet.

See this figure from our manual to understand the path that a packet takes through the ns-3 stack: http://www.nsnam.org/docs/release/manual/html/internet-stack.html#example-path-of-a-packet

 
As per Konstantinos reply, looks like I have to send the packet to
WifiDevice interface #0 of my source node.

One of the arguments of RouteOutput() is Ptr<NetDevice> oif. But I am
not sure how can I use it to send the packet down to lower layers.


The link I gave should clarify your doubts on how the packets go through the all the layers. Bear in mind that these are internal details, and if you're only concerned with sending a packet from A to B, then all you need to worry about or ensure is (w.r.t your use case):

a) The sender is attempting to send the packet to the right destination IP/Port combination.
b) The sender has a valid route to the destination.
c) The nodes are within radio range.



--
Lalith Suresh

Megha

unread,
Nov 16, 2011, 11:51:59 PM11/16/11
to ns-3-users
Ok, here is what I am trying to do and I am stuck at one point.
Consider a situation where there are 5 nodes in radio range of each
other.

I am trying to send packet from node 0 to node 2. See below
applications that I have installed on node 0 and node 2. Node 0 is
acting a a source which sends a packet to node 2 which is acting as a
receive sink.

Ptr<Socket> source = Socket::CreateSocket (m_NodeContainer.Get (0),
tid);
InetSocketAddress remote = InetSocketAddress (Ipv4Address
("10.1.1.3"), 80); // node 2 has ip address 10.1.13
source->Connect (remote);
source->Send(packet);

Ptr<Socket> recvSink= Socket::CreateSocket (m_NodeContainer.Get (2),
tid);
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (),
80);
recvSink->Bind (local);
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));


I have created a new flooding based protocol called epidemic in src
folder. So once source above sends a packet RouteOutput() is invoked.
Here I am invoking SendFlood method which instead of sending packet to
destination broadcasts the packet. In NotifyInterfaceUp I am setting
each node to act as Receive sink. See below. The packet which is
broadcasted is received by all the nodes including node 2 and except
node-0 which has broadcasted the packet. In SendFlood method before
broadcasting the packet I am adding a epidemic header to store the
actual destination ip address. And I am using EPIDEMIC_PORT for
broadcasting. After packet is broadcasted it will be received by all
nodes, so RouteInput() is invoked for each node. In RouteInput()
method I am accepting the packet by calling lcb() which in turns is
sending packet to RecvEpidemic method. See below. So in this method I
know that packet has reached the destination. But how should I forward
it to upper layers? See below methods.

Ptr<Ipv4Route> RoutingProtocol::RouteOutput (Ptr<Packet> p,
                              const Ipv4Header &header,
                              Ptr<NetDevice> oif,
                              Socket::SocketErrno &sockerr)
{
  Ptr<Ipv4Route> route;
  Simulator::Schedule (Seconds (0.0),&RoutingProtocol::SendFlood,this,
p, header);
  return route;
}

Void RoutingProtocol::SendFlood (Ptr<Packet> packet, Ipv4Header
header)
{
   for (std::map<Ptr<Socket>, Ipv4InterfaceAddress>::const_iterator j
= m_socketAddresses.begin (); j
        != m_socketAddresses.end (); ++j)
     {
       Ptr<Socket> socket = j->first;
       EpidemicHeader epidemicHeader;
       epidemicHeader.SetDst(header.GetDestination ());
       packet->AddHeader(epidemicHeader);
       Ipv4Address destination = Ipv4Address ("255.255.255.255");
       socket->SendTo (packet, 0, InetSocketAddress (destination,
EPIDEMIC_PORT));
    }
}


void
RoutingProtocol::NotifyInterfaceUp (uint32_t i)
{
   NS_LOG_FUNCTION (this << m_ipv4->GetAddress (i, 0).GetLocal ()
                         << " interface is up");
   Ptr<Ipv4L3Protocol> l3 = m_ipv4->GetObject<Ipv4L3Protocol> ();
   Ipv4InterfaceAddress iface = l3->GetAddress (i,0);
   if (iface.GetLocal () == Ipv4Address ("127.0.0.1"))
     {
       return;
     }
   if (m_mainAddress == Ipv4Address ())
     {
       m_mainAddress = iface.GetLocal ();
     }
   NS_ASSERT (m_mainAddress != Ipv4Address ());

     // Create a socket to listen only on this interface
     Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node>
(),UdpSocketFactory::GetTypeId ());
     NS_ASSERT (socket != 0);
     socket->SetRecvCallback (MakeCallback
(&RoutingProtocol::RecvEpidemic,this));
     socket->BindToNetDevice (l3->GetNetDevice (i));
     socket->Bind (InetSocketAddress (Ipv4Address::GetAny (),
EPIDEMIC_PORT));
     socket->SetAllowBroadcast (true);
     socket->SetAttribute ("IpTtl",UintegerValue (1));
  m_socketAddresses.insert (std::make_pair (socket,iface));
}


Bool RoutingProtocol::RouteInput (Ptr<const Packet> p,
                             const Ipv4Header &header,
                             Ptr<const NetDevice> idev,
                             UnicastForwardCallback ucb,
                             MulticastForwardCallback mcb,
                             LocalDeliverCallback lcb,
                             ErrorCallback ecb)
{
  int32_t iif = m_ipv4->GetInterfaceForDevice (idev);
  lcb (p, header, iif);
  return true;
}




void

RoutingProtocol::RecvEpidemic (Ptr<Socket> socket)

{

EpidemicHeader epidemicHeader;

packet->PeekHeader(epidemicHeader);


if(epidemicHeader.GetDst() == m_mainAddress)

{

cout <<"Packet after removing epidemic header should be sent to
upper layers here as it has reached the destination BUT HOW??\n";

}

}


Any help on this will be appreciated.

Thanks,
Megha

Lalith Suresh

unread,
Nov 17, 2011, 5:27:28 AM11/17/11
to ns-3-...@googlegroups.com
Since the destination port for the packet is EPIDEMIC_PORT, you're receiving the packet at RecvEpidemic(), which is the correct RecvCallback.

One thing you can do is, correct the destination port of the packet to the actual port of the higher layer application or intended recipient of the packet, and send this corrected packet to the loopback device. This packet will then reach Ipv4L3Protocol::Receive(), and go through the same procedure, but the lcb() from RouteInput() (Ipv4L3Protocol::LocalDeliver()) will match the packet against the higher layer application that is listening on the updated destination port.

Question: why not do the "if(epidemicHeader.GetDst() == m_mainAddress)" check within RouteInput(), correct the destination port, and invoke lcb() from there directly without getting the packet to RecvEpidemic()?

 

Thanks,
Megha

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.




--
Lalith Suresh

Megha

unread,
Nov 17, 2011, 9:37:12 AM11/17/11
to ns-3-users
> Question: why not do the "if(epidemicHeader.GetDst() == m_mainAddress)"
> check within RouteInput(), correct the destination port, and invoke lcb()
> from there directly without getting the packet to RecvEpidemic()?


epidemicHeader.GetDst()shows garbage value if I try to get the value
at RouteInput(). May be it's not the correct layer where I can read
epidemicHeader. I can only read epidemicHeader correctly when the
callback RecvEpidemic is invoked. Any thoughts on this?



On Nov 17, 4:27 am, Lalith Suresh <suresh.lal...@gmail.com> wrote:

Lalith Suresh

unread,
Nov 17, 2011, 10:11:24 AM11/17/11
to ns-3-...@googlegroups.com
On Thu, Nov 17, 2011 at 3:37 PM, Megha <er.m...@gmail.com> wrote:
> Question: why not do the "if(epidemicHeader.GetDst() == m_mainAddress)"
> check within RouteInput(), correct the destination port, and invoke lcb()
> from there directly without getting the packet to RecvEpidemic()?


epidemicHeader.GetDst()shows garbage value if I try to get the value
at RouteInput(). May be it's not the correct layer where I can read
epidemicHeader. I can only read epidemicHeader correctly when the
callback RecvEpidemic is invoked. Any thoughts on this?


Because at RouteInput(), the transport headers are still on the packet. When you invoke Packet::RemoveHeader(blah), it deserialises as many bytes as needed from the outermost part of the packet to populate a header of type "blah".



--
Lalith Suresh

Megha

unread,
Nov 17, 2011, 10:36:35 AM11/17/11
to ns-3-users
So as per your question I can't do "if(epidemicHeader.GetDst() ==
m_mainAddress)"
check within RouteInput() as destination's ip address is not available
at that point of time. Anything else I can do to forward packet up the
higher layers?

On Nov 17, 9:11 am, Lalith Suresh <suresh.lal...@gmail.com> wrote:
> > > Lalith Sureshwww.lalith.in-Hide quoted text -

Megha

unread,
Nov 22, 2011, 11:26:48 AM11/22/11
to ns-3-users
Hi Lalith, Here you suggested to correct the destination port. Can you
please guide me how I can correct the destination port in RouteInput()
method? I tried looking at doxygen and user group but didn't find
anything on how port can be updated.

And also since RouteInput() is invoked at network layer, is port
information accessible at this layer?

Thanks,
Megha

On Nov 17, 4:27 am, Lalith Suresh <suresh.lal...@gmail.com> wrote:

Lalith Suresh

unread,
Nov 24, 2011, 4:25:46 AM11/24/11
to ns-3-...@googlegroups.com
Hi,

On Tue, Nov 22, 2011 at 5:26 PM, Megha <er.m...@gmail.com> wrote:
Hi Lalith, Here you suggested to correct the destination port. Can you
please guide me how I can correct the destination port in RouteInput()
method? I tried looking at doxygen and user group but didn't find
anything on how port can be updated.

And also since RouteInput() is invoked at network layer, is port
information accessible at this layer?


Well, if you know the exact order of headers that appear in the packet, then this is possible. I guess this is possible because of your custom protocol. Assuming you have an IP and UDP headers on the packet, just do something like:

Ptr<Packet> p = packet->Copy(); // Make a copy of the packet
Ipv4Header iph;
UdpHeader udph;
p->RemoveHeader (iph);
p->RemoveHeader (udph);

... and now you can look into any information that's available in the UDP header of the packet.

In essence, you need to strip out headers one after the other to look into the inner headers. And this can be done at any point in the stack. Be warned that if you get the header types wrong, you'll have a not-so-pleasant time trying to figure out what went wrong. :)



--
Lalith Suresh

Megha

unread,
Jan 3, 2012, 9:46:26 AM1/3/12
to ns-3-users
Hi, Just wanted to thank you both for your assiatance on the project I
was working on. I was able to complete my project on time. :-)

Happy New Year!!
Megha


On Nov 24 2011, 3:25 am, Lalith Suresh <suresh.lal...@gmail.com>
wrote:
> Hi,
> > > Lalith Sureshwww.lalith.in-Hide quoted text -

Madhumita Rautela

unread,
Jun 3, 2014, 5:36:31 AM6/3/14
to ns-3-...@googlegroups.com
Dear Konstantinos,

How to set Rx sensitivity of a wireless node? I have to implement long range links in a small world wireless mesh network. I am using Friis Propagation Loss Model.

Regards,
Madhumita.

peyman saleh

unread,
Apr 5, 2016, 3:13:51 AM4/5/16
to ns-3-users
hi, I want to have wifi-adhoc nodes with different range of wifi but in my simulation only nodes with same YansWifiPhyHelper cant get each other broadcast, I'll be really appreciate if you look at my code.

I just set MaxRange for second group and wifiPhy.SetChannel(wifiChannel.Create()); again.

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();

WifiHelper wifi = WifiHelper::Default();

NqosWifiMacHelper mac = NqosWifiMacHelper::Default();

wifi.SetRemoteStationManager("ns3::AarfWifiManager");

wifiPhy.SetPcapDataLinkType(YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
wifiChannel.AddPropagationLoss("ns3::RangePropagationLossModel", "MaxRange",
DoubleValue(100.0));
wifiPhy.SetChannel(wifiChannel.Create());
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default();
wifi.SetStandard(WIFI_PHY_STANDARD_80211b);
wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode",
StringValue(phyMode), "ControlMode", StringValue(phyMode));
wifi2.SetStandard(WIFI_PHY_STANDARD_80211b);
wifi2.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode",
StringValue(phyMode), "ControlMode", StringValue(phyMode));


// Set it to adhoc mode
wifiMac.SetType("ns3::AdhocWifiMac");
NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, c);
MobilityHelper mobility;
mobility.SetPositionAllocator("ns3::GridPositionAllocator", "MinX",
DoubleValue(10.0), "MinY", DoubleValue(10.0), "DeltaX",
DoubleValue(distance), "DeltaY", DoubleValue(distance), "GridWidth",
UintegerValue(5), "LayoutType", StringValue("RowFirst"));
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
mobility.Install(c);



NqosWifiMacHelper wifiMac2 = NqosWifiMacHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
NetDeviceContainer devices2 = wifi2.Install(wifiPhy, wifiMac2, q);
mobility.SetPositionAllocator("ns3::GridPositionAllocator", "MinX",
DoubleValue(20.0), "MinY", DoubleValue(20.0), "DeltaX",
DoubleValue(distance), "DeltaY", DoubleValue(distance), "GridWidth",
UintegerValue(15), "LayoutType", StringValue("RowFirst"));
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
mobility.Install(q);

NetDeviceContainer devices3  (devices , devices2);

 Ipv4StaticRoutingHelper staticRouting;


Ipv4ListRoutingHelper list;

list.Add(staticRouting, 0);


InternetStackHelper internet;

internet.SetRoutingHelper(list); // has effect on the next Install()

internet.Install(c);

internet.Install(q);


Ipv4AddressHelper ipv4;

NS_LOG_INFO("Assign IP Addresses.");

ipv4.SetBase("10.1.1.0", "255.255.255.0");

Ipv4InterfaceContainer i = ipv4.Assign(devices3);

Konstantinos

unread,
Apr 5, 2016, 3:38:50 AM4/5/16
to ns-3-users
Dear Payman,

You are creating TWO wifi channel objects, that's why nodes in the two groups can not communicate.
Simply create a single channel and use it in both helpers, i.e. do not call again wifiPhy.SetChannel(wifiChannel.Create()); for the second group.

peyman saleh

unread,
Apr 5, 2016, 5:02:41 AM4/5/16
to ns-3-users
thanks for your response, I Create wifiChannel again because  I want to change MaxRange for another nodes, and if I don't create it again it apply previous range that I declared before, I don't know how to change range for new group of nodes and it's my problem.

peyman saleh

unread,
Apr 5, 2016, 5:07:57 AM4/5/16
to ns-3-users
actually I forgot  to copy these lines;

///////these lines//

wifiChannel.AddPropagationLoss("ns3::RangePropagationLossModel", "MaxRange",
DoubleValue(1000.0));
/////////////////////////////
NqosWifiMacHelper wifiMac2 = NqosWifiMacHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
NetDeviceContainer devices2 = wifi2.Install(wifiPhy, wifiMac2, q);
mobility.SetPositionAllocator("ns3::GridPositionAllocator", "MinX",
DoubleValue(20.0), "MinY", DoubleValue(20.0), "DeltaX",
DoubleValue(distance), "DeltaY", DoubleValue(distance), "GridWidth",
UintegerValue(15), "LayoutType", StringValue("RowFirst"));
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
mobility.Install(q);

NetDeviceContainer devices3  (devices , devices2);


Konstantinos

unread,
Apr 5, 2016, 5:43:34 AM4/5/16
to ns-3-users
My reply stands the same. By creating TWO channel objects the nodes can not communicate. 
You need to create a single channel. 

Then you could change the attribute for the installed channel on particular nodes.
For example, install the 100m range model on ALL nodes, and then, iterate on the nodes you want to have 
1000m and change the propagation model using the attribute system (https://www.nsnam.org/docs/manual/html/attributes.html)

Tommaso Pecorella

unread,
Apr 5, 2016, 5:58:05 AM4/5/16
to ns-3-users
I beg your pardon, but I think that this user should read a book about wireless networks before simulating anything.
Changing the propagation model to change the transmission range is the most wrong thing in history, just next to the flat earth theories.
The radio range depends on the transmitter and receiver antennas and radiated power. The propagation model is something that depends on the surrounding environment, and it's the same for all the nodes in similar conditions. It is allowed to change it only in particular cases, e.g., some nodes are indoor and some outdoor.

This said, how you draw your (wrong) results it's none of my business.

T.
Message has been deleted

peyman saleh

unread,
Apr 6, 2016, 5:01:08 AM4/6/16
to ns-3-users
sorry to bug you again about this 
I did what you said 

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();

WifiHelper wifi = WifiHelper::Default();

NqosWifiMacHelper mac = NqosWifiMacHelper::Default();

wifi.SetRemoteStationManager("ns3::AarfWifiManager");

wifiPhy.SetPcapDataLinkType(YansWifiPhyHelper::DLT_IEEE802_11_RADIO);

YansWifiChannelHelper wifiChannel;

wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");

wifiChannel.AddPropagationLoss("ns3::RangePropagationLossModel", "MaxRange",

DoubleValue(100.0));

wifiPhy.SetChannel(wifiChannel.Create());

NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default();

wifi.SetStandard(WIFI_PHY_STANDARD_80211b);

wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode",

StringValue(phyMode), "ControlMode", StringValue(phyMode));

wifiMac.SetType("ns3::AdhocWifiMac");

NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, c);

NetDeviceContainer devices2 = wifi.Install(wifiPhy, wifiMac, q);


I read the link that you mentioned but I couldn't find out how to change node's wifi range, if it's possible for you just give me one example of how to do it.

thank you.
Reply all
Reply to author
Forward
0 new messages