Program Assignment 2

Similar documents
Programming Assignment 0

Programming Assignment 1

Programming Assignment 1

CS 1803 Pair Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 29th, before 6 PM Out of 100 points

Fall CSEE W4119 Computer Networks Programming Assignment 1 - Simple Chat Application

Overview. Exercise 0: Implementing a Client. Setup and Preparation

Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang

Overview. Exercise 0: Implementing a Client. Setup and Preparation

COMP Assignment 1

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

CS 374 Fall 2014 Homework 2 Due Tuesday, September 16, 2014 at noon

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

Overview. Setup and Preparation. Exercise 0: Four-way handshake

CpSc 1111 Lab 4 Formatting and Flow Control

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30

CS447-Network and Data Communication Project #2 Specification, Fall 2017 Due December 5, 2017

Lab Assignment 3 for ECE374

Project 1. 1 Introduction. October 4, Spec version: 0.1 Due Date: Friday, November 1st, General Instructions

CS 2316 Individual Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 18th, before 11:55 PM Out of 100 points

EECE.2160: ECE Application Programming

CMSC 201 Fall 2018 Lab 04 While Loops

CMSC 201 Spring 2016 Homework 7 Strings and File I/O

Hands on Assignment 1

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

Programming Assignment 2

CIS 505: Software Systems

Project Introduction

CS 118 Project Phase 2 P2P Networking

CS 426 Fall Machine Problem 1. Machine Problem 1. CS 426 Compiler Construction Fall Semester 2017

CpSc 1111 Lab 5 Formatting and Flow Control

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

3. A Periodic Alarm: intdate.c & sigsend.c

P2P Programming Assignment

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

CSE 333 Midterm Exam July 24, Name UW ID#

Peer to Peer Instant Messaging

CS246-Assign01 V1.1: Winter 2013

Figure 1: Graphical representation of a client-server application

Computer Networks CS3516 B Term, 2013

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Homework 4 (document version 1.0) Network Programming using C

Cookie/TCP Protocol Specification

Project 1: A Web Server Called Liso

Fundamentals of Programming Session 4

gcc o driver std=c99 -Wall driver.c everynth.c

This homework is due by 11:59:59 PM on Thursday, October 12, 2017.

Lab 1 Introduction to UNIX and C

CMSC 201 Fall 2016 Homework 6 Functions

Project 1: Snowcast Due: 11:59 PM, Sep 22, 2016

Fall CSEE W4119 Computer Networks Programming Assignment 1 - Simple Online Bidding System

COMP26120 Academic Session: Lab Exercise 2: Input/Output; Strings and Program Parameters; Error Handling

It is academic misconduct to share your work with others in any form including posting it on publicly accessible web sites, such as GitHub.

CpSc 1010, Fall 2014 Lab 10: Command-Line Parameters (Week of 10/27/2014)

CMSC 201 Spring 2018 Project 3 Minesweeper

CS2 Practical 1 CS2A 22/09/2004

CSCI 4963/6963 Large-Scale Programming and Testing Homework 1 (document version 1.0) Regular Expressions and Pattern Matching in C

p1: Fortune 1. Overview 2. Learning Goals 3. Logistics 4. Linux commands

COE 518 Operating Systems. Lab 10

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

New York University Computer Science Department Courant Institute of Mathematical Sciences

بسم اهلل الرمحن الرحيم

CS 142 Style Guide Grading and Details

************ THIS PROGRAM IS NOT ELIGIBLE FOR LATE SUBMISSION. ALL SUBMISSIONS MUST BE RECEIVED BY THE DUE DATE/TIME INDICATED ABOVE HERE

Algorithm Design and Analysis Homework #4

CS52 - Assignment 8. Due Friday 4/15 at 5:00pm.

MP 1: HTTP Client + Server Due: Friday, Feb 9th, 11:59pm

CS164 Final Exam Winter 2013

CS2223: Algorithms D- Term, Homework I. Teams: To be done individually. Due date: 03/27/2015 (1:50 PM) Submission: Electronic submission only

Reliable File Transfer

CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

CS143 Handout 05 Summer 2011 June 22, 2011 Programming Project 1: Lexical Analysis

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Homework 4 (document version 1.1) Sockets and Server Programming using C

Remote Procedure Calls (RPC)

EECS 311: Data Structures and Data Management Program 1 Assigned: 10/21/10 Checkpoint: 11/2/10; Due: 11/9/10

Unate Recursive Complement Algorithm

COMP 412, Fall 2018 Lab 1: A Front End for ILOC

We first learn one useful option of gcc. Copy the following C source file to your

CS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September

ML 4 A Lexer for OCaml s Type System

Dr. Mohammad Nassiri

EE 422C HW 6 Multithreaded Programming

Homework Assignment #3

CS 455/655 Computer Networks Fall Programming Assignment 1: Implementing a Social Media App Due: Thursday, October 5 th, 2017 (1pm)

