How to get delay time

3,079 views
Skip to first unread message

Meng Kuai

unread,
Mar 18, 2013, 2:42:29 AM3/18/13
to ns-3-...@googlegroups.com
I have written a protocol extended from IPV4 protocol. Now I just get delivery time in RouteInput method. But it seems not correct. Does anyone tell me how to calculate delay for each packet?

Thanks,

Meng

Konstantinos

unread,
Mar 18, 2013, 7:09:24 AM3/18/13
to ns-3-...@googlegroups.com
If you want the delay for each packet, then you have different options:

1) create trace source and use callbacks to get the time each packet was created/sent and the time it was delivered/received. Then you can calculate the delay
2) Use tags to tag the time a packet was created/sent and read this tag when you receive it and calculate the delay
3) Use a header (or just a field in the header) to include the time it is created/sent and read that header when you receive it

If you want average delay, or statistics (histogram of delay) then you can use FlowMonitor to get these without any modification in the packets. 

Choose your option and search the documentation/mailing-list to see how to do it. Every option is discussed at lead once in this list.

Regards,
Konstantinos

khc...@siswa.um.edu.my

unread,
Oct 19, 2013, 10:16:42 AM10/19/13
to ns-3-...@googlegroups.com
Hi Konstantinos,

I am trying to get the delay values for LTE X2 Handover procedure. I used an approach similar to approach (1) you mentioned to get the delay for packet. I used trace source to get the time (with the command Simulator::Now()) when Handover procedure starts and another trace source to get the time (with the command Simulator::Now()) when Handover procedure ends. Then i minus to calculate the delay value.

However, the delay values for all the Handover procedures I calculated are the same although I changed to use different parameters, which I think is weird.

Do you have any idea/suggestion on how can correct it? Or do you know how do the program compute the time values returned by the Simulator::Now() command?

Any comment is appreciated.

Thanks

khc...@siswa.um.edu.my

unread,
Oct 20, 2013, 8:33:05 AM10/20/13
to ns-3-...@googlegroups.com
Thanks for your reply.

Regarding my question on how do the program compute the time values returned by the Simulator::Now() command. Because i used the Simulator::Now() command to get the time T1 and T2 and minus them to get the delay, for certain parameters that I changed such as increasing the noise level and the x2 link delay with commands as follows:

  Config::SetDefault ("ns3::EpcHelper::X2LinkDelay", TimeValue (MilliSeconds(100)));
  Config::SetDefault ("ns3::LteUePhy::NoiseFigure", DoubleValue(59));
  Config::SetDefault ("ns3::LteEnbPhy::NoiseFigure" , DoubleValue(50));

I noticed that the difference between time T1 and T2 (the delay) has increased. But again the delay obtained is constant for all HO that occurred. So, I thought that perhaps the program might have some method to determine what time values to return depending on the parameters we set?

In my scenario, I am expecting to see changes in delay values with different speed of User Equipment movement.

Thanks






On Saturday, October 19, 2013 10:29:04 PM UTC+8, Konstantinos wrote:


On Saturday, October 19, 2013 3:16:42 PM UTC+1, khc...@siswa.um.edu.my wrote:
Hi Konstantinos,

I am trying to get the delay values for LTE X2 Handover procedure. I used an approach similar to approach (1) you mentioned to get the delay for packet. I used trace source to get the time (with the command Simulator::Now()) when Handover procedure starts and another trace source to get the time (with the command Simulator::Now()) when Handover procedure ends. Then i minus to calculate the delay value.

However, the delay values for all the Handover procedures I calculated are the same although I changed to use different parameters, which I think is weird.

Do you have any idea/suggestion on how can correct it?

 I do not have any experience with what the 'expected' delay for handover should be. Perhaps your scenario is 'small', not too much traffic that would cause notable delays or you do not consider the assumptions for the X2 interfaces that LTE has made (ideal signalling channels). I would recommend to study the NS-3 documentation on the LTE module more carefully. 

Also note that in NS-3 there is no consideration of processing delay. If an event is scheduled at the same time then you wouldn't see delays. For example if after the HO starts and event to make this HO is at the same time, without any queueing etc, then the end of the HO would be at the same time.

Or do you know how do the program compute the time values returned by the Simulator::Now() command?


Simulator::Now() returns the current simulation time. What do you mean how it computes it? It is from the internal timer that NS-3 has to keep time.

pdbarnes

