Programming: Reliable Transport - Alternating Bit

Similar documents
Lab 2: Implementing a Reliable Transport Protocol (30 points)

CSE434 Computer Networks (FALL, 2009) Programming Assignment 3 Due: Wed, December 2, 2009

Programming Assignment 5: Implementing a Reliable Transport Protocol

ECE5650: Computer Networking and Programming Term Project Assignment Part II: Total 100 points

Total Points 100 (One Hundred)

Computer Networks. Project 2. Project Assigned: November 14 Checkpoint: November 21 12:01 AM Due: December 04 12:01 AM. Networks - Project 2 1

CSE 489/589 Programming Assignment 2

Lab 1 - Reliable Data Transport Protocol

Lecture 10: Transpor Layer Principles of Reliable Data Transfer

CSCD 330 Network Programming

Basic Reliable Transport Protocols

The GBN sender must respond to three types of events:

Project 2 Reliable Transport

Figure 1: Network topology and link costs for DV routing

Internet transport-layer protocols. Transport services and protocols. Sending and receiving. Connection-oriented (TCP) Connection-oriented

The Transport Layer: TCP & Reliable Data Transfer

COMPUTER NETWORK. Homework #2. Due Date: April 12, 2017 in class

Computer Networks. Project 3. Project Assigned: December 2 Due: December 17 12:01 AM Show and Tell: December Networks - Project 3 1

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

Chapter 3: Transport Layer

Chapter 3 outline. 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management

COM-208: Computer Networks - Homework 3

CSE 123: Computer Networks Alex C. Snoeren. HW 1 due NOW!

CSC358 Week 4. Adapted from slides by J.F. Kurose and K. W. Ross. All material copyright J.F Kurose and K.W. Ross, All Rights Reserved

Communication Networks

file:///c:/users/hpguo/dropbox/website/teaching/fall 2017/CS4470/H...

CSCE 463/612 Networks and Distributed Processing Spring 2018

Unit 2.

COSC4377. Useful Linux Tool: screen

TCP : Fundamentals of Computer Networks Bill Nace

Operating Systems and Networks Project 1: Reliable Transport

CS 3516: Advanced Computer Networks

Chapter 3: Transport Layer Part A

Lecture 7: Flow Control"

ELEN Network Fundamentals Lecture 15

CS 3516: Computer Networks

Chapter 3 Transport Layer

Chapter 3 Transport Layer

c. If the sum contains a zero, the receiver knows there has been an error.

CMPE 150/L : Introduction to Computer Networks. Chen Qian Computer Engineering UCSC Baskin Engineering Lecture 8

4.0.1 CHAPTER INTRODUCTION

NWEN 243. Networked Applications. Layer 4 TCP and UDP

CSC 401 Data and Computer Communications Networks

Chapter 4 Defining Classes I

The Transport Layer Reliability

Lecture 5: Flow Control. CSE 123: Computer Networks Alex C. Snoeren

Chapter 11 Data Link Control 11.1

CMSC 332 Computer Networks Reliable Data Transfer

Lecture 4: CRC & Reliable Transmission. Lecture 4 Overview. Checksum review. CRC toward a better EDC. Reliable Transmission

Guide To TCP/IP, Second Edition UDP Header Source Port Number (16 bits) IP HEADER Protocol Field = 17 Destination Port Number (16 bit) 15 16

Problem 7. Problem 8. Problem 9

Computer Networking. Reliable Transport. Reliable Transport. Principles of reliable data transfer. Reliable data transfer. Elements of Procedure

STEVEN R. BAGLEY PACKETS

Project Introduction

Outline. EEC-484/584 Computer Networks. Data Link Layer Design Issues. Framing. Lecture 6. Wenbing Zhao Review.

rdt2.0 has a fatal flaw!

CSC 4900 Computer Networks: Reliable Data Transport

CPSC 441 COMPUTER COMMUNICATIONS MIDTERM EXAM SOLUTION

CSC 4900 Computer Networks: TCP

Transport services and protocols. Chapter 3 outline. Internet transport-layer protocols Chapter 3 outline. Multiplexing/demultiplexing

Project #1 Exceptions and Simple System Calls

Internet and Intranet Protocols and Applications

Lecture 9: Transpor Layer Overview and UDP

