For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > March 2006 > Time between sending and receiving of Ethernet Packet (Cont..)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Time between sending and receiving of Ethernet Packet (Cont..)
Yash

2006-03-22, 4:01 am

"Yash" <yash_...@yahoo.com> writes:
> Hi all,


> I need a solution, by which i can measure time between sending and
> receiving of packet from one application to another one.
> I am working with application with uses unicast( both TCP and UDP) and
> broadcast.
> Also i am having "Ethereal" tool to see when packet leaving one
> port/NIC and reaching
> other port/NIC. But i want more precise solution, by which i can know
> delay for
> application to application.




ping(1)


> One solution which i thought off, is that i can get the system time
> before
> sending the packet, put it into packet with regular data and extract
> the time at other end.



This doesn't work because time is relative. Even with ntp
synchronized hosts, there may be a difference.


> By comparing the current time with this time, i can get time
> difference. Is it a
> correct approch. I am not sure, how precise it is. Is there any better
> method or
> tool available.



Yes, you can re-implement ping functionality in your application. It
could give you a different number of nanoseconds, given that ping uses
the icmp protocol, while your application may use udp or tcp.

You send data to the other application which sends a response
immediately when it receives it. You measure the time between sending
and receiving the response, and divide by 2.



> I will be grateful to you for suggestions and solutions.
> best regards,
> Yashpal



--
__Pascal Bourguignon__
http://www.informatimago.com/
Un chat errant
se soulage
dans le jardin d'hiver
Shiki
/***---------------------------------------------------------------------------***/

Hi,
I am thankful for your previous responses.

I worked upon the problem, "calculation of time delay between
transmission and reception of ethernet Packet".
But i am getting different time delay at different time. Can anybody
tell me the reason?


Test Setup is as follows:


|-------| |-----------|
| Tx |<----------------- | |----------------->|Rx |
|-------| | | |-----------|
Linux Box 1 | | Linux Box 2
| |
|-----------------------|
| Eth Swt |
|-----------------------|
^
|
|-------------|
|NTP Box|
|-------------|


I am having NTP unit with Stratum 1, Dlink Gigabit Ethernet Switch and
two Linux machine.
So both linux boxes are time syncronised.
I hav written two socket programs for sending and receiving packet.
In sender program (i hav removed unnecessory code) :
gettimeofday(&p->t1,NULL);
send(sock,p,pkt_size,0);
sending time t1 in packet.


At receiver end:
recv(newsock, &p1, sizeof(char)*(pkt_size), 0);
gettimeofday((&p1.t3),NULL);
lapse = (p1.t3.tv_sec-p1.t1.tv_sec)*1000000 +
(p1.t3.tv_usec-p1.t1.tv_usec);
So t3 is time ,packet reached. and then calculating the time
difference.


At the same time i am running ETHEREAL to cross check the timedelay,
calculated as above.


Now, with this setup, the statistics which i got, raised lot of points:



1. There is a difference between the time delay calculated by program
and ETHEREAL. Why?
2. At differnet instant of time i am getting different timedelay. Why?
3. Sometimes time delay is negative. Why?
4. Does the clocks of both Linux Boxes are maintaining same time, as
they are having the same Reference clock of NTP ?


I will be grateful to you for suggestions and solutions.
best regards,
Yashpal

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com