Introduction to computer networking

Similar documents
Socket programming. Complement for the programming assignment INFO-0010

New York University Computer Science Department Courant Institute of Mathematical Sciences

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

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

COMP90015: Distributed Systems Assignment 1 Multi-threaded Dictionary Server (15 marks)

P2P Programming Assignment

: Distributed Systems Principles and Paradigms Assignment 1 Multithreaded Dictionary Server

Protocols SPL/ SPL

CS 118 Project Phase 2 P2P Networking

Peer to Peer Instant Messaging

Assignment, part1: feedback and common mistakes. INFO-0010 Samuel HIARD

Web Server Project. Tom Kelliher, CS points, due May 4, 2011

The Specification of Project-1

INF3190 Mandatory Assignment:

CIS 505: Software Systems

Distributed Systems. Client-Server Communication: Exercises

TCP/IP Transport Layer Protocols, TCP and UDP

COMS3200/7201 Computer Networks 1 (Version 1.0)

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

CCNA 1 Chapter 7 v5.0 Exam Answers 2013

Assignment, part 2. Statement and concepts INFO-0010

Networking Applications

Assignment 3 ITCS-6010/8010: Cloud Computing for Data Analysis

TRIBHUVAN UNIVERSITY INSTITUTE OF ENGINEERING PULCHOWK CAMPUS DEPARTMENT OF ELECTRONICS AND COMPUTER ENGINEERING. A Report On MARRAIGE

TFTP and FTP Basics BUPT/QMUL

Socket Programming Assignment 6: Video Streaming with RTSP and RTP

Assignment 2 CISC 650 Computer Networks Fall 2016 Due Date: 10/9/ :59PM ET Total Points: 100

Example packages from Java s standard class library:

To gain experience using GUI components and listeners.

CSC 2209: CLOUD STORAGE FINAL PROJECT

Homework 3 CSC/ECE , Fall, 2016

Lab 2: Threads and Processes

Remote Invocation. Today. Next time. l Overlay networks and P2P. l Request-reply, RPC, RMI

Assignment 1. Due date February 6, 2007 at 11pm. It must be submitted using submit command.

Advances in Programming Languages: Exam preparation and exam questions

Internet Layers. Physical Layer. Application. Application. Transport. Transport. Network. Network. Network. Network. Link. Link. Link.

ITEC 350: Introduction To Computer Networking Midterm Exam #2 Key. Fall 2008

CMPSCI 187 / Spring 2015 Hanoi

Lab 5 Classy Chat. XMPP Client Implementation --- Part 2 Due Oct. 19 at 11PM

4. The transport layer

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM

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

CSE 461: Computer Networks John Zahorjan Justin Chan Rajalakshmi Nandkumar CJ Park

Guide to TCP/IP, Third. Chapter 6: Basic TCP/IP Services

Homework 1. Hadachi&Lind October 25, Deadline for doing homework is 3 weeks starting from now due date is:

Thrift specification - Remote Procedure Call

Programming Assignment #1 (Java)

JADE TCP/IP Connection and Worker Framework

Assignments 3 & 4. COMP248/Winter Assignment 3 & 4 Page 1 of 7

Programming Assignment 1

Internet Technology. 06. Exam 1 Review Paul Krzyzanowski. Rutgers University. Spring 2016

Internet Technology 3/2/2016

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

6.824 Lab 2: A concurrent web proxy

Programming Assignment 0

Programming Assignment III

COE 518 Operating Systems. Lab 10

Lab 10: Sockets 12:00 PM, Apr 4, 2018

Project 2 Reliable Transport

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

AS COMPUTERS AND THEIR USER INTERFACES have become easier to use,

Programming Assignment 1

CHAPTER 2. Troubleshooting CGI Scripts

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

Name Student ID Department/Year. Final Examination. Introduction to Computer Networks Class#: Fall :20-11:00 Tuesday January 13, 2004

TUTORIAL FOR UW NETWORK CODING USING OPNET AND MATLAB

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

An ios Static Library for Service Discovery and Dynamic Procedure Calls

