//Sending Packets
McpsDataRequestParams params;
params.m_srcAddrMode = SHORT_ADDR;
params.m_dstAddrMode = SHORT_ADDR;
params.m_dstPanId = 0;
params.m_dstAddr = Mac16Address ("FF:FF");
params.m_msduHandle = 0;
params.m_txOptions = TX_OPTION_ACK;
string packetInformation = ("");
//generatepacket() returns string content
packetInformation = generatePacket();
stringstream msgx;
msgx << packetInformation;
uint16_t packetSize = packetInformation.length();
Ptr<Packet> packet = Create<Packet>((uint8_t*) msgx.str().c_str(), packetSize);
Simulator::ScheduleWithContext (1, Seconds (0.0), &LrWpanMac::McpsDataRequest, firstNode->device->GetMac (), params, packet); // p is the received packet
cout<<"Packet Size:"<<p->GetSize()<<endl;
uint8_t *buffer = new uint8_t[p->GetSize ()];
p->CopyData (buffer, p->GetSize ());
string receivedData(buffer, buffer+p->GetSize ());
cout<<"Received:"<<receivedData<<endl;
std::ostringstream msg; msg << "Hello World!" << '\0';
Ptr<Packet> packet = Create<Packet> ((uint8_t*) msg.str().c_str(), msg.str().length());
packet->Print (cout);
std::cout << std::endl; uint8_t *buffer = new uint8_t[p->GetSize ()];
p->CopyData(buffer, p->GetSize ());
string s = string((char*)buffer);
cout<<"Received:"<<s<<endl; uint16_t packetSize = msgx.str().length();
Ptr<Packet> packet = Create<Packet>((uint8_t*) msgx.str().c_str(), packetSize);
dev->GetMac()->TraceConnectWithoutContext ("MacRx", MakeBoundCallback(&PacketReceived, dev));