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

Material Type: Assignment; Professor: Bhattacharjee; Class: Computer Networks; Subject: Computer Science; University: University of Maryland; Term: Spring 2009;

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-jan
koofers-user-jan 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 417 Computer Networks Spring 2009
Programming Assignment 0
Assigned: 01/30/2009 Due: 02/04/2009, 11:59:59 PM.
You should use the CSIC Linux cluster systems and obtain your account information from the TA.
1 Introduction
For this assignment, you will write a client program which will communicate using sockets with
aserver program provided by us. We will give you a a sketch of the client program all you have
to do is fill in socket-specific bits.
For each client request, our server generates and returns two cookies, and then the server and
clientembarkonalonggoodbye. Obviously,theprotocolis trivial/useless, however,this exercise
will get youstarted onthecluster andfamiliarize youwithsockets, networkprogrammingand
distributed debugging.
2 The Protocol
The server runs on the machine SERVER HOSTNAME andlistensforrequestsonaTCPsocket bound
to port SERVER PORT. Both constants are defined in the header file provided for you. This exercise
hasfourtypes ofmessages: HELLO,STATUS,BYEandCONFIRMBYE.Eachmessageis an
ASCII string, and consists of multiple fields separated by spaces (0x20). The maximum length of
eachmessageis MAX STR SIZE, which is also defined in the header file given to you.
Client Server
HELLO
STATUS
BYE
CONFIRM_BYE
Figure 1: protocol outline
The protocol outline is given in Fig 1. The client initiates the protocol by sending a HELLO
messagetotheserver.Theserver replies withaSTATUSmessage. Theclientthen sendsaBYE
message, and the server terminates the connection by sending a CONFIRM BYE message. A
1
pf3
pf4

Partial preview of the text

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

CMSC 417 Computer Networks Spring 2009

Programming Assignment 0

Assigned: 01/30/2009 Due: 02/04/2009, 11:59:59 PM.

You should use the CSIC Linux cluster systems and obtain your account information from the TA.

1 Introduction

For this assignment, you will write a client program which will communicate using sockets with a server program provided by us. We will give you a a sketch of the client program — all you have to do is fill in socket-specific bits. For each client request, our server generates and returns two cookies, and then the server and client embark on a long goodbye. Obviously, the protocol is trivial/useless, however, this exercise will get you started on the cluster and familiarize you with sockets, network programming and distributed debugging.

2 The Protocol

The server runs on the machine SERVER HOSTNAME and listens for requests on a TCP socket bound to port SERVER PORT. Both constants are defined in the header file provided for you. This exercise has four types of messages: HELLO, STATUS, BYE and CONFIRM BYE. Each message is an ASCII string, and consists of multiple fields separated by spaces (0x20). The maximum length of each message is MAX STR SIZE, which is also defined in the header file given to you.

Client Server

HELLO

STATUS

BYE

CONFIRM_BYE

Figure 1: protocol outline

The protocol outline is given in Fig 1. The client initiates the protocol by sending a HELLO message to the server. The server replies with a STATUS message. The client then sends a BYE message, and the server terminates the connection by sending a CONFIRM BYE message. A

connection is successful if and only if all of these messages are correctly sent and received. Since we are using TCP for communication in this assignment, you do not have to worry about lost messages etc.; you only need to ensure that all messages are sent correctly (and that you receive and parse messages correctly). The details of each message are as follows:

  • HELLO (From the client to the server: Client → Server) The HELLO message has 4 fields EXACTLY in the following order - Message Type The type string MUST be HELLO to indicate a message type HELLO. The server is case-sensitive. - Magic String It MUST set to be MAGIC STRING which is a constant defined in the header file (cmsc417spring09). If you send a message which does not contain this magic string, the message will be ig- nored. - Login ID This field is your cluster login ID. - Last Name The last field is your last name. Please do NOT put spaces in your last name, even if it contain spaces.

An example HELLO message might look like this:

HELLO cmsc417spring09 cs417000 Huang

  • STATUS (Server → Client) The STATUS message has 5 fields in the following order: - Message Type Must be set to STATUS. - Magic String Same as above. - Cookie An integer randomly generated by the server (represented in ASCII). The range is be- tween 1 and 1000. - Cookie Another integer randomly generated by the server (represented in ASCII). The range is between 1 and 1000. - IP Address and Port number A string of the form a.b.c.d:e, representing the IP address and port number of the client.

An example STATUS message might be: STATUS cmsc417spring09 356 478 128.8.128.153:

expected, such as an incorrect magic string or wrong message type, assert an error and terminate your program. Your code must be -Wall clean on gcc. Do not ask the TA for help on (or post to the forum) code that is not -Wall clean unless getting rid of the warning is what the problem is in the first place.