static inline std::string
PrintReceivedPacket (Ptr<Socket> socket, Ptr<Packet> packet, Address senderAddress)
{
std::ostringstream oss;
oss << Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId ();
if (InetSocketAddress::IsMatchingType (senderAddress))
{
InetSocketAddress addr = InetSocketAddress::ConvertFrom (senderAddress);
oss << socket-> GetNode()->GetDevice(socket->GetNode ()->GetId ()) << " received one packet from " << addr.GetIpv4 ();
}
else
{
oss << " received one packet!";
}
return oss.str ();
}
Ptr<Node> node = socket->GetNode (); Ptr<Ipv4> ipv4_ptr = node->GetObject<Ipv4> (); // Get Ipv4 instance of the node Ipv4Address addr = ipv4_ptr->GetAddress (1, 0).GetLocal (); // Get Ipv4InterfaceAddress of 1st interface. std::cout << "Node: " << node->GetId() << " Address: " << addr<<std::endl;
Best regards,
George
--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/e863f98d-05b3-4477-b9c8-9da1729c4770%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/76fde66d-e147-49e1-84e9-9d1dd66dc03e%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/76fde66d-e147-49e1-84e9-9d1dd66dc03e%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/0d92fbb0-b1ba-4e4c-8c74-670f0138f84a%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/0d92fbb0-b1ba-4e4c-8c74-670f0138f84a%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/c29377a3-9a34-4f05-bb55-333ff2205eb8%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/c29377a3-9a34-4f05-bb55-333ff2205eb8%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/633e0924-0821-43d2-b279-3694c17d5a9d%40googlegroups.com.