0
votes

I have to calculate the delay in my application, so I need the generation time of the packet that I insert with a chunk in the packet. But then, when I receive the packet, I don't know how to pick the generation time from the chunk.

This is the chunk.

class AppPacket extends FieldChunk {
simtime_t appGenPacket;
int seqNo;
}

This is the trasmission function.

auto data = makeShared<ByteCountChunk>(B(payload));
Packet *pkt=new Packet("DataPacket", data);
auto pktData = makeShared<AppPacket>();
pktData->setAppGenPacket(simtime());
pkt->insertAtBack(pktData);
send(pkt, "lowerLayerOut");

Now when I receive the packet I have to get appGenPacket to calculate the delay, but I don't know hot to do this. Help me pls!

1

1 Answers

2
votes

On the receiving side, you just peek/pop (e.g. pop<AppPacket>()) the chunk with the appropriate type.

But this is NOT how statistics are meant to be generated for packet flows. This approach requires you to modify the app level packet and add a field that is used only by the statistics module (which is not present there in real world). You can add packet tags and packet region tags to a packet (or part of the packet) which is meta-data information that travels along the packet or individual bits in the packet. On the receiving end you can query the attached tags and use that for your statistics. (see TimeTag in the latest INET version)

Even better, INET already has facilities to measure the delay of packet flows (it's called FlowMeasurement btw.) and also the timing example.