end to end delay or latency

8 views (last 30 days)
rem ng
rem ng on 21 May 2019
Commented: Walter Roberson on 14 Feb 2022
can anyone help me what matlab code has to be used to find out end to end delay packet transmission or latency from source node to destination node? or related matlab code?
  1 Comment
Mahal Wasique
Mahal Wasique on 10 Jul 2021
rem ng can you provide me the code if you have it?

Sign in to comment.

Answers (3)

Vol kan
Vol kan on 31 Aug 2019
Dear Rem,
Have you solved your problem?
If yes, could you please kindly share your codes in here?
Best
  2 Comments
rem ng
rem ng on 1 Sep 2019
not yet @ Vol kan
meh mehz
meh mehz on 13 Aug 2020
Hey if you solve it can you share the answer @rem ng

Sign in to comment.


Walter Roberson
Walter Roberson on 31 Aug 2019
In order to calculate the end-to-end time, you need a pair of timestamps -- the time that the packet is queued for transmission, and the time that the packet is dequeued and becomes ready for consumption.
If somehow you had a single datascope hooked up to the source and recipient nodes, you could potentially measure the times for physical nodes. However, that situation does not typically occur. At best you might have a scope attached to the source physical node and a different scope attached to the destination physical node, and then to accurately measure latency, you are at the mercy of the accuracy of the synchronization of times between the two scopes -- which turns out to be amazingly hard to synchronize accurately. It is a "Keeps physicists up at night worrying that humans have made serious mistakes in understanding fundamental reality" hard problem.
As you are talking about MATLAB code, then you are probably taking about simulated networks. In that case, just attach some metadata to each simulated packet giving the simulated time that the packet was simulated transmitted, and when the packet is simulated received, inject the simulated reception time. And then subtract.
  4 Comments
Kok Siong Yap
Kok Siong Yap on 20 Jun 2021
Hi Walter,
Do you have a simple matlab code regarding attachment of metadata as you mention?
As you are talking about MATLAB code, then you are probably taking about simulated networks. In that case, just attach some metadata to each simulated packet giving the simulated time that the packet was simulated transmitted, and when the packet is simulated received, inject the simulated reception time. And then subtract.
Walter Roberson
Walter Roberson on 21 Jun 2021
%transmitting side
[packet_to_transmit, NODEINFO(SOURCE)] = build_packet(NODEINFO(SOURCE), DEST, Protocol, SourcePort, DestPort, payload);
outidx = numel(NODES(SOURCE).OutQueue)+1;
NODES(SOURCE).OutQueue(outidx).packet = packet_to_transmit;
NODES(SOURCE).OutQueue(outidx).xmit_time = SIMULATION_TIME;
%when packet reaches the head of the virtual send queue for the node
PACKET_INFO = NODES(SOURCE).OutQueue(outidx);
PACKET_INFO.source = SOURCE;
PACKET_INFO.outidx = outidx;
%transmission is noisy
PACKET_INFO = CorruptPacket(PACKET_INFO);
%receiving side
inidx = numel(NODES(DEST).InQueue) + 1;
NODES(DEST).InQueue(inidx).packet = PACKET_INFO.packet;
NODES(DEST).InQueue(inidx).xmit_time = PACKET_INFO.xmit_time;
NODES(DEST).InQueue(inidx).receive_time = SIMULATION_TIME;
NODES(PACKET_INFO.source).OutQueue(PACKET_INFO.outidx) = []; %it moved from output queue to input queue
Here, variables in all capitals represent values that live in the simulation software, that represent global knowledge of everything that is happening.
NODES in the above excerpt is only used to hold the packets.
NODEINFO in the above is intended to represent each nodes' knowledge about its neighbours, and to include information such as TCP sequence numbers. It is output as well as input from the build_packet process because starting a new conversation can involve allocating resources, and continuing a conversation can involve changing state.
Ideally, the information in NODES should be confined to only the information needed because the simulation software is "god" to the simulation, and anything being simulated as the nodes knowing should be elsewhere. Indeed, where I show the queues as being part of NODES, they should instead be part of NODEINFO ("per-node info"), but NODES might be used to keep global statistists. For example the above sequence on the receiver side should continue with validating the packet and increasing any global received-payload total for the node... with it being valid to instead keep the received-payload-total per-node and and have the simulation controller fish through the per-node information to get the values.

Sign in to comment.


Zahid Ullah Khan
Zahid Ullah Khan on 14 Feb 2022
someone help me to do matlab code of end-to-end delay in underwater wireless communication networks my email is engr.zahidkhan09@gmail.com
  1 Comment
Walter Roberson
Walter Roberson on 14 Feb 2022
"help me" can mean many different things. Are you looking for someone you can give your ideas to, and the person tells you whether they sound reasonable? Are you looking for someone to research papers on the topic for you and give you the references? Are you looking for someone who can look over the code you have so-far and help you debug the code you have so far? Are you looking for a tutor? Are you looking for someone to write the code for you with the intention that you would hand in the code as-if you had written it yourself? Are you looking for someone to give you an example implementation that you would study for ideas and then write your own version?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!