Chapter 3 Transport Layer

Chapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP 23.1

TDTS06: Computer Networks

Rdt2.0: channel with packet errors (no loss!)

Chapter III: Transport Layer

The Transport Layer Multiplexing, Error Detection, & UDP

Chapter 11 Data Link Control 11.1

Lecture 11: Transport Layer Reliable Data Transfer and TCP

ECE697AA Lecture 3. Today s lecture

Lecture - 14 Transport Layer IV (Reliability)

CSC 401 Data and Computer Communications Networks

Programming Assignment 2

Transport layer. Our goals: Understand principles behind transport layer services: Learn about transport layer protocols in the Internet:

Introduction to Programming Using Java (98-388)

6.033 Lecture 12 3/16/09. Last time: network layer -- how to deliver a packet across a network of multiple links

Transport layer: Outline

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

TCP. Sliding Windows, Flow Control, and Congestion Control. Networks : TCP Sliding Windows 1

CMPE 150/L : Introduction to Computer Networks. Chen Qian Computer Engineering UCSC Baskin Engineering Lecture 7

Computer Networks & Security 2016/2017

Reliable Transport : Fundamentals of Computer Networks Bill Nace

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

Flow Control, and Congestion Control

Protocol Specification

TCP reliable data transfer. Chapter 3 outline. TCP sender events: TCP sender (simplified) TCP: retransmission scenarios. TCP: retransmission scenarios

23-3 TCP. Topics discussed in this section: TCP Services TCP Features Segment A TCP Connection Flow Control Error Control 23.22

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

ERROR AND FLOW CONTROL. Lecture: 10 Instructor Mazhar Hussain

Chapter 3 Transport Layer

Specification of Protocol Using FSM

CS3516 Computer Networks. Program 3 {October 27, 2014} 55 points

14-740: Fundamentals of Computer and Telecommunication Networks

Reliable Transport I: Concepts and TCP Protocol

Programming Assignment 2 (50 pts) Due: 9 a.m. Friday, February 8, Data Link Layer Client and Server Processes Using Tanenbaum s PAR Protocol

OSI Transport Layer. Network Fundamentals Chapter 4. Version Cisco Systems, Inc. All rights reserved. Cisco Public 1

CSE 3214: Computer Network Protocols and Applications Transport Layer (Part 2) Chapter 3 outline. UDP checksum. Port numbers

Connectionless and Connection-Oriented Protocols OSI Layer 4 Common feature: Multiplexing Using. The Transmission Control Protocol (TCP)

Transcription:

Programming: Reliable Transport - Alternating Bit This lab is to be completed in teams of two. Collaborative conversations between yours and other teams with regard to syntax, strategies and methods for completing the lab are encouraged; however design and implementation must be the work of the team that is handing in the final product. Make sure the work/understanding is shared between team members. Overview In this laboratory programming assignment you will use a guided, building block approach to write the sending and receiving transport-level code for an implementation of the simple reliable data transfer protocol (rtd 3.0). Remember, the transport level is responsible for passing messages between the application layer and network layer on a host in order to allow two processes to communicate. Since we can t modify the Windows XP operating system on our lab computers, your code will have to execute in a simulated hardware/software environment. However, the programming interface provided to your routines, i.e., the code that would call your entities from above and from below is very close to what is done in an actual UNIX environment. (Indeed, the software interfaces described in this programming assignment are much more realistic than the infinite loop senders and receivers that many texts describe). Stopping/starting of timers is also simulated, and timer interrupts will cause your timer handling routine to be activated. Step 1 Understanding the Simulated Environment First you will load the code that creates the simulated environment as well as the single class that you will modify to complete this lab: Download the ReliableTransportStarter.zip file from the Campus EFREI. Unzip the file to a directory on your X drive where you plan to work. In NetBeans 5.5.x (or Eclipse), open a New Project and choose from the General category Java Project with Existing Sources. => Next Give your project the name <Your LName> Lab 7 and a working directory =>Next 1

