Problem Set 1: Socket Programming
Work to be done in teams of two students.
Due date: 11:59PM EST, January 23, 2012.
Late submissions will result in a 10% penalty per day (e.g., 2.5 days late result in 25% penalty)
Sockets Communication
Write a simple client-server broadcast chat application. The server listens
at a specified UDP port, and waits for GREETING messages from remote
clients. Once a greeting has been received the client may send a
MESSAGE command to the server, which will forward the contents in
an INCOMING message to every remote point that has previously
sent a GREETING.
The client creates a socket which it will maintain throughout its lifetime, and is capable of receiving and sending packets from/to the server.
The types and format of messages to be exchanged in the application are:
GREETING: Greets the server. Client to server only.MESSAGE text-of-msg: Sends some text to the server for further distribution. Client to server only.INCOMING text-of-msg ip port: The server has received some text, and is passing it along with the sender's ip and port. Server to client only.- Any other message (e.g. ICMP errors) must be ignored.
You can use either Java or C/C++ to program the application. Here are C sample codes for a udp server and client.
A sample run of your application must work as follows:
server$ java ChatServer 9090runs the server on port 9090
Server Initialized...Server is left runninguser1$ java ChatClient server-ip 9090runs the client and GREETs the server.
] MESSAGE Hello World!Sends a message
<From w.x.y.z:aa>: Hello World!Every client sees this, where w.x.y.z:aa is the senders ip address and port.
]
Note the following:
- The client program keeps waiting for the user to enter new messages and sends them to the server.
- The messages forwarded by the server should be immediately displayed by the client program.
- The messages do not need to be authenticated, confirmed nor encrypted.
- There are no usernames whatsoever.
- The server sends the message to everyone who has GREETED him. There is no mechanism to make the server "forget" or logout clients.
- There is no limit to the number of clients the server supports.
Network Diagnostic
On your own machine, install wireshark, a widely used network protocol analyzer. Familiarize yourself with wireshark capabilities. Run the server chat application you developed in the previous section, on login.ccs.neu.edu, and the client on your own machine.
- Capture and filter the traffic of your application. Show how you did it. (Hint: select the right network interface, filter based on your apppliation port.)
- Capture (1) a
GREETINGpacket, (2) aMESSAGEpacket, and (3) anINCOMINGpacket. Print a screen dump for each of the packets. Describe the protocol stack encapsulation headers for your application packets.
Mechanisms for Reliable Communication
- Describe a mechanisms that makes the delivery of the
MESSAGEpacket reliable from the clients to the server. - Dicuss how you could make the delivery of
INCOMINGpackets reliable. How about efficiency and scalability when the number of clients is very large?