assigning ip addresses

1,361 views
Skip to first unread message

jen lo

unread,
Apr 14, 2012, 9:50:05 PM4/14/12
to ns-3-users


/ n0
// \ 5 Mb/s, 2ms
// \ 1.5Mb/s,
10ms 1.5Mb/s, 10ms
// n2
----------------------------------------------------------------------
n3-------------------------------n4
// /
\
// / 5 Mb/s,
2ms
\
//
n1
n5


I want the IP addresses of each nodes to be the following:

n0 -> 10.1.1.1
n1 -> 10.1.1.2
n2 -> 10.1.1.3
n3 -> 10.1.1.4
n4 -> 10.1.1.5
n5 -> 10.1.1.6

and I want them to be connected with the channels specified in the
figure above.

I did the following :

NodeContainer c;
c.Create (6);

NodeContainer n02 = NodeContainer (c.Get (0), c.Get (2));
NodeContainer n12 = NodeContainer (c.Get (1), c.Get (2));
NodeContainer n32 = NodeContainer (c.Get (3), c.Get (2));
NodeContainer n34 = NodeContainer (c.Get (3), c.Get (4));
NodeContainer n44 = NodeContainer (c.Get (4), c.Get (5));

PointToPointHelper p2p;
p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));

NetDeviceContainer nd02 = p2p.Install (n02);
NetDeviceContainer nd12 = p2p.Install (n12);


p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));

NetDeviceContainer nd32 = p2p.Install (n32);
NetDeviceContainer nd34 = p2p.Install (n34);
NetDeviceContainer nd34 = p2p.Install (n45);

//Now how do i add the Ip addressees so that each node has exactly
one id ?

Ipv4AddressHelper ipv4;
ipv4.SetBase ??
Ipv4InterfaceContainer ???

Please help

jen lo

unread,
Apr 15, 2012, 12:24:24 AM4/15/12
to ns-3-users
oh uh, the network look kind of messed up,

ill draw it again :


n0
// \ 5 Mb/s, 2ms
// \ 1.5Mb/s, 10ms
// n2 -------------------------n3---------n4
// / \
// / 5 Mb/s, 2ms \n5
// n1

John Abraham

unread,
Apr 15, 2012, 7:11:27 AM4/15/12
to ns-3-...@googlegroups.com
All The ip addresses belong to the same subnet?
In p2p links each pair of interfaces belonging to the same link belongs to a unique subnet.
Point point layout dumbbell may be worth looking at

--
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.

jen lo

unread,
Apr 15, 2012, 7:26:43 AM4/15/12
to ns-3-users
the reason I want to assign one unique ip for each node is because I
want to get the neighbors of each node and know if 2 nodes have the
same neighbor. I am running olsr on each node.

for example n1 and n0 have the same neighbor n2, but if n2 has 2 ip
addresses, there is no way I can compare the neighbors of n0 and
neighbors of n1 and know that they have n2 in common !

how can I have n0----n2 such that n0 knows that n1 also has the same
neighbor?
/
n1
can you advise me please?

On Apr 15, 2:11 pm, John Abraham <john.abraham...@gmail.com> wrote:
> All The ip addresses belong to the same subnet?
> In p2p links each pair of interfaces belonging to the same link belongs to
> a unique subnet.
> Point point layout dumbbell may be worth looking at
>
>
>
>
>
>
>
> On Saturday, April 14, 2012, jen lo wrote:
> > oh uh, the network look kind of messed up,
>
> > ill draw it again :
>
> > n0
> > //     \ 5 Mb/s, 2ms
> > //      \          1.5Mb/s, 10ms
> > //       n2 -------------------------n3---------n4
> > //      /                                          \
> > //     / 5 Mb/s, 2ms                                \n5
> > //   n1
>
> > To post to this group, send email to ns-3-...@googlegroups.com<javascript:;>
> > .
> > To unsubscribe from this group, send email to
> > ns-3-users+...@googlegroups.com <javascript:;>.

John Abraham

unread,
Apr 15, 2012, 7:30:33 AM4/15/12
to ns-3-...@googlegroups.com
I am not really following this:

