Department of Computer Science
CS4254 Computer Network Architecture and Programming
This homework will be submitted online using the Curator system at http://courses.cs.vt.edu/curator/CourseLinks.html. Follow the link that has our course name and number. Please do not submit binaries or object files. Your source code should be accompanied by a make file and a README file explaining how to generate relevant binaries, and any other necessary information to run your programs. Every student gets a maximum of 3 submissions. Your last submission will be the one to be graded. No late submission will be accepted.
Q1. (5 pts) Write C source code to verify the IP address and ephemeral port assigned to a client UDP socket? Hint: Print this information after calling socket, sendto, and connect in the connect variant. What do you conclude regarding the assignment of IP/port to a UDP socket?
Q2. (5 pts) Write C source code for a UDP client. This client will send datagrams to 2 different UDP echo servers in order, i.e., send the first datagram to the first server, then wait to receive it back, send the second datagram to the second server, then wait to receive it back. The first and second datagrams are user-provided input. Upon receiving the datagram from the server, the client displays the datagram’s data along with the source of the datagram (IP and port). Hint: Do you need 1 or 2 sockets in the client?
Q3. (20 pts) Write C source code for the following client/server specifications.
The client creates 1
Usage: client <
The server creates 1
Usage: server <TCP server port>
Example for Server Output
Connection from TCP client 22.214.171.124:48967 accepted
“xyz” received from 126.96.36.199:45987
For the client and server, your code should provide suitable error checking and diagnostic messages.