CSCI 3300 Assignment 7

Programming Assignment III

CSE 333 Midterm Exam 5/10/13

CS131 Compilers: Programming Assignment 2 Due Tuesday, April 4, 2017 at 11:59pm

Family Map Server Specification

a f b e c d Figure 1 Figure 2 Figure 3

CS 1044 Project 1 Fall 2011

CMSC 201 Spring 2019 Lab 06 Lists

Automated Agent Affiliation

CS 1653: Applied Cryptography and Network Security Fall Term Project, Phase 2

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Homework 3 (document version 1.2) Multi-threading in C using Pthreads

The input of your program is specified by the following context-free grammar:

Instructions PLEASE READ (notice bold and underlined phrases)

MP 3 A Lexer for MiniJava

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

Assignment 1. CSI Programming Practice, Fall 2011

Project 5 Handling Bit Arrays and Pointers in C

Transcription:

Program Assignment 2 CMSC 417 Fall 2014 September 16, 2014 1 Deadline September 30, 2014. 2 Objective In this assignment you will write the server program which will communicate using sockets with the client program provided by us. Your server program will operate according to the protocol described in the next chapter. Obviously, the protocol is trivial/useless, however, this exercise will get familiarize you with client/server programming and communication protocol. 3 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, common.h, provided for you. Figure 1: Protocol 1

The protocol has four types of messages: HELLO, STATUS, CLIENT BYE and SERVER BYE. Each message is an ASCII string, and consists of multiple fields separated by whitespace (space (0x20) or newline (0x0a) character). The MAXIMUM length of the string is 255. 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 CLIENT BYE message, and the server terminates the connection by sending a SERVER 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; 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: 1. HELLO (From the client to the server: Client Server) The HELLO message has 4 fields EXACTLY in the following order: It MUST set to be MAGIC STRING which is a constant defined in the header file ( cmsc417fall2014 ). If the client sends a message which does not start with this magic string, the message should be ignored by your server program. The type string is HELLO to indicate a message type HELLO. The server should be case-sensitive. Login ID This field is your cluster login ID. You will put your login ID as a argument when you execute the client program. Name The last field is your first name. Please do NOT put spaces in your name, even if it contains spaces. You will also put your name as a argument when you execute the client program. An example HELLO message might look like this: cmsc417fall2014 HELLO cs417000 Alice 2. STATUS (Server Client) The STATUS message has 4 fields in the following order: Same as above. Must be set to STATUS. Cookie An integer randomly generated by the server (represented in ASCII). Cookie generation is explained later. 2

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: cmsc417fall2014 STATUS 42 128.8.128.153:48522 3. CLIENT BYE (Client Server) The CLIENT BYE message has 3 fields in the following order: The same as above. Must be set to CLIENT BYE. Cookie A string of an integer, set to the value of the cookie sent by the server in the STATUS message for this connection. An example CLIENT BYE message would be: cmsc417fall2014 CLIENT BYE 42 4. SERVER BYE (Server Client) The SERVER BYE message has 2 fields in the following order: The same as above. Must be set to SERVER BYE. An example SERVER BYE message would be: cmsc417fall2014 SERVER BYE 4 Server Program The command line syntax for a minimal server is given below. The server will take the port as an argument. USAGE:./server [<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. 3

After successful communication, the server MUST print the cookie it generates along with the clients login id, first name, IP address and port number. All this information should be in a single line. An example is: 555 cs417050 Alice from 128.8.126.208:48542 Notice that ((128+8+126+208) 13 mod 1111) is 555. 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 clients IP address and port number also in a single line, as such: **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 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. The server should be able to serve multiple clients. It is acceptable if this is done serially. 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. You may use fflush(stdout); after every output to stdout. 5 Client Program The client program is provided. The command line syntax for the client is given below. The client program takes command line arguments corresponding to the login id and first name. The hostname and port specifications are optional. If included, they override the default definition of SERVER HOSTNAME and SERVER PORT in common.h. USAGE:./client [<hostname> [<port>]] <login id> <first name>./client heaving.csic.umd.edu 9999 csic417050 Alice 6 Requirement Your code must be -Wall clean on gcc. (For example, when you compile your code, try like this: gcc -o -Wall server server.c ) The TA will answer general questions/confusions only, and is not supposed to debug for you. The This is my code, what could be the problem type of questions will be ignored. 4

7 Hint Your server and client programs should run on the same linuxlab machine because we are not allowed to connect to other linuxlab machines. There are 4 remote login machines that you can use for your project: heaving.csic.umd.edu nauseated.csic.umd.edu emesis.csic.umd.edu sislatsirep.csic.umd.edu When you connect to linuxlab.csic.umd.edu, you will be connected to one of above machine automatically. In order to make sure that your client and server programs run on the same machine, you need to connect to one of 4 machines directly. Your files are shared on all the linuxlab machines so you don t need to worry about that. 8 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: zip server.zip server.c common.h 5