packet drooped due to MAC filtering

60 views
Skip to first unread message

Asayel A

unread,
Mar 30, 2019, 5:28:33 AM3/30/19
to ns-3-users
Greetings,
I'm running the following code, but the packets sent from devices are being dropped for some reason. Can anyone help?

static void PacketSentSuccessfully (Ptr<const Packet> p)
{

BasicPacketData bpd (p);
NS_LOG_UNCOND ("----------MSDU sent successfully----------\n"
<< "Packet of size " << bpd.size << " bytes sent\n"
<< "was successfully sent from address " << bpd.src << " to address " << bpd.dst << "\n"
<< "sequence number is " << (int) bpd.seq_nr << "\n"
<< "PAN ID is " << bpd.pan_id << "\n"
<< "----------MSDU sent successfully------------\n\n"
);
}



static void PacketDropped (Ptr<LrWpanNetDevice> dev, Ptr<const Packet> p)
{

BasicPacketData bpd (p);
NS_LOG_UNCOND ("----------Packet dropped----------\n"
<< "Packet of size " << bpd.size << " was dropped during MAC filtering\n"
<< "on device with address "<<dev->GetMac()->GetShortAddress()<<"\n"
<< "coming from address " << bpd.src << " to address " << bpd.dst << "\n"
<< "sequence number is " << (int) bpd.seq_nr << "\n"
<< "PAN ID is " << bpd.pan_id << "\n"
<< "----------Packet dropped------------\n\n"
);
}


static void MakeCallbacks(std::vector<Ptr <LrWpanNetDevice> > devs)
{


for (std::vector<Ptr <LrWpanNetDevice> >::const_iterator i = devs.begin(); i!=devs.end(); ++i)
{
Ptr<LrWpanNetDevice> dev = *i;
dev->GetMac()->TraceConnectWithoutContext ("MacTxEnqueue", MakeBoundCallback(&PacketEnqued,dev));
dev->GetMac()->TraceConnectWithoutContext ("MacTxOk", MakeCallback(&PacketSentSuccessfully));
dev->GetMac()->TraceConnectWithoutContext ("MacRxDrop", MakeBoundCallback(&PacketDropped,dev));
dev->GetMac()->TraceConnectWithoutContext ("MacSentPkt", MakeBoundCallback(&PacketSendInfo,dev));

McpsDataConfirmCallback cb0 = MakeBoundCallback (&McpsDataConfirm,dev); //McpsDataConfirmCallback This callback is called after a McpsDataRequest has been called from the higher layer
dev->GetMac ()->SetMcpsDataConfirmCallback (cb0);
}

}

Ptr< Packet> createpackets(Ptr<LrWpanNetDevice> dev, Ptr<LrWpanNetDevice> dev3)
{
Ptr< Packet> packet;
//char* ch = reinterpret_cast<char*>(p);
//std::cout<<dev->GetMac();
  if (dev->GetMac()->GetShortAddress() == ("00:01")){


    std::string packettype = ("00");
    std::string packetInformation = ("123e4567-e89b-12d3-a456-426655440000");
    packettype += packetInformation;
    std::stringstream msgx;
    msgx << packettype;
    uint16_t packetSize = msgx.str().length()+1;
    packet = Create<Packet>((uint8_t*) msgx.str().c_str(), packetSize);
    
    


  }
  else if (dev->GetMac()->GetShortAddress() == ("00:02")){


    std::string packettype = ("00");
    std::string packetInformation = ("345e6789-e89b-12d3-a456-426655440000");
    packettype += packetInformation;
    std::stringstream msgx;
    msgx << packettype;
    uint16_t packetSize = msgx.str().length()+1;
    packet = Create<Packet>((uint8_t*) msgx.str().c_str(), packetSize);

  }
  else  {

    std::string packettype = ("00");
    std::string packetInformation = ("567e8912-e89b-12d3-a456-426655440000");
    packettype += packetInformation;
    std::stringstream msgx;
    msgx << packettype;
    uint16_t packetSize = msgx.str().length()+1;
    packet = Create<Packet>((uint8_t*) msgx.str().c_str(), packetSize);

  }
Ptr<const Packet> p = packet;
LrWpanMacHeader h;
p->PeekHeader(h);
BasicPacketData bpd (p);
std::cout<<"Packet Size:"<<p->GetSize()<<std::endl;
uint8_t *buffer = new uint8_t[p->GetSize()];
p->CopyData (buffer, p->GetSize());
//string receivedData(buffer, buffer+p->GetSize());
std::string receivedData(buffer, buffer+p->GetSize ());
std::cout<<"Received:"<<receivedData.c_str()<<std::endl;

if(!h.IsAcknowledgment()) //Returns true if the header is an ack
{
NS_LOG_UNCOND ("----------Packet received----------\n"
<< "Packet of size " << bpd.size << " bytes received\n"
//<< "on device with address "<< dev3->GetMac()->GetShortAddress()<<"\n"
//<< "was sent from address " << dev->GetMac()->GetShortAddress() << "\n"
                                << "on device with address "<< bpd.dst<<"\n"
<< "was sent from address " << bpd.src << "\n"
<< "sequence number is " << (int) bpd.seq_nr << "\n"
<< "PAN ID is " << bpd.pan_id << "\n"
<< "----------Packet received------------\n\n"
);
}
else
{
NS_LOG_UNCOND ("----------ACK Frame received---------\n"
<< "ACK frame of size " << bpd.size << " bytes \n"
<<  "received on device with address " << dev3->GetMac()->GetShortAddress() << "\n"
<< "for the frame with sequence number " << (int) bpd.seq_nr << "\n"
<< "----------ACK Frame received---------\n\n"
);
  
}
return packet;
//packet->Print(std::cout);

}


packetPayloadTest1tobemodified3-1.cc
Reply all
Reply to author
Forward
0 new messages