1. With P2P links wired nodes can have only exactly one neighbor. Each pair of interfaces belong to one unique subnet
2. With CSMA Links (LAN) wired nodes can have multiple neighbors and each interface belonging to the LAN can be part of the same subnet.
> 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.

jen lo

unread,
Apr 15, 2012, 7:35:51 AM4/15/12
to ns-3-users
umm, ok. How can I create an ad hoc network where I can assign a
unique ip for each node and specify which node is connected to which
node?

John Abraham

unread,
Apr 15, 2012, 7:45:42 AM4/15/12
to ns-3-...@googlegroups.com
1. Ip addresses are assigned to node Interfaces and not to nodes. 
2. Dumbbell topology helper , helps you assign unique ip addresses to every node. Why can't you use that?

take a few moments to look at the example under netanim "dumbbell-animtation.cc".

jen lo

unread,
Apr 15, 2012, 8:01:34 AM4/15/12
to ns-3-users
ok so here is my problem:

Given an olsr network, I have written a code that accesses the
objectState m_State of each OLSR node and get the one hop and two hop
neighbor information from it.

so n0 would know its one hop information
n1 would also know its one hope information.

then I want to compare the one hop information of n0 and n1 and get a
result that YES, they do have a node in common, which is n2. ( this is
why i want n2 to have one ip.

(its part of a bigger problem I am trying to implement)

so now that you explained how p2p is used, I guess I need an AD HOC
network where I can connect nodes manually and assign one ip.

I looked at dumbell quickly, I didnt really understand what it
does...can I use it to have ad and hoc network where I can connect
nodes manually and assign one ip.?

John Abraham

unread,
Apr 15, 2012, 8:08:04 AM4/15/12
to ns-3-...@googlegroups.com
Unfortunately there is a disconnect. Not really following your topology.

1. Is this wired or wireless topology?
2. If wired do you want to use P2p or Csma?

jen lo

unread,
Apr 15, 2012, 8:09:22 AM4/15/12
to ns-3-users
wireless topology ( I was mistaken with I used p2p ), it should be ad
hoc network

John Abraham

unread,
Apr 15, 2012, 8:21:52 AM4/15/12
to ns-3-...@googlegroups.com
check out examples/routing/manet-routing-compare.cc which uses Adhoc Wifi with olsr

  NS_LOG_INFO ("assigning ip address");

  Ipv4AddressHelper addressAdhoc;
  addressAdhoc.SetBase ("10.1.1.0", "255.255.255.0");
  Ipv4InterfaceContainer adhocInterfaces;
  adhocInterfaces = addressAdhoc.Assign (adhocDevices);

Can you use this?

jen lo

unread,
Apr 15, 2012, 1:31:02 PM4/15/12
to ns-3-users
YES! that example is really helpful . thank you !!

one last question . how do I manually build my network ??

n0
// \ 5 Mb/s, 2ms
// \ 1.5Mb/s, 10ms
// n2 -------------------------n3---------n4
// / \
// / 5 Mb/s, 2ms \n5
// n1



n0 has only n2 as a neighbor ( i.e. n2 is the only node in the radio
range of n0)
n1 has only n2 as a neighbor ( i.e. n2 is the only node in the radio
range of n1)
n2 has n0, n1, n3 as neighbors ( i.e. n0,n1,n2 are the only nodes in
the radio range of n2)
n3 has only n2,n4 as neighbors ( i.e. n2,n4 are the only node in the
radio range of n3)
n4 has only n3 as a neighbor ( i.e. n3 is the only node in the radio
range of n4)

how do I manually code the above ?

John Abraham

unread,
Apr 15, 2012, 1:54:46 PM4/15/12
to ns-3-...@googlegroups.com
See AnimationInterface::SetConstantPosition code for example of how to set a fixed position.
Ns-3 uses txp (search in manet-routing-compare) dBm to determine rx power at receiving nodes.if rx power is less than a certain threshold it is dropped.in essence txp controls range but threshold is also important.

See yans-wifi-phy.cc for receiver energy threshold. I think ns-3 uses  a version of friis formula to determine rx power

I havent checked it more deeply,but post a new thread with new subject line about range,im sure others have asked themselves the same question.
Im not an expert in this area

On Sunday, April 15, 2012, jen lo wrote:
United States
Reply all
Reply to author
Forward
0 new messages