| CS 455/555 - Intro to Networks and Communications
Fall 2009: Tues/Thurs 3-4:15pm, Spong 0108 |
|
Staff
Syllabus (pdf) |
Program 2: Ping with TCP and UDPAssigned: Thursday, September 24, 2009
DescriptionThe goal of this assignment is to help you become familiar with socket programming in Java using both TCP and UDP sockets. We'll be implementing a Because we're limited to running the programs on-campus where there will be little delay and very little loss, the server will add some artificial delay and ignore some ping requests (for UDP) to simulate packet loss. PingClient
PING seqno timestamp
where PING is the word "PING", seqno is the ping sequence number (between 0-9), and timestamp is the time (in milliseconds) that the message was created and sent
PingServer
The server's action will either be " not sent" if the ping was ignored or "delayed x ms" .
For TCP, the server will close the client connection after each ping reply is sent.
Rules
TestingA large part of your program's grade will be determined by how well it handles a set of inputs. You should test your program rigorously before submitting. Because your programs will be run and tested using a script, you must format your output exactly as I have described or you will lose points. Example 1 java PingClient
Usage: java PingClient hostname port protocol
protocol - {TCP, UDP}
java PingServer
Usage: java PingServer port protocol [seed]
protocol - {TCP, UDP}
Example 2 java PingClient vega three TCP ERR - arg 2 java PingServer 10002 tcp ERR - arg 2 Example 3 vega> java PingServer 10002 TCP 123 128.82.4.98:48596> PING 0 1234821840436 ACTION: delayed 144 ms 128.82.4.98:48597> PING 1 1234821840596 ACTION: delayed 198 ms 128.82.4.98:48598> PING 2 1234821840805 ACTION: delayed 50 ms 128.82.4.98:48599> PING 3 1234821840865 ACTION: delayed 121 ms 128.82.4.98:48600> PING 4 1234821840995 ACTION: delayed 161 ms 128.82.4.98:48601> PING 5 1234821841165 ACTION: delayed 175 ms 128.82.4.98:48602> PING 6 1234821841345 ACTION: delayed 143 ms 128.82.4.98:48603> PING 7 1234821841495 ACTION: delayed 14 ms 128.82.4.98:48604> PING 8 1234821841515 ACTION: delayed 159 ms 128.82.4.98:48605> PING 9 1234821841685 ACTION: delayed 115 ms antares> java PingClient vega 10002 TCP PING 0 1234821840436 RTT: 159 ms PING 1 1234821840596 RTT: 208 ms PING 2 1234821840805 RTT: 59 ms PING 3 1234821840865 RTT: 130 ms PING 4 1234821840995 RTT: 169 ms PING 5 1234821841165 RTT: 179 ms PING 6 1234821841345 RTT: 149 ms PING 7 1234821841495 RTT: 19 ms PING 8 1234821841515 RTT: 169 ms PING 9 1234821841685 RTT: 119 ms (Note: The delays the server uses should be the same with the same seed, but the timestamps in the client's ping message will not since they depend on the time the program was run. Also, with TCP since you are creating a new connection for each PING sent, the client's port number will be different each time.) Example 3 vega> java PingServer 10002 UDP 123 128.82.4.98:35405> PING 0 1234821943582 ACTION: delayed 198 ms 128.82.4.98:35405> PING 1 1234821943786 ACTION: not sent 128.82.4.98:35405> PING 2 1234821944791 ACTION: delayed 161 ms 128.82.4.98:35405> PING 3 1234821944955 ACTION: delayed 143 ms 128.82.4.98:35405> PING 4 1234821945105 ACTION: not sent 128.82.4.98:35405> PING 5 1234821946110 ACTION: delayed 115 ms 128.82.4.98:35405> PING 6 1234821946235 ACTION: delayed 29 ms 128.82.4.98:35405> PING 7 1234821946275 ACTION: delayed 13 ms 128.82.4.98:35405> PING 8 1234821946295 ACTION: not sent 128.82.4.98:35405> PING 9 1234821947300 ACTION: not sent antares> java PingClient vega 10002 UDP PING 0 1234821943582 RTT: 204 ms PING 1 1234821943786 RTT: * PING 2 1234821944791 RTT: 164 ms PING 3 1234821944955 RTT: 150 ms PING 4 1234821945105 RTT: * PING 5 1234821946110 RTT: 125 ms PING 6 1234821946235 RTT: 40 ms PING 7 1234821946275 RTT: 20 ms PING 8 1234821946295 RTT: * PING 9 1234821947300 RTT: * Hints
No. You must use an actual machine name (antares, vega, or hydra).
See System.currentTimeMillis()
See the setSoTimeout() function in the DatagramSocket class in the Java Class Reference (the link is under 'Useful Links' on the course webpage).
SubmissionYou must name your source files PingClient.java and PingServer.java (note the capitalization). Make sure that you submit all files necessary to compile your program. But, do not submit compiled files (.class files). Directions for submitting your assignment through Blackboard |