[MS-SNID]: Server Network Information Discovery Protocol. Intellectual Property Rights Notice for Open Specifications Documentation

Computer Networks - A Simple HTTP proxy -

[MS-SNID-Diff]: Server Network Information Discovery Protocol. Intellectual Property Rights Notice for Open Specifications Documentation

Java Support for developing TCP Network Based Programs

ch02 True/False Indicate whether the statement is true or false.

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

Seminar report Java Submitted in partial fulfillment of the requirement for the award of degree Of CSE

BEAAquaLogic. Service Bus. Native MQ Transport User Guide

[MS-WINSRA]: Windows Internet Naming Service (WINS) Replication and Autodiscovery Protocol

JAVA Network API. 2 - Connection-Oriented vs. Connectionless Communication

CSCI 466 Midterm Networks Fall 2013

Figure 1: Graphical representation of a client-server application

Multi-threaded Web Server (Assignment 1) Georgios Georgiadis

Network Intrusion Detection Systems. Beyond packet filtering

CS244a: An Introduction to Computer Networks

COMP 321: Introduction to Computer Systems

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

Interprocess Communication

Australian Informatics Olympiad Thursday 23 August, Information Booklet

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

Project 3: RPN Calculator

CSE 123: Computer Networks

Lab Assignment 3 for ECE374

SPDY - A Web Protocol. Mike Belshe Velocity, Dec 2009

Java RMI Middleware Project

Lecture 2: Links and Signaling

Task 2: TCP Communication

ASSIGNMENT TWO: PHONE BOOK

CMSC 322 Computer Networks Applications and End-To- End

BEAAquaLogic. Service Bus. MQ Transport User Guide

4 rd class Department of Network College of IT- University of Babylon

Official Competition Manual March 2, 2005

Transcription:

Introduction to computer networking First part of the assignment Academic year 2017-2018 Abstract In this assignment, students will have to implement a client-server application using Java Sockets. The server is a game platform, i.e. it allows a user to play the game of Mastermind. The client will interact with the user to display the game status and ask for new combination, and discuss with the server to verify the combination guessed by the user, or to request a new game. Students will work alone using the Java language. Sections 1 and 2 define your assignment objectives. Sections 3 and further are an executive summary of the technologies we use. The Hard Deadline is March, 25 th, 2018. 1 Mastermind platform As stated in the abstract, you will implement a Mastermind platform using Java Sockets. The server waits for TCP connections on a given port, receives requests through that connection when established, potentially updates its internal state accordingly, and Image taken from www.amazon.com 1

responds with a formatted response following the custom-made Mastermind protocol. The server will be up for new connections and be able to handle concurrency. Each client plays its own game. The session scope is the TCP connection (identified by the client IP address and port). The client will interact with the user using terminal I/Os, send requests to the server, read its responses, and update its display accordingly. Figure 1 shows an example of a potential output from the client, interacting with the user and with the server. Figure 1: Example of a potential console output. 1.1 Rules On game start, the server will select a combination of 4 colors at random from 6 possible ones. A color can be chosen several times in a combination. At each iteration, the user selects a combination that (s)he thinks might be the secret one. The client software can help the user build its combination and send it to the server. The server responds with the number of colors in the correct spot, as well as the number of colors that are in the secret combination, but not in the correct spot. The game ends either when the combination has been discovered successfully, or when the combination wasn t found in 12 tries, or if the user quits prematurely. 2

1.2 Launch The software is invoked on the command line with no additional arguments: java MastermindServer for the server and java MastermindClient for the client. The server listens on port 2xxx where xxx are the last three digits of your ULg ID. 1.3 Incorrect or incomplete commands When dealing with network connections, you can never assume that the other side will behave as you expect. It is thus your responsibility to check the validity of the client s request (and respond with the appropriate error code if something goes wrong) and to ensure that a malevolent person won t make your server freeze by initiating a TCP connection and keeping it open for an indefinite period of time (see Section 4 for a counter-measure). 2 Guidelines You will implement the programs using Java 1.8, with packages java.lang, java.io, java.net and java.util, You will ensure that your program can be terminated at any time simply using CTRL+C, and avoid the use of ShutdownHooks You will not manipulate any file on the local file system. You will ensure your main class is named MastermindServer (resp. Mastermind- Client), located in MastermindServer.java (resp. MastermindClient.java) at the root of the archive, and does not contain any package instruction. On the server output console, you will display the selected random combination, for easier testing. You will not cluster your program in packages or directories. All java files should be found in the same directory. You will ensure that your program is fully functional (i.e. compilation and execution) on the student s machines in the lab (ms8xx.montefiore.ulg.ac.be). Submissions that do not observe these guidelines could be ignored during evaluation. 3

Your commented source code will be delivered no later than 25th of March (Hard deadline) to the Montefiore Submission platform (http://submit.run.montefiore. ulg.ac.be/) as a.zip package. Your program will be completed with a.pdf report (in the zip package) addressing the following points: Software architecture: How have you broken down the problem to come to the solution? Name the major classes and methods responsible for requests processing. Multi-thread coordination: How have you synchronized the activity of the different threads? Limits: Describe the limits of your program, esp. in terms of robustness. Possible Improvements: This is a place where you re welcome to describe missing features or revisions of these specifications that you think would make the server richer or more user-friendly. 3 The Mastermind Protocol The Mastermind Protocol (MP) is a custom-made protocol designed for this assignment only. This protocol is binary-oriented, meaning that all exchanges are custom packed and not intended to be human-readable (as opposed to text-oriented protocols such as HTTP that is based on readable lines of text). Each request and reply is made of a header of 2 bytes, possibly followed by more data. Figure 2 is a visual summary of the protocol. 3.1 MP Header For each new request and each response, the message is preceded by a header of 2 bytes. The description of each byte follows. 1. A version number, allowing several versions of the protocol to be supported. In this assignment, the protocol version is 1. 2. A number identifying the type of message. 3.2 MP Method field The second field in the header determines the meaning of the request/response type. The possible values, and their meaning, are described in the following subsections. 4

3.2.1 Client requests 0 : Request a new game. 1 : Request the analysis of a combination. The four colors are given after the header. Each color is represented by a number encoded in one byte (0 = red, 1 = blue, 2 = yellow, 3 = green, 4 = white, 5 = black). 2 : Request the list of already proposed combinations and, for each one, the number of good and well placed colors, and the number of good but misplaced colors. 3.2.2 Server response 1 : A new game was started. 2 : The combination was received. The following two bytes indicate how many colors were good and well placed, and how many colors were good but in the wrong place, in that order. 3 : List request received. The next byte indicates how many combinations were already tested. For each one, the reponses contains 6 additional bytes : 4 bytes for the proposed combination, 2 bytes for its "correctness". 4 : Request error. Figure 2: Summary of the Mastermind Protocol. 5

4 Multi-Threading A very simple solution for the server s code would be to accept a connection, handle the request, then go back to accepting new connections, and so forth. Now, imagine that a client behaves badly and sends an incomplete request. server would then be blocked and would not be able to handle new connections. The A simple solution to handle this problem is to separate the code logic into separate threads. The main thread will loop on the accept() method and, when it succeeds, forward the task to a new Thread. That way, even if one client is erroneous, it will only impact one of the server s Threads and other clients will be served correctly. We will see in the second part of the assignment that this method also has a flaw, but will be considered as acceptable for this first part. 5 Stream-oriented protocols (TCP) The MP protocol relies on the TCP protocol, which is stream-oriented. This has at least three implications: 1. You can be sure that the connection is lossless and that there won t be any packet re-ordering. 2. The sender could be buffering the output, i.e. the data that is requested to be sent might not have been effectively sent yet. This can be solved by calling the flush() method on the OutputStream. 3. The data requested to be sent with one call to a write method will not necessarily be received with only one read method from the other side. Several reads could be necessary to recover the entire information. This is because we are reading from a stream, we are not reading messages (as we would with UDP, for instance). We thus have to find a way to delimit message boundaries on the stream. MP achieves this by having a constant-size header, whose "type" field determines how many bytes, if any, will follow. Good programming... 6