Add folder ReliableTransportStarter as your Source Package. =>Finish Open StudentNetworkSimulator.java and add your name and the date to the comments at the beginning of the file. This is the only file you will need to read and modify. The other files are provided only for your curiosity and convenience. The supplied Java code simulates both an application layer (layer 5) and a network layer (layer 3) that your transport protocol must interact with. The methods you will write are for the sending entity (A) and the receiving entity (B). Only unidirectional transfer of data (from A to B) is required. However, the B side will ultimately have to send packets to A to acknowledge receipt of data. The general structure of the emulated environment is below: The unit of data passed between the upper layers and your protocols is a message, which is a 20- byte string (implemented as a Java class with getdata and setdata methods). Your sending entity will thus receive data in 20-byte chunks from layer5; your receiving entity should deliver 20-byte chunks of correctly received data to layer5 at the receiving side. The unit of data passed between your routines and the network layer is the packet, which is declared as: public class Packet { private int seqnum; private int acknum; private int checksum; private String payload; } 2

There are associated useful methods to manipulate a Packet object and those are detailed in the comments of the StudentNetworkSimulator.java class. The packet fields will be used by your protocols to insure reliable delivery, as we've seen in class. The Transport Layer Routines You Will Write The four methods you will fill in are detailed below. These methods will be called by (and will call) methods that have been provided to interact with the emulated network environment. Your routines will fill in the payload field from the message data passed down from layer 5 and send them through layer 3. As noted above, such methods in real-life would be part of the operating system, and would be called by other methods in the operating system. 1. aoutput(message message), where message contains data to be sent to the B-side. This routine will be called whenever the upper layer at the sending side (A) has a message to send. It is the job of your protocol to insure that the data in such a message is delivered in-order, and correctly, to the receiving side upper layer. 2. ainput(packet packet) - This routine will be called whenever a packet sent from the B- side (i.e., as a result of a tolayer3() being done by a B-side method) arrives at the A- side. packet is the (possibly corrupted) packet sent from the B-side. 3. atimerinterrupt() - This routine will be called when A's timer expires (thus generating a timer interrupt). You'll probably want to use this routine to control the retransmission of packets. See starttimer() and stoptimer() below for how the timer is started and stopped. 4. binput(packet packet) - This routine will be called whenever a packet sent from the A- side (as a result of a tolayer3() being done by a A-side method) arrives at the B-side. The packet object is the (possibly corrupted) packet sent from the A-side. 3

Software Interfaces To help you with this project, you are provided with following routines which can be called by your methods: tolayer3(int callingentity, Packet p), where calling_entity is either 0 (for the A-side send) or 1 (for the B side send), and p is a Packet. Calling this routine will cause the packet to be sent into the network, destined for the other entity. tolayer5(string string) With unidirectional data transfer, you would only be calling this from to the B-side. Calling this routine will cause data to be passed up to layer 5. protected void starttimer(int callingentity, double increment), where entity is either 0 (for starting the A-side timer) or 1 (for starting the B side timer), and increment is a double value indicating the amount of time that will pass before the timer interrupts. A's timer should only be started (or stopped) by A-side routines, and similarly for the B-side timer. To give you an idea of the appropriate increment value to use: a packet sent into the network takes an average of 5 time units to arrive at the other side when there are no other messages in the medium. stoptimer(int callingentity), where entity is either 0 (for stopping the A-side timer) or 1 (for stopping the B side timer). Your first step is to write the java code that simulates a transport protocol that sits on a completely reliable network layer. Recall from the text that the FSM for the sender and receiver in this unlikely scenario is as follows: After examining these FSMs you should very quickly realize that all the transport layer needs to do in this case is take a message from the application layer, packetize it by encapsulating it in 4

