The Specification of Project-1

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

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

CIS 505: Software Systems

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

P2P Programming Assignment

CS 118 Project Phase 2 P2P Networking

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

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

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

6.824 Lab 2: A concurrent web proxy

Introduction to computer networking

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

EE122 Project 1 Fall 2010

A Client-Server Exchange

Programming Assignment 3

Project 1: A Web Server Called Liso

Network Software Implementations

2/13/2014. A protocol is an agreed-upon convention that defines how communication occurs between two (or more?) endpoints

Key Points for the Review

Project 3: Base64 Content-Transfer-Encoding

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

Programming Assignment 1

Assignment 1: tcpbridge

COMP/ELEC 429/556 Introduction to Computer Networks

Tutorial on Socket Programming

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

CMSC 417 Project Implementation of ATM Network Layer and Reliable ATM Adaptation Layer

ECE 650 Systems Programming & Engineering. Spring 2018

EE122 Project 1. Fall Version 0.4. Part A due at 11:50pm on Monday, October 11, 2010 Part B due at 11:50pm on Wednesday, October 27, 2010

CS 447 : Networks and Data Communications Programming Assignment #02 Total Points: 150

Figure 1: Graphical representation of a client-server application

Communication Networks

Outline. What is TCP protocol? How the TCP Protocol Works SYN Flooding Attack TCP Reset Attack TCP Session Hijacking Attack

TFTP and FTP Basics BUPT/QMUL

LESSON PLAN. Sub. Code & Name : IT2351 & Network Programming and Management Unit : I Branch: IT Year : III Semester: VI.

Socket Programming 2007/03/28

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

Creating a Shell or Command Interperter Program CSCI411 Lab

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur QUESTION BANK

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

QW5 - Remote Access Data Server

Simple network applications using sockets (BSD and WinSock) Revision 1 Copyright Clifford Slocombe

TRANSMISSION CONTROL PROTOCOL. ETI 2506 TELECOMMUNICATION SYSTEMS Monday, 7 November 2016

EECS122 Communications Networks Socket Programming. Jörn Altmann

New York University Computer Science Department Courant Institute of Mathematical Sciences

52 Remote Target. Simulation. Chapter

Chapter Two. The OSI Model

CS321: Computer Networks Introduction to Application Layer

USA North 811. Positive Response System Requirements

Protocol Specification Version 1.0 Shreyas Dube Smita Singhaniya Piyush Goswami Sowmya MD. Protocol Specification

CS 10: Problem solving via Object Oriented Programming. Client/Server

CSC209 Review. Yeah! We made it!

Enhancements Added support for VLProxy thread dumps in support bundles. Requires VersaLex or later.

Lab 2: Threads and Processes

Program Assignment 2

Programming Assignment 0

Programming Assignment 1

JADE TCP/IP Connection and Worker Framework

Homework 1: Programming Component Routing Packets Within a Structured Peer-to-Peer (P2P) Network Overlay VERSION 1.1

CS307 Operating Systems Processes

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State

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

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF MCA QUESTION BANK UNIT 1

Switch 2018 u3. What s New In Switch 2018u3.

Packet Sniffing and Spoofing

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

E&CE 454/750-5: Spring 2010 Programming Assignment 1 Due: 11:59 PM Friday 11 th June 2010

CS 455 / Computer Networks Fall Using an Echo Application to Measure TCP Performance Due: THURSDAY, October 2, 2014 (1pm)

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

Telnet/KSHELL NETIO M2M API protocols docs

A Generic Multi-node State Monitoring Subsystem

Computer Networks Prof. Ashok K. Agrawala

Reference Models. 7.3 A Comparison of the OSI and TCP/IP Reference Models

Lecture 24. Thursday, November 19 CS 375 UNIX System Programming - Lecture 24 1

EEC-682/782 Computer Networks I

UNIT V. Computer Networks [10MCA32] 1

Last Time. Internet in a Day Day 2 of 1. Today: TCP and Apps

Avaya Port Matrix: Avaya Proprietary Use pursuant to the terms of your signed agreement or Avaya policy.

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

ELEC5616 COMPUTER & NETWORK SECURITY

Programming Project #2

Peer to Peer Instant Messaging

Homework 3 CSC/ECE , Fall, 2016

CS 450 Introduction to Networking Spring 2014 Homework Assignment 1 File Transfer and Data Bandwidth Analysis Tool

Operating Systems and Networks Project 1: Reliable Transport

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

CS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm

Network Programming in Python. based on Chun, chapter 2; plus material on classes

COMP 321: Introduction to Computer Systems

