Develop a ping programme for MM
Tuesday, November 28, 2006 1:22:06 PM
Model:
Client-- ping -->Server
|
calculate (rtt)
|
Client<--pingback--Server
In this programm, we do the following things:
1) Client sends a packet to the server, with the time vector <timeval payload> in its payload;
2) Server gets the packet from the client;
3) Server picks out the sendtime of the packet from the payload, and calculate the one-way rtt by <current_time - payload_time>;
4) Server sends the rtt back to the client;
5) Client gets the rtt, and print it out.
2. How to compile these files?
Input the following lines:
1) gcc pingd.c -o server
2) gcc ping.c -o client
Then you get two excutive files, server and client.
You could run both of them on the same machine, or on two different machines.
If you want to run them on the same machine:
in one terminal:
3) ./server
open another terminal:
4) ./client localhost (which means you ping yourself). Or you could input
./client 127.0.0.1 Or
./client <the IP of your machine> etc. "./client 192.1.42.23"
If you want to run them on two different machines:
in one machine:
3) ./server
in the other machine:
4) ./client <the IP of the sever Machine>
Howto
ping.c
ping.h
pingd.c