unread,
Oct 29, 2013, 3:29:40 PM10/29/13
to ns-3-...@googlegroups.com
On Sunday, October 20, 2013 5:33:05 AM UTC-7, KH Chua wrote:
  Config::SetDefault ("ns3::EpcHelper::X2LinkDelay", TimeValue (MilliSeconds(100)));
I noticed that the difference between time T1 and T2 (the delay) has increased. But again the delay obtained is constant for all HO that occurred. So, I thought that perhaps the program might have some method to determine what time values to return depending on the parameters we set?

In my scenario, I am expecting to see changes in delay values with different speed of User Equipment movement.

Sounds like you expect to see propagation delay, based on (variable) distance between nodes.  Recall that speed of light is 0.3 m/ns, so you'll have to pretty large distance changes to see a significant change in time delay.  Further, you might think about whether such delays are observable at all with a time-slotted protocol, like LTE.

Peter
Message has been deleted

Dionysios Efstathiou

unread,
Nov 29, 2013, 7:01:51 AM11/29/13
to ns-3-...@googlegroups.com
Hi Konstantinos,

Could you please elaborate more on the 2) option? Do you have some running example of this?

The packet tag is added on packet creation and is read back on the ReceivePacket function, right? What about in the case of using a packethelper like UdpSocketFactory, when your custom Tag is added on the packet to be sent? I cannot locate the point where a new packet is created and prepared for sent.

Thanks in advance,
Dionysios

Konstantinos

unread,
Nov 29, 2013, 8:38:36 AM11/29/13
to ns-3-...@googlegroups.com
Hi Dionysios,

Have a look at the documentation regarding packet tags

All you have to do, is create your own packet tag that will add e.g. a timestamp.
When the packet is created at the application, you have to add this packet tag to the packet with the timestamp for current time.
Then when you will receive it, you can read that packet tag, and calculate the delay as the time difference from current time.
This time difference you can save it, print it, do whatever you want. It is the end-to-end delay for a single packet.

The place where you should look for to add the tag, is before a "send" method. For example in applications like OnOffApplication, you have to put it inside this method 

void OnOffApplication::SendPacket (). The UdpSocketFactory you say, just creates a socket, it does not send the packet. 

pdbarnes

unread,
Dec 19, 2013, 5:21:33 PM12/19/13
to ns-3-...@googlegroups.com
There is a TimestampTag to get you started:

Peter

Konstantinos

unread,
Oct 19, 2013, 10:29:04 AM10/19/13
to ns-3-...@googlegroups.com


On Saturday, October 19, 2013 3:16:42 PM UTC+1, khc...@siswa.um.edu.my wrote:
Hi Konstantinos,

I am trying to get the delay values for LTE X2 Handover procedure. I used an approach similar to approach (1) you mentioned to get the delay for packet. I used trace source to get the time (with the command Simulator::Now()) when Handover procedure starts and another trace source to get the time (with the command Simulator::Now()) when Handover procedure ends. Then i minus to calculate the delay value.

However, the delay values for all the Handover procedures I calculated are the same although I changed to use different parameters, which I think is weird.

Do you have any idea/suggestion on how can correct it?

 I do not have any experience with what the 'expected' delay for handover should be. Perhaps your scenario is 'small', not too much traffic that would cause notable delays or you do not consider the assumptions for the X2 interfaces that LTE has made (ideal signalling channels). I would recommend to study the NS-3 documentation on the LTE module more carefully. 

Also note that in NS-3 there is no consideration of processing delay. If an event is scheduled at the same time then you wouldn't see delays. For example if after the HO starts and event to make this HO is at the same time, without any queueing etc, then the end of the HO would be at the same time.

Or do you know how do the program compute the time values returned by the Simulator::Now() command?


Simulator::Now() returns the current simulation time. What do you mean how it computes it? It is from the internal timer that NS-3 has to keep time.
 
Any comment is appreciated.

Barkha Makwana

unread,
Nov 23, 2016, 4:17:58 AM11/23/16
to ns-3-users
Hi i am a student,and i want to do coding of power based handover algorithm and improve the efficiency of this algorithm, i know it sounds weird but i m not used to with ns3.

So can you Please help me?

pdbarnes

unread,
Nov 23, 2016, 10:37:26 AM11/23/16
to ns-3-users
Please start with the Tutorial:
https://www.nsnam.org/docs/tutorial/html/

Next time please also read and follow the posting guidelines.
https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting

These will help you ask good questions, provide all the information needed to give you helpful answers, and enable others to learn from the discussion by keeping one topic per thread.

Good luck,
Peter

Reply all
Reply to author
Forward
0 new messages