z/tpf Communications Enhancements

Assignment 1: Communicating with Programs

CS321: Computer Networks Socket Programming

The Norwegian text is authoritative, this translation is provided for your convenience.

COMP/ELEC 429/556 Project 2: Reliable File Transfer Protocol

Request for Comments: 851 Obsoletes RFC: 802. The ARPANET 1822L Host Access Protocol RFC 851. Andrew G. Malis ARPANET Mail:

CS344/444 Spring 2007 Project 1 Instant Messaging Client and Server

CS11 C++ DGC. Spring Lecture 6

CS4514 (C04) HELP Session 1 Introduction to Network Programming (v1.3)

Transcription:

The Specification of Project-1 EE122 Introduction to Communication Networks, Fall 2002 Weidong Cui, Karthik Lakshminarayanan, Khian Hao Lim Revision : 1.23 1 Overview In this project, you will build a chat service with a client-server architecture in project groups of two. Your job is to write server and client software in C or C++ that fulfils our requirements and handles errors gracefully. Your implementation is required to use TCP sockets for communication. Implementation and testing should be done on the unix instructional machines. Instructional support will be available only for programs written and tested on these machines. The list of chat functionalities you are required to implement is a small subset of the possible ones in a typical Internet Relay Chat service. However, you will be exposed to most of the networking components typically used. 2 Main Components Server: Usage: chatserver <port> The single-threaded chatserver listens at a known host and port, listening to new connections from clients, accepting them and handling the commands (refer to section 5) sent from each client. Each chatclient sends a message to the chatserver periodically to inform the server that it is alive. The chatserver can concurrently have up to MAXNUMCLIENTS chatclients using its chatservice (if this state is reached, we call the chatserver full ). When a chatclient requests to take part in the chatservice run by a chatserver which is already full, its request will be rejected. The chatserver must handle all possible errors and remain alive until explicitly terminated (e.g., by its user typing Ctrl-C). Client: Usage: chatclient <server address> <server port> <username> Once started, the single-threaded chatclient connects to the chatserver with a unique username not already used by any clients connected to the chatserver. It then reads user input from standard input and sends commands to the server. It also receives and handles commands from the server. If the chatclient perceives any possible error from the server, it will shut down with an informative message. 3 Implementation Constraints Fixed Header Code A header file, chat.h, a README and a Makefile are provided. Parts of the code in chat.h must not be changed. These parts are indicated by comments in the code. The README is provided with questions that you need to answer for submission. It mostly has to do with the conditions under which you have tested your programs and the names of the instructional machines you tested them on. Revision : 1.23 1

Sample Input and Output A set of inputs and outputs for a sample session is given for reference. The session demonstrates the exchange between 2 chatclients and a chatserver. It includes five files: chatclient1.in, chatclient1.out, chatclient2.in chatclient2.out, and chatserver.out. Defined Numbers chat.h contains values which are already fixed. They include: /* the maximum number of clients */ MAXNUMCLIENTS = 255; /* the maximum length of a username in bytes */ MAXNAMELEN = 255; /* the period within which chatclient needs to send Command Keep Alive s (in seconds) */ KEEP ALIVE PERIOD = 60; These are to be used in writing your programs. You are not to hardcode the numerical values into your programs. Various byte offsets are also defined for your convenience. Printing to Stdout and Stderr In the following sections, we specify the output your program should print in different circumstances. Unless otherwise stated, each line should end with a newline and be flushed. The delimitor between each word of your input and output should be a single space. All the output specified in this document is done to stdout. Since we will be using stdout for testing, you must ensure that only the specified output goes there. We do not specify the format of output to stderr. However, judicious use of stderr makes for more elegant error handling. Some suggestions for output to stderr are responses to socket connect errors, socket read errors, and invalid packet format. 4 User Input User input (which we call UserInput) is obtained from standard input. Each UserInput fits into a single line and the chatclient processes the UserInput when the user types <Enter> key. If user input does not conform to any of the following, chatclient prints the following to stdout and the non-conforming UserInput is ignored. incorrect userinput format The possible UserInputs are: 1. UserInput Message Function: Sends a message from this chatclient to other chatclients connected to the chatserver using the names specified in this UserInput. Specifying a username more than once for this UserInput is fine but the chatserver must ensure that the chatclient in question will only receive the message once. Format: /mesg number of receivers username 1 username 2... username n message 2. UserInput List Function: Format: 3. UserInput Help List all the usernames of chatclients connected to the chatserver. /list Function: List all the commands possible for this chatclient. The chatclient prints a list of possible UserInputs to stdout. Revision : 1.23 2

