Scenario:
Using UdpEchoSerer and UdpEchoClinet application. Client send packet
to server and server send echo message to client. On receiving the
echo packet, client displays the information that "it " has received
packet from server "IP address."
My requirement:
When client displays the sever IP address, I also want the IP address
of client that has received the packet.
Means I want to know the IP address of Node to which UdpEchoClient
application instance is associated.
The code that I tried:
Ptr <Node> PtrNode = this->GetNode();
Ptr<NetDevice> PtrNetDevice = PtrNode->GetDevice(0);
//Address clientAddress = PtrNetDevice->GetAddress();
Code up to this works well and returns the MAC address of Netdevice
of that "Node"
I want the IPv4 Address of node to which this application instance is
associated. I tried the following code.
Ptr<Ipv4> ipv4 = PtrNode->GetObject<Ipv4> ();
IpvInterfaceAddress iaddr = ipv4.GetAddress (1,0); Ipv4Address ipAddr
= iaddr.GetLocal ();
This code returns an error.
1. "Ipv4" is not declared in this scope.
2. in the first code line : template argument is invalid.
3. Ipv4InterfaceAddress is not declared in this scope
4. no matching function for call to ns3::Node::GetObject();
Please help how to get the IP address
> Ptr<Ipv4> ipv4 = PtrNode->GetObject<Ipv4> ();
> IpvInterfaceAddress iaddr = ipv4.GetAddress (1,0); Ipv4Address ipAddr
> = iaddr.GetLocal ();
You have to change two things:
1: It is Ipv4InterfaceAddress, not IpvInterfaceAddress.
2: it is ->, not .
Like:
Ipv4InterfaceAddress iaddr = ipv4->GetAddress(1, 0);
--
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.
So, it seems to be an include problem.
Try putting the following lines at the beginning of the file:
#include "ns3/network-module.h"
#include "ns3/ipv4.h"
using namespace ns3;
--
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.
Did you solve this problem? I'm with exactly the same problem...
Lucas.
I did make like you, and worked perfectly!
Att, Lucas