some additional data, and then send it through the network layer. The steps are reversed on the receiver side. In StudentNetworkSimulator.java class this can all be accomplished by filling in the missing code from the following methods: aoutput(message message) and binput(packet packet). You will simply need to use the previously mentioned software interfaces to turn a message into a packet, send it through layer 3, then retrieve the message on the receiver side and pass it up to layer 5. This should require no more than five lines of code. When creating the packet for this first task, use a value of zero in each of the data fields int seq, int ack, int check. It is highly encouraged that you use System.out.println to display what data the message is comprised of (i.e. A sent : ). When you compile and run the program, accept all defaults from the GUI control panel. Your output should look similar to this: A sent: aaaaaaaaaaaaaaaaaaaa B received: aaaaaaaaaaaaaaaaaaaa A sent: bbbbbbbbbbbbbbbbbbbb B received: bbbbbbbbbbbbbbbbbbbb If your code works correctly, a file named OutputFile will be created in your Project Folder (not in your Source Folder) containing the contents of the packets sent from A to B. Step 2 Create Pseudo Code Now that your simple code works inside the emulator you should have an understanding of how your transport layer interacts with the layers above and below it. As noted in lecture, rdt 1.0 is basically useless and we didn t have a realistic protocol until we developed rdt 3.0. The ultimate goal of this lab is to implement rdt 3.0 within our emulator. rdt 3.0 Receiver Both the sender and receiver side of rdt 3.0 have complex FSM s (see the diagrams on the next page), and to get ourselves organized before we program their code we need to make some pseudo code. Download the file LabPsuedo.txt from Campus EFREI. It contains general pseudo code for most of the steps which need to take place for a successful coding of rdt 3.0 with the exception of some key words that were blanked out. Take the time now fill in the blanks of the pseudo code based on the steps dictated by the FSMs of rdt 3.0. You will turn this page in for grading.

Laboratoire Télécom&Réseaux Protocoles- Interconnexions 29/11/2012 rdt3.0 Receiver 6

Step 3 Coding the Alternating-Bit-Protocol Once you have organized your thoughts with pseudo code you are almost ready to write the methods aoutput(), ainput(), atimerinterrupt(),and binput(), which together will implement a stop-and-wait (the alternating bit) protocol which we referred to as rdt3.0 in the text. First you need more background on the environment. The network layer is capable of corrupting and losing packets. It will not reorder packets. When you compile your methods and the provided code together and run the resulting program, you are able to specify the following values regarding the simulated network environment: Number of messages to simulate. The emulator (and your routines) will stop as soon as this number of messages has been passed down from layer 5, regardless of whether or not all of the messages have been correctly delivered. Thus, you need not worry about undelivered or unack'ed messages still in your sender when the emulator stops. Note that if you set this value to 1, your program will terminate immediately, before the message is delivered to the other side. Thus, this value should always be greater than 1. Loss. You are asked to specify a packet loss probability. A value of 10% (0.1) would mean that one in ten packets (on average) are lost. Corruption. You are asked to specify a packet corruption probability. A value of 20% (0.2) would mean that one in five packets (on average) are corrupted. Note that the contents of payload, sequence, ack, or checksum fields can be corrupted. Tracing. Setting a tracing value of 1 or 2 will print out useful information about what is going on inside the emulation (e.g., what's happening to packets and timers). A tracing value of 0 will turn this off. A tracing value greater than 2 will display all sorts of odd messages that are for the emulator s debugging purposes. A tracing value of 2 may be helpful to you in debugging your code. Average time between messages from sender's layer 5. You should choose a very large value for the average time between messages from sender's layer5 (~1000) so that your sender is never called while it still has an outstanding, unacknowledged message it is trying to send to the receiver. Helpful Hints and the like A simplified checksum method has been provided for you. Furnish it the requested fields at either A or B and it will return the same int value. START SIMPLE. Set the probabilities of loss and corruption to zero and test out your routines. Then handle the case of one of these probabilities being non-zero, and then finally both being non-zero. Any shared "state" among your routines needs to be in the form of global variables. Any information that your methods need to save from one invocation to the next must also be a global (or static) variable. For example, your routines will need to keep a copy of a packet for possible retransmission. It would be a good idea for such a data structure to be a global variable in your code. Note, however, that if one of your global variables is used by your sender side, that variable should NOT be accessed by the receiving side entity, since in real life communicating entities cannot share global variables. 7

There is a float global variable called time that you can access from within your code to help you out with your diagnostics msgs. Debugging. We'd recommend that you set the tracing level to 2 and put LOTS of printlns in your code while you are debugging your methods. Submission Turn in your filled in your hard copy of the pseudocode, an electronic copy of your modified StudentNetworkSimulator.java code and a hard copy printout of your code output running with trace level 2, 10 messages, a loss probability of 0.1 and a corruption probability of 0.3. Make sure you have included sufficient printlns in your code so that the output is clear. For example, your methods might print out a message whenever an event occurs at your sender or receiver. 8