我试图了解使用inet 4.0中的PACKET API创建数据包。这是inet 4.0中的新API。
std::ostringstream str;
Packet *packet = new Packet(str.str().c_str());
const auto& payload = makeShared<ApplicationPacket>();
payload->setChunkLength(B(par("packetLength")));
payload->setSequenceNumber(0);
auto macAddressReq = packet->addTag<MacAddressReq>(); // add new tag for MAC
macAddressReq->setSrcAddress(SrcAddress); // source is our MAC address
macAddressReq->setDestAddress(DestAddress); // destination is next hop
auto interfaceReq = packet->addTag<InterfaceReq>(); // add tag for dispatch
interfaceReq->setInterfaceId(1); // set designated interface
auto packetProtocolTag = packet->addTagIfAbsent<PacketProtocolTag>();
packetProtocolTag->setProtocol(&Protocol::ipv4); // set protocol of packet
encapsulate(packet);
send(packet, "radioOut");
编译中没有错误,但是在仿真过程中有错误。
模拟ERR MSG:
我确定错误是由于数据包创建所致。我试图根据开发人员指南来理解。但这没有足够的信息来解决问题。