Format: /help You can use any format to print the list of commands to stdout. This command is for the sake of completeness of the chatclient. 4. UserInput Quit Function: Closes the connection from this chatclient to the chatserver. Chatclient prints the following to stdout and terminates. quitting chatclient gracefully Format: /quit 5 Protocol A command is the basic unit of data transfer between a server and each client. There are four distinct packet formats for this protocol. The formats along with the size of each field are illustrated in Figure 1, Figure 2, Figure 3 and Figure 4. The Type field (first 2 bytes) identifies the command. The Length field refers to the length of the application layer portion of the packet (i.e., not including the TCP/IP portion), and the Num field refers to the number of usernames that follow in the List of Users. Each Username field in the packet format does not include the \0 ending and the corresponding Length field counts the number of bytes for the Username excluding the \0 at the end. The chatclient also removes the newline (that it reads from stdin) while filling the message field that it includes with a Command Message. The numbers in the packet are in network byte order (refer to htonl(3), htons(3), ntohl(3) and ntohs(3) 1 ). The type numbers for different types of packets are defined in chat.h. Do not change them. Type Length Figure 1. Basic Packet Format Type Length User Name Figure 2. Join Packet Format Type Length List of Users 1 1 Len1 1 Len2 1 LenK Num Len1 UserName1 Len2 Username2... LenK UsernameK Figure 3. List Packet Format Type Length List of Users Message 1 1 Len1 1 Len2 1 LenK Num Len1 UserName1 Len2 Username2... LenK UsernameK Message Figure 4. Message Packet Format The following are the list of commands as identified by the Type field. 1 The number in parenthesis is the Unix man page on which documentation of the command resides. Revision : 1.23 3

1. Command Join: Packet Format: Use the Join packet format (Figure 2). Sender action: This is the first command that the chatclient sends to the chatserver and is a request to join the chat service. The requested username is also sent in this command. Receiver action: When the chatserver receives this packet, one of the following situations could arise: (a) The chatserver allows the chatclient to join and does not send any response. Chatserver prints the following to stdout: join: <source user name> (b) The name is already in use by one of the other chatclients who joined the chatserver, then the chatserver sends a Command Error Name Used command. Chatserver prints the following to stdout: disconnected: <user name> existing user name (c) The server is already full. If the server already has MAXNUMCLIENTS connected to it, it should accept the new connection, send back a Command Error Server Full to the client, and close the connection. The chatserver prints the following to stdout: disconnected: server full (d) An erroneous scenario occurs when the first command that a chatclient sends to the chatserver is not Command Join. This is treated as a command type that the chatserver does not recognize and is handled by Command Error Unknown Command. The actions performed are explained in Command Error Unknown Command section. 2. Command List Request: Sender action: Upon receiving UserInput List, chatclient sends this to the server. Receiver action: Upon receipt, the chatserver responds by sending back a Command List Reply containing the list of usernames of chatclients connected to the chatserver. The chatserver also prints the following to stdout: list request: <source user name> 3. Command List Reply: Packet Format: Use the List packet format (Figure 3). Sender action: Upon receiving Command List Request, the chatserver responds by sending this command back, which contains a list of user names of all clients that have connected to the chatserver, including the one that sent the Command List Request. Receiver action: The chatclient prints out the list of users in to stdout as follows: list: <user name 1> <user name 2>... <user name k> 4. Command Message: Packet Format: Use the Message packet format (Figure 4). Sender action: When the user types UserInput Message, the chatclient sends this command. Usernames that are repeated on the UserInput Message may be forwarded as well. Revision : 1.23 4

