I use socket to send a packet from a node to another. I verified that the packet is received through callback method. But, when I want to read the packet from the receiver, I obtain no thing. Can you please help me to find the problem. This is the code
ns3::PacketMetadata::Enable () ;
Ptr<Socket> recvSink = Socket::CreateSocket (container.Get (1), tid);
InetSocketAddress local = InetSocketAddress ((Ipv4Address::GetAny()), dlPort);
recvSink->Bind (local);
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));
Ptr<Socket> source;
source = Socket::CreateSocket (container.Get (0), tid);
InetSocketAddress remote = InetSocketAddress (wifiInterfaces.GetAddress(0), dlPort);
source->Connect(remote);
Ptr <Packet> p=Create<Packet> (1024);
source->Send (p);
Ptr <Packet> packet;
Address address= wifiInterfaces.GetAddress(u);
LogComponentEnable("UdpSocket",LOG_LEVEL_INFO);
packet = recvSink->RecvFrom (address);
std::cout<<p->GetSize();
while ((packet = recvSink->RecvFrom (address)))
{
//packet = recvSink->RecvFrom (address);
if (packet->GetSize () > 0)
{
SeqTsHeader seqTs;
packet->RemoveHeader (seqTs);
// uint32_t currentSequenceNumber = seqTs.GetSeq ();
if (InetSocketAddress::IsMatchingType (address))
{
std::cout<<"At time " << Simulator::Now ().GetSeconds () << "s server received " << packet->GetSize () << " bytes from " <<
InetSocketAddress::ConvertFrom (address).GetIpv4 () << " port " <<
InetSocketAddress::ConvertFrom (address).GetPort ();
}
}
}