examples: remove questionable use of SocketAddressTag (use RecvFrom)
This commit is contained in:
@@ -120,18 +120,15 @@ RoutingExperiment::RoutingExperiment ()
|
||||
}
|
||||
|
||||
static inline std::string
|
||||
PrintReceivedPacket (Ptr<Socket> socket, Ptr<Packet> packet)
|
||||
PrintReceivedPacket (Ptr<Socket> socket, Ptr<Packet> packet, Address senderAddress)
|
||||
{
|
||||
SocketAddressTag tag;
|
||||
bool found;
|
||||
found = packet->PeekPacketTag (tag);
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId ();
|
||||
|
||||
if (found)
|
||||
if (InetSocketAddress::IsMatchingType (senderAddress))
|
||||
{
|
||||
InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag.GetAddress ());
|
||||
InetSocketAddress addr = InetSocketAddress::ConvertFrom (senderAddress);
|
||||
oss << " received one packet from " << addr.GetIpv4 ();
|
||||
}
|
||||
else
|
||||
@@ -145,11 +142,12 @@ void
|
||||
RoutingExperiment::ReceivePacket (Ptr<Socket> socket)
|
||||
{
|
||||
Ptr<Packet> packet;
|
||||
while ((packet = socket->Recv ()))
|
||||
Address senderAddress;
|
||||
while ((packet = socket->RecvFrom (senderAddress)))
|
||||
{
|
||||
bytesTotal += packet->GetSize ();
|
||||
packetsReceived += 1;
|
||||
NS_LOG_UNCOND (PrintReceivedPacket (socket, packet));
|
||||
NS_LOG_UNCOND (PrintReceivedPacket (socket, packet, senderAddress));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user