Counting number of data packets in AODV

75 views
Skip to first unread message

Shanen Leen

unread,
Jun 23, 2017, 9:38:36 AM6/23/17
to ns-3-users
Hi all,
How can I count the number of data packets received from and forwarded to each neighbor of a node within the aodv-routing-protocol.cc/.h?

I'm not talking about the AODV protocol specific packets like RREQ, RREP, RERR. I'm talking about the data packets sent after discovering the route.
(I've posted a detailed question before, but I got no answers/suggestions)
Thanks!

Konstantinos

unread,
Jun 23, 2017, 10:39:37 AM6/23/17
to ns-3-users
Hi Shanen,

You could use the previous post to 'up' the question, if it has been neglected or not answered for some time, instead of creating a new thread.
If you are within aodv-routing-protocol.cc as you mention, you have knowledge of Forwarding packets. That's the role of RouteInput method, to handle incoming packets.

Regards
K

Shanen Leen

unread,
Jun 24, 2017, 11:24:26 PM6/24/17
to ns-3-users
Thanks Konstantinos for the quick answer. I'll surely do so in future.

After proceeding furthur with your guidance, I want to know how to get the current node's interface Ipv4Address(My IP Address) within the RouteInput() method?

I'm storing the packet counts in a static data structure like below,
| MyIP | NeighbourIP | DataPacketCount |
(This data is used by a learning algorithm)

I can get the NeighbourIP through,
RoutingTableEntry toOrigin;
//Look up therouting table
Ipv4Address NeighbourIP = toOrigin.GetNextHop();

Similarly how can I get,
Ipv4Address MyIP = ???


Konstantinos

unread,
Jun 25, 2017, 5:01:06 AM6/25/17
to ns-3-users
Hi,

Note that each node may have more than one IP addresses when it has multiple interfaces.
AODV protocol provides a method called IsMyOwnAddress() that checks if a particular address is your address.

Regards,
K
Message has been deleted

Shanen Leen

unread,
Jun 25, 2017, 5:52:36 AM6/25/17
to ns-3-users
Thanks for the reply.
I've seen the IsMyOwnAddress(Ipv4Address) method previously.

I'm asking the way to get the the IPv4 address of the interface which the packet is received through?

I've tried the following inside the RouteInput() to do this. But I don't get the correct address of the interface.

RouteInput() has a parameter,
Ptr<const NetDevice> idev

Through this,
for (std::map<Ptr<Socket>, Ipv4InterfaceAddress>::const_iterator j =
m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) {

Ipv4InterfaceAddress iface = j->second;

if (m_ipv4->GetInterfaceForAddress(iface.GetLocal()) == iif) {
myAddress = iface.GetLocal();
}
}

Where I'm doing wrong?

Shanen Leen

unread,
Jun 26, 2017, 2:27:02 PM6/26/17
to ns-3-users
To clarify and simplify my requirement even more,

Within the RouteInput() method, what statement/argument should be passed to IsMyOwnAddress(<statement>) to always return true?
Always returning true means we are passing an Ipv4Address that belongs to an interface of the node itself.

Thanks!

Shanen Leen

unread,
Jun 26, 2017, 2:42:27 PM6/26/17
to ns-3-users
Please note that in the simulation script (Very much similar to manet-routing-comapare.cc example with AODV enabled), i'm giving the addresses by calling,
addressAdhoc.SetBase("10.1.1.0", "255.255.255.0");

So within the aodv-routing-protocol.cc RouteInput() method, I want to get my interface IP as something similar to 10.1.1.2 or 10.1.1.3 or ...
Then if I pass this address to IsMyOwnAddress(), is should return true always. Isn't it?

How can I get the interface address is what i'm asking help for.
Hope we are clear.

Thanks again for the time!

Tommaso Pecorella

unread,
Jul 17, 2017, 7:12:07 PM7/17/17
to ns-3-users
Hi,

sorry for the late answer, but... can you share the changes to the function ?
At first sight the code you posted should work.

T.
Reply all
Reply to author
Forward
0 new messages