Receiver action: The chatserver responds by forwarding the message using Command Message Forward to all the clients with usernames listed in this command. The chatserver ensures that the chatclient whose username is repeated gets Command Message Forward only once. The chatserver prints the following to stdout: mesg: <source user name> For each username that does not correspond to a chatclient, chatserver prints the following to stdout: mesg: <source user name> to nonexistent user <non existent user> 5. Command Message Forward: Packet Format: Use the Message packet format (Figure 4). There should be exactly one username specified in the List of Users in the packet. This is the username of the sender. Sender action: Upon receiving Command Message, the chatserver sends this command, containing the message, to each of the clients whose usernames are listed in the Command Message command. Any username which does not correspond to a user is ignored. Any client whose username appears in the list will receive the message once regardless of the number of times his username appears in the Command Message command. Receiver action: The chatclient prints the following to stdout: mesg: <source user name>: <message text> 6. Command Keep Alive: Sender action: Chatclient sends this command every KEEP ALIVE PERIOD (now set to 60) seconds to the server to inform the chatserver that it is still alive. (Think about why you would need this). Receiver action: The chatserver refreshes the connection to this chatclient and it prints the following to stdout: keep alive: <source user name> If the chatserver does not receive a Command Keep Alive from a client for a long period (say, for twice the KEEP ALIVE PERIOD), it closes its connection to the client and releases any state associated with that client. It also prints out the following to stdout: disconnected: <user name> no keep alive 7. Command Error Unknown Command: Sender action: Upon receiving a command type that the chatserver does not recognize, or a format that does not conform to the packet format stipulated, or a command from a chatclient who has not joined yet (refer to Command Join), the chatserver sends this command to the client, closes the connection and drops any state held for that client. Chatserver prints the following to stdout: disconnected: <user name> sent unknown command Receiver action: Upon receiving this, chatclient prints out an error, closes the connection to the server, and shuts down. The chatclient prints the following to stdout: disconnected: server received unknown command 8. Command Error Server Full: Revision : 1.23 5

Sender action: When there are already MAXNUMCLIENTS connected to the chatserver and it receives a new connection, it sends this command and closes the connection. Receiver action: Upon receiving this command, the chatclient prints out a message, closes the connection, and shuts down. Chatclient prints the following to stdout: disconnected: server full 9. Command Error Name Used: Sender action: Upon receiving a Command Join from a chatclient that gives a username that is in use by one of the chatclients already connected to the server, the chatserver sends this command back. The chatserver then closes the connection and removes any state for this chatclient. Receiver action: Upon receiving this command, the chatclient prints out a fixed message, closes the connection and shut down. Chatclient prints the following to stdout: disconnected: name in use 6 Other Protocol and Printing Issues Ending Chatservice The chatclient quits after receiving UserInput Quit. The chatclient simply closes the TCP socket to the chatserver and exits. The corresponding socket on the chatserver side will read 0 bytes and understand that the chatclient has left the chatserver. Under this condition and other socket errors, the chatserver prints the following to stdout: disconnected: <user name> closed connection Under this condition and other socket errors, the chatserver closes the TCP socket and removes the state for that particular chatclient. 7 Implementation Suggestions Standardized Types and Definitions chat.h contains typedefs and defines for some standardized types often used in socket programming. It is useful to stick with these typedefs. Of course, you are free to use your own definitions. Execution Model Because the programs are single threaded, they must not block on reads or writes for sockets or standard input. I/O should be non-blocking. Socket and file descriptor activity (standard input and output streams are controlled by file descriptors as well) should be detected through the select(2) system call. Chapter 6 of Unix Network Programming by W. Richard Stevens addresses many of the issues you will need to understand. Socket Programming API Some functions you probably need to know well include: open(2), close(2), connect(2), setsockopt(2), fcntl(2), connect(2), listen(2), select(2), socket(2), accept(2), bind(2), htons(3), htonl(3), ntohs(3), ntohl(3), gethostbyname(3), gettimeofday(2), perror(3). Start Early This cannot be stressed enough. Revision : 1.23 6

8 Checkpoint In order to monitor your progress, we decided to have a checkpoint version submitted by Oct 2 before 11.59 pm. Subsequently, there will be a meeting with a TA who will check on the progress of your project. Your chatserver and chatclient must demonstrate part of the functionality of the final version, namely it has to handle the following functionalities: UserInput Quit UserInput Help Command Keep Alive Command Join Command Error Server Full Command Error Name Used In short, for the checkpoint your chatserver must be able to demonstrate the ability to handle normal and error conditions for new connections. And your chatclient must be able to demonstrate the ability to connect to a chatserver and remain alive. It must also quit gracefully after receiving UserInput Quit or other errors like Command Error Name Used or Command Error Server Full. 9 Testing You must ensure that your chatserver and chatclient implementation meets the following requirements. Consistent with our specification: Your chatclient and chatserver must be able to work with other chatclients and chatservers that implement the same set of protocols. Your implementations will be cross tested with other implementations for compatibility. Handles errors gracefully: Your programs should do their best to continue function correctly despite nonspecified behavior. For example, regardless of incorrect input, your chatserver should never crash or hang. Your implementations will be tested with erroneous input to ensure graceful handling of errors. 10 Submission Project submission will be done as in other classes. To submit the checkpoint, use the following command: % submit proj1-checkpoint To submit the final version of your project, use the following command: % submit proj1 The class website and newsgroup will be the official authority for information on submission or due dates. The files required for submission include the files that we have provided you. The questions in README should be answered as well. Revision : 1.23 7