Programming Assignment 2 - Computer Networks | CMSC 417, Assignments of Computer Systems Networking and Telecommunications

Material Type: Assignment; Professor: Agrawala; Class: Computer Networks; Subject: Computer Science; University: University of Maryland; Term: Fall 2008;

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-086
koofers-user-086 🇺🇸

7 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 417 Computer Networks Fall 2008
Programming Assignment 2
1 Introduction
In this assignment you will write the server program which will communicate using
sockets with the client program in the previous assignment.
2 The Protocol
Your server will run on a linuxlab machine and will listen on a TCP socket bound to a port as described
below. Note that you cannot bind to a port below 1024 without having super user (root) access.
Given that your class account login id is cs4170xx, the ports you should use are 10xx0-10xx9 (inclusive).
Thus, if your login id is cs417060, you will use port range 10600-10609. Your final project must work with
any port, but when you are testing your project you should only use the ports you have been allocated to
avoid collision with others.
The rest of the protocol is as described in Project 0.
3 The server program
The command line syntax for a minimal server is given below. The server will take the port as argument.
(you can almost re-use the argument parsing code in the client).
server
server server
server [<port>]
[<port>][<port>]
[<port>]
• The cookie should be generated using the formula:
(a + b + c + d) × 13 mod 1111, where a.b.c.d is the IP address of the client, 0 a, b, c, d 255.
• After the successful communication, the server MUST print the cookie it generates along with the client’s
login id, first name, IP address and port number. All this information should be in a single line. An example
is:
555 cs417050 Nikolaos from 128.8.126.208:48542
555 cs417050 Nikolaos from 128.8.126.208:48542555 cs417050 Nikolaos from 128.8.126.208:48542
555 cs417050 Nikolaos from 128.8.126.208:48542
Notice that ((128+8+126+208) × 13 mod 1111) is 555
•For project 1 the server only accepted null terminated strings. Your server should work even when the
client sends the string without the terminal ‘\0’ character.
• Note well: your server should not accept spurious input from the clients.
• We will test your server with non-confor ming clients; the server should print out an error message
containing the client’s IP address and port number also in a single line, as such:
**Error** from 128.8.126.133:48522
**Error** from 128.8.126.133:48522**Error** from 128.8.126.133:48522
**Error** from 128.8.126.133:48522
and immediately close the connection when it finds a bad message from the client. It should not
breakdown, but continue operating after servicing misbehaving clients. Bad messages, as per project 0, are
ones that have an incorrect magic string, incorrect message type or too many fields.
Remember, the cookie sent in the STATUS message has to match the cookie in the CLIENT BYE
message for a communication to be successful.
pf2

Partial preview of the text

Download Programming Assignment 2 - Computer Networks | CMSC 417 and more Assignments Computer Systems Networking and Telecommunications in PDF only on Docsity!

CMSC 417 Computer Networks Fall 2008

Programming Assignment 2

1 Introduction

In this assignment you will write the server program which will communicate using

sockets with the client program in the previous assignment.

2 The Protocol

Your server will run on a linuxlab machine and will listen on a TCP socket bound to a port as described below. Note that you cannot bind to a port below 1024 without having super user (root) access.

Given that your class account login id is cs4170xx, the ports you should use are 10xx0-10xx9 (inclusive).

Thus, if your login id is cs417060, you will use port range 10600-10609. Your final project must work with any port, but when you are testing your project you should only use the ports you have been allocated to avoid collision with others. The rest of the protocol is as described in Project 0.

3 The server program

The command line syntax for a minimal server is given below. The server will take the port as argument. (you can almost re-use the argument parsing code in the client).

serverserverserverserver (^) [][][][]

  • The cookie should be generated using the formula: (a + b + c + d) × 13 mod 1111, where a.b.c.d is the IP address of the client, 0 ≤ a, b, c, d ≤ 255.
  • After the successful communication, the server MUST print the cookie it generates along with the client’s login id, first name, IP address and port number. All this information should be in a single line. An example is: 555555555555 cs417050cs417050cs417050cs417050 NikolaosNikolaosNikolaosNikolaos fromfromfromfrom 128.8.126.208:48542128.8.126.208:48542128.8.126.208:48542128.8.126.208: Notice that ((128+8+126+208) × 13 mod 1111) is 555

•For project 1 the server only accepted null terminated strings. Your server should work even when the client sends the string without the terminal ‘\0’ character.

  • Note well: your server should not accept spurious input from the clients.
  • We will test your server with non-conforming clients; the server should print out an error message containing the client’s IP address and port number also in a single line, as such:

Error****Error****Error****Error fromfromfromfrom 128.8.126.133:48522128.8.126.133:48522128.8.126.133:48522128.8.126.133:

and immediately close the connection when it finds a bad message from the client. It should not breakdown, but continue operating after servicing misbehaving clients. Bad messages, as per project 0, are ones that have an incorrect magic string, incorrect message type or too many fields. Remember, the cookie sent in the STATUS message has to match the cookie in the CLIENT BYE message for a communication to be successful.

  • Do NOT print out any other debugging messages. They are useful for you, but not for your TA to grade.
  • All output should be printed to stdout. Use fflush(stdout); after every output to stdout.

4 Requirements

  • We provide a conforming client for those who did not get the client to work and a public test to test the server functions against it.
  • Your code must be -Wall clean on gcc. Do not ask the TA for help on (or post to the newsgroup) code that is not -Wall clean unless getting rid of the warning is what the problem is in the first place.

5 Project Submission

  • Please submit your code to the Submit Server (https://submit.cs.umd.edu/).
  • You should upload a zip file which contains the files server.c and common.h ( and possibly any other .h files you are using). You can create this file on linuxlab using:

zipzipzipzip server.zipserver.zipserver.zipserver.zip server.cserver.cserver.cserver.c common.hcommon.hcommon.hcommon.h