Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

TCP Connection Protocol Implementation using Finite State Machine, Assignments of Data Communication Systems and Computer Networks

An assignment for the course Data Communications & Networks at New York University. The assignment requires students to build a finite state machine implementation of the TCP connection protocol for both the client and server side of a connection using a JAVA package that implements a programmable finite state machine. a diagram of the TCP connection protocol and lists the required classes in the FSM package. The due date for the assignment is Friday April 30 2015.

Typology: Assignments

2014/2015

Uploaded on 05/11/2023

ameen
ameen 🇺🇸

4.6

(5)

2 documents

1 / 10

Toggle sidebar

Related documents


Partial preview of the text

Download TCP Connection Protocol Implementation using Finite State Machine and more Assignments Data Communication Systems and Computer Networks in PDF only on Docsity! New York University Computer Science Department Courant Institute of Mathematical Sciences Course Title: Data Communications & Networks Course Number: CSCI-GA.2662-001 Instructor: Jean-Claude Franchitti Session: 8 Assignment #8 I. Due Friday April 30 2015. II. Objectives 1. Get introduced to (or reacquainted with) a very neat computational model called a finite state machine. 2. Build a finite state machine implementation of the TCP connection protocol (3- way handshake) for the both the client (active) side and the server (passive) side of a connection. 3. Leverage a JAVA package that implements a programmable finite state machine to write a program that uses these classes to implement the TCP connection protocol given in Figure 1 below. 4. Since you won’t really get events from a communications link, a sequence of events will be simulated by reading and parsing commands from "standard input" (System.in in Java) Figure 1 – TCP Connection Protocol (symbol Λ means “no action”) III. References 1. Slides and handouts posted on the course Web site 2. Textbook chapters as applicable IV. Software Required 1. Microsoft Word. 2. Win Zip as necessary. 3. Java SE 6.0 and above CLOSED LISTEN SYN_RCVD SYN_SENT ESTABLISHED FIN_WAIT_1 FIN_WAIT_2 LAST_ACK CLOSE_WAIT CLOSED TIME_WAIT CLOSING PASSIVE / Λ CLOSE / Λ CLOSE / Λ ACTIVE / <syn> SYN / <syn-ack> SYN / <syn-ack> SYNACK/ <ack> SEND / <syn> RDATA / <n> SDATA / <n> ACK / Λ CLOSE / <fin> CLOSE / <fin> FIN / <ack> CLOSE / <fin> FIN / <ack> ACK / Λ FIN / <ack> ACK / Λ TIMEOUT / Λ ACK / Λ The classes in the FSM package are: FSM The finite state machine class. State An abstract class that you will use to define the states for your FSM. Event A class that you will use to define the events for your FSM Transition A class that you will use to define the transitions in your FSM Action An abstract class that you will use to define the actions that you take on each transition. FsmException A class used to generate detectable errors in package classes. The code for the FSM package is HERE. The package is in a jar file, so you will need to extract it or use the jar file in your classpath. To use the classes, your JAVA program must import the classes in the Fsm package. The easiest way to use the package is to include the jar file in your class path when you compile and execute. For example, on Unix, you might try: javac -cp .;./Fsm.jar myProgram.java to compile myProgram.java, and java -cp .;./Fsm.jar myProgram to run myProgram On Windows, the command is the same, but the classpath command argument is introduced by -cp rather than -classpath. The documentation for the FSM package is HERE. 4. Implement your program to operate as follows: Your program should loop, reading ONE event from standard in and processing that event completely, including display of any output, then continuing to read and process the next event, until end of input stream (end of file) You MUST implement ALL of the states shown in the transition diagram. You MUST Implement all of the transitions shown in the transition diagram AND the transitions for RDATA and SDATA. Notice that there are two transitions in the Established state to handle data events. These are the SDATA (application request to send data) and the RDATA (data received from the network) events that can occur while in the ESTABLISHED State. You should handle these Events by writing an output message: “DATA received n” when the event is RDATA "DATA sent n" when the event is SDATA Where n is a number representing the number of SDATA or RDATA Events received to date, including this (R|S)DATA Event. The transition for the (|S)DATA Event should leave the FSM in the ESTABLISHED State. The purpose of this requirement is to ask you to figure out how to associate a variable with a state. In practice, you would call a data transfer process which would have it's own FSM to implement flow control. To simplify your task, you may treat ANY String that you read from standard input that is NOT one of the events defined here by writing: "Error: unexpected Event: xxx" where xxx is the invalid event. Your program should then continue as if the “bad” input did not occur. 5. Review the following FAQs: OK, so how do I use these classes to make an FSM? 1. Create classes for your states (by extending State) and allocate your states. 2. Allocate an FSM, giving it a name and a Start State (see the constructor). NOTE: Use ONLY the constructor that allows you to specify the FSM name and starting state: public FSM(String fsmName, State start) 3. Create your events (by allocating instances of Event). 4. Create classes for the actions to take on each transition (by extending Action) and allocate your actions. 5. Allocate instances of the Transaction class using the allocated State, Event, and Action objects, and add these Transition objects to your FSM object (see the addTransition() method in FSM). How to I "send" events into the FSM? The FSM class has a "doEvent" method that takes an Event object as its input. What happens when I send an Event to the FSM? Well, this is a Mealy machine, so the FSM will locate the Transition you defined that associates the Event with the current state of the FSM, then set the current state to the state defined in this Transition as the next state, then it will execute the action method you specified in this Transition's Action object. What do I do in my "Action" methods? For all Transitions EXCEPT those caused by the (R|S)DATA Events, write the message: "Event eee received, current State is sss" where eee is the Event and sss is the current State. For the Actions on the ESTABLISHED/(R|S)DATA Transitions, write the message: “DATA received n” when the event is RDATA "DATA sent n" when the event is SDATA where n is a number representing the number of SDATA or RDATA Events received to date, including this (R|S)DATA Event. What do I do if you send my program an Event that is not defined for the current State? The FSM.doEvent() method will throw an FsmException if you pass an Event that is not defined for the current State. Make sure that you catch this exception and just display the exception (every Exception has a toString() method). Your program should then continue as if the “bad” Event did not occur. How does my program terminate? When you detect the end of the input stream on standard input, just exit. 6. Email your assignment file to your TA. VI. Deliverables 1. Electronic: Your assignment file must be emailed to the TA. The file must be created and
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved