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

Similar documents
CSE434 Computer Networks (FALL, 2009) Programming Assignment 2 Due: Wed, October 7, 2009

Java Socket Workshop. July Purpose of this workshop:

Principles, Models and Applications for Distributed Systems M

Network Programming. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff

CSCD 330 Network Programming Spring 2018

Java Networking (sockets)

CSCD 330 Network Programming Winter 2019

Programming Assignment 1

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

Advanced Java Programming. Networking

Networking Basics. network communication.

Interprocess Communication

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

CPSC 441 UDP Socket Programming. Department of Computer Science University of Calgary

Chapter 2 Applications and

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

CSCD 330 Network Programming Spring 2018

Programming Assignment 1

Problems of IP. Unreliable connectionless service. Cannot acquire status information from routers and other hosts

UDP Sockets TCP guarantees the delivery of packets and preserves their order on destination. Sometimes these features are not required, since they do

Lab 1 - Reliable Data Transport Protocol


Chapter 9: UDP sockets & address conversion function

Layer 4 - Transport Layer. What do we need a Transport Layer for? Transport Protocols in the TCP/IP Reference Model. The Transport Layer TCP and UDP

Transport layer protocols. Lecture 15: Operating Systems and Networks Behzad Bordbar

Outlines. Networking in Java. Internet hardware structure. Networking Diagram. IP Address. Networking in Java. Networking basics

Layer 4 - Transport Layer

Introduction to Sockets 9/25/14

Computer Communications and Networks (COMN), 2017/18, Semester 1

Communication in Distributed Systems: Sockets Programming. Operating Systems

JAVA SOCKET PROGRAMMING

Communication Paradigms

Multi-threaded Web Server (Assignment 1) Georgios Georgiadis

User Datagram Protocol

Unix Network Programming

Lecture 3: Socket Programming

JAVA - NETWORKING (SOCKET PROGRAMMING)

CPSC 441 Assignment-3 Discussion. Department of Computer Science University of Calgary

Interprocess Communication

User Datagram Protocol(UDP)

Networking: IPv6, UDP and TCP. Network Programming in Java UDP and TCP

COMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming

CS 326: Operating Systems. Networking. Lecture 17

SNMP traps (simple network management protocol)

Project 0. Danyang Zhuo CSE sp Sec;on #2

Problem Set 7 Due: Start of Class, November 2

Configure IP SLA Tracking for IPv4 Static Routes on an SG550XG Switch

Chapter 11. Application-Layer Elements Ports

CPSC 441 Tutorial - 11 UDP Socket Programming Department of Computer Science University of Calgary

Basic Java Network Programming. CS211 July 30 th, 2001

CSS 533 Program 2: Distributed Java Space Servers Professor: Munehiro Fukuda Due date: see the syllabus

UNIT IV -- TRANSPORT LAYER

Operating Systems and Networks Project 1: Reliable Transport

OBJECT ORIENTED PROGRAMMING

Department of Computer Science and Engineering. Final Examination. Instructor: N. Vlajic Date: April 15, 2011

Project #1 Computer Science 2334 Fall 2008

TCP and Concurrency. The third assignment at DA

CS September 2017

Networking and Security

Applied Networks & Security

Chapter 2 outline. 2.1 Principles of app layer protocols

Chapter 2 Application Layer

Distributed Systems. 3. Access to the Transport Layer. Werner Nutt

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

II. Principles of Computer Communications Network and Transport Layer

Socket Programming Assignment 6: Video Streaming with RTSP and RTP

IT 341: Introduction to System

Table of Contents 1 System Maintaining and Debugging Commands 1-1

PLEASE READ CAREFULLY BEFORE YOU START

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

MIDTERM EXAMINATION #2 OPERATING SYSTEM CONCEPTS U N I V E R S I T Y O F W I N D S O R S C H O O L O F C O M P U T E R S C I E N C E

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

05 Transmission Control Protocol (TCP)

Chapter 6. What happens at the Transport Layer? Services provided Transport protocols UDP TCP Flow control Congestion control

416 Distributed Systems. Networks review; Day 2 of 2 Fate sharing, e2e principle And start of RPC Jan 10, 2018

Project 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently.

CPSC 441 Assignment-3 Discussion. Department of Computer Science University of Calgary

Reliable File Transfer

CSE 461 Module 11. Connections

PLEASE READ CAREFULLY BEFORE YOU START

Mobile Transport Layer Lesson 02 TCP Data Stream and Data Delivery

Network Management & Monitoring

You should see something like this, called the prompt :

Distributed Systems Recitation 2. Tamim Jabban

ICS 351: Networking Protocols

New York University Computer Science Department Courant Institute of Mathematical Sciences

CS 118 Project Phase 2 P2P Networking

Transport Layer (TCP/UDP)

C19: User Datagram and Multicast

Table of Contents 1 System Maintenance and Debugging Commands 1-1

Chapter 2: outline. 2.1 principles of network applications. 2.6 P2P applications 2.7 socket programming with UDP and TCP

estadium Project Lab 2: Iperf Command

PLEASE READ CAREFULLY BEFORE YOU START

PLEASE READ CAREFULLY BEFORE YOU START

Short answer (35 points)

Lecture 20 Overview. Last Lecture. This Lecture. Next Lecture. Transport Control Protocol (1) Transport Control Protocol (2) Source: chapters 23, 24

Info 408 Distributed Applications programming 2 nd semester of Credits: 5 Lecturer: Dr. Antoun Yaacoub

Kent State University

Different Layers Lecture 20

public static void main(string[] args) throws IOException { sock = new Socket(args[0], Integer.parseInt(args[1]));

Transcription:

Assignment 1 Due date February 6, 2007 at 11pm. It must be submitted using submit command. Note: submit 4213 a1 <filename>. Read the manpages ("man submit") for more details on the submit command. It is not be possible to submit the files after the deadline. You must submit a report containing answers to all the questions. For programming question you must put your source codes into the report and submit the source files via submit command. Questions 1. Problem P13 of Chapter 1 (10 marks) 2. Problem P10 of Chapter 4 (10 marks) 3. Wireshark Lab of Chapter 4 (15 marks) (http://www.cse.yorku.ca/course/4213/assignment1/wireshark_ip.pdf) 4. Programming Assignment (65 marks) UDP Pinger In this assignment, you will study a simple Internet ping server written in the Java language, and implement a corresponding client. The functionality provided by these programs are similar to the standard ping programs available in modern operating systems, except that they use UDP rather than Internet Control Message Protocol (ICMP) to communicate with each other. (Java does not provide a straightforward means to interact with ICMP.) The ping protocol allows a client machine to send a packet of data to a remote machine, and have the remote machine return the data back to the client unchanged (an action referred to as echoing). Among other uses, the ping protocol allows hosts to determine round-trip times to other machines. You are given the complete code for the Ping server below. Your job is to write the Ping client. Server Code The following code fully implements a ping server. You need to compile and run this code. You should study this code carefully, as it will help you write your Ping client. import java.io.*; import java.net.*; import java.util.*; 1

/* * Server to process ping requests over UDP. */ public class PingServer { private static final double LOSS_RATE = 0.3; private static final int AVERAGE_DELAY = 100; // milliseconds public static void main(string[] args) throws Exception { // Get command line argument. if (args.length!= 1) { System.out.println("Required arguments: port"); return; int port = Integer.parseInt(args[0]); // Create random number generator for use in simulating // packet loss and network delay. Random random = new Random(); // Create a datagram socket for receiving and sending UDP packets // through the port specified on the command line. DatagramSocket socket = new DatagramSocket(port); // Processing loop. while (true) { // Create a datagram packet to hold incomming UDP packet. DatagramPacket request = new DatagramPacket(new byte[1024], 1024); // Block until the host receives a UDP packet. socket.receive(request); // Print the recieved data. printdata(request); // Decide whether to reply, or simulate packet loss. if (random.nextdouble() < LOSS_RATE) { System.out.println(" Reply not sent."); continue; // Simulate network delay. Thread.sleep((int) (random.nextdouble() * 2 * AVERAGE_DELAY)); // Send reply. 2

InetAddress clienthost = request.getaddress(); int clientport = request.getport(); byte[] buf = request.getdata(); DatagramPacket reply = new DatagramPacket(buf, buf.length, clienthost, clientport); socket.send(reply); System.out.println(" Reply sent."); /* * Print ping data to the standard output stream. */ private static void printdata(datagrampacket request) throws Exception { // Obtain references to the packet's array of bytes. byte[] buf = request.getdata(); // Wrap the bytes in a byte array input stream, // so that you can read the data as a stream of bytes. ByteArrayInputStream bais = new ByteArrayInputStream(buf); // Wrap the byte array output stream in an input stream reader, // so you can read the data as a stream of characters. InputStreamReader isr = new InputStreamReader(bais); // Wrap the input stream reader in a bufferred reader, // so you can read the character data a line at a time. // (A line is a sequence of chars terminated by any combination of \r and \n.) BufferedReader br = new BufferedReader(isr); // The message data is contained in a single line, so read this line. String line = br.readline(); // Print host address and data received from it. System.out.println( "Received from " + request.getaddress().gethostaddress() + ": " + new String(line) ); The server sits in an infinite loop listening for incoming UDP packets. When a packet comes in, the server simply sends the encapsulated data back to the client. 3

Packet Loss UDP provides applications with an unreliable transport service, because messages may get lost in the network due to router queue overflows or other reasons. In contrast, TCP provides applications with a reliable transport service and takes care of any lost packets by retransmitting them until they are successfully received. Applications using UDP for communication must therefore implement any reliability they need separately in the application level (each application can implement a different policy, according to its specific needs). Because packet loss is rare or even non-existent in typical campus networks, the server in this lab injects artificial loss to simulate the effects of network packet loss. The server has a parameter LOSS_RATE that determines which percentage of packets should be lost. The server also has another parameter AVERAGE_DELAY that is used to simulate transmission delay from sending a packet across the Internet. You should set AVERAGE_DELAY to a positive value when testing your client and server on the same machine, or when machines are close by on the network. You can set AVERAGE_DELAY to 0 to find out the true round trip times of your packets. Compiling and Running Server To compile the server, do the following: javac PingServer.java To run the server, do the following: java PingServer port where port is the port number the server listens on. Remember that you have to pick a port number greater than 1024, because only processes running with root (administrator) privilege can bind to ports less than 1024. Note: if you get a class not found error when running the above command, then you may need to tell Java to look in the current directory in order to resolve class references. In this case, the commands will be as follows: java -classpath. PingServer port Your Job: The Client (35 marks) You should write the client so that it sends 10 ping requests to the server, separated by approximately one second. Each message contains a payload of data that includes the keyword PING, a sequence number, and a timestamp. After sending each packet, the client waits up to one second to receive a reply. If one seconds goes by without a reply 4

from the server, then the client assumes that its packet or the server's reply packet has been lost in the network. Hint: Cut and paste PingServer, rename the code PingClient, and then modify the code. You should write the client so that it starts with the following command: java PingClient host port where host is the name of the computer the server is running on and port is the port number it is listening to. Note that you can run the client and server either on different machines or on the same machine. The client should send 10 pings to the server. Because UDP is an unreliable protocol, some of the packets sent to the server may be lost, or some of the packets sent from server to client may be lost. For this reason, the client can not wait indefinitely for a reply to a ping message. You should have the client wait up to one second for a reply; if no reply is received, then the client should assume that the packet was lost during transmission across the network. You will need to research the API for DatagramSocket to find out how to set the timeout value on a datagram socket. When developing your code, you should run the ping server on your machine, and test your client by sending packets to localhost (or, 127.0.0.1). After you have fully debugged your code, you should see how your application communicates across the network with a ping server run by another member of the class. Message Format The ping messages in this lab are formatted in a simple way. Each message contains a sequence of characters terminated by a carriage return character (r) and a line feed character (n). The message contains the following string: PING sequence_number time CRLF where sequence_number starts at 0 and progresses to 9 for each successive ping message sent by the client, time is the time when the client sent the message, and CRLF represent the carriage return and line feed characters that terminate the line. Extensions When you are finished writing the client, do the following extensions. 1) Currently, the program calculates the round-trip time for each packet and prints them out individually. Modify this to correspond to the way the standard ping program works. You will need to report the minimum, maximum, and average RTTs. (10 marks) 5

2) The basic program sends a new ping immediately when it receives a reply. Modify the program so that it sends exactly 1 ping per second, similar to how the standard ping program works. Hint: Use the Timer and TimerTask classes in java.util. (10 marks) Test Results (10 marks) You should provide appropriate test results i.e. screen dumps that would make it easy for TA to mark. 6