






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Course Title: Data Communications & Networks Course Number: CSCI-GA.2662- Instructor: Jean-Claude Franchitti Session: 8
I. Due
Friday April 30 2015.
II. Objectives
Figure 1 – TCP Connection Protocol (symbol Λ means “no action”)
III. References
IV. Software Required
CLOSED
LISTEN
SYN_RCVD SYN_SENT
ESTABLISHED
FIN_WAIT_
FIN_WAIT_2 LAST_ACK
CLOSE_WAIT
TIME_WAIT^ CLOSED
CLOSING
PASSIVE / Λ
CLOSE / Λ
CLOSE / Λ
ACTIVE /
SYN / <syn-ack> SYN / <syn-ack>
SYNACK/
SEND /
RDATA /
SDATA /
ACK / Λ CLOSE /
FIN /
FIN /
TIMEOUT / Λ
ACK / Λ
2. Understand your program inputs requirements:
Your program MUST accept as input (from standard input) the Strings for events in the following table
Events in standard input will be separated by white space (note : EOL is also white space!).
NOTE 1: Events must be specified exactly as shown in the table above. All events must be entered in uppercase letters only. Any parsed token (word) that does not exactly match one of these should be treated as invalid (incorrect) input.
NOTE 2: Figure 1 shows a transition from LISTEN state to SYN-SENT state driven by the SEND event. Your program should not handle this case so you should ignore this transition. A SEND event occurs when a server socket is converted implicitly from server to client by the owning application doing a write on the server socket.
3. Understand the classes provided in the FSM package:
EVENT Input string
Passive Open PASSIVE
Active Open ACTIVE
SYN received SYN
SYN + ACK received
ACK received ACK
Data received from network
Data to be sent from application
FIN received FIN
Client or Server issues close()
Timed wait ends TIMEOUT
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
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
Your assignment file must be emailed to the TA. The file must be created and
sent by the beginning of class. After the class period, the homework is late. The email clock is the official clock.
Your assignment file should contain your program source code packaged as a JAR file.
To create the JAR file containing your JAVA source code (please do not include the class files), change your working directory to the directory where your JAVA files are located and execute the command:
jar cvf xxx .jar *.java
where xxx is YOUR STUDENT ID.
Include the jar file in your assignment zip file and send the zip file as an email attachmentl to the grader.
The associated documentation provided in your zip file MUST include a readme file containing the name of the class that contains the main() method.
You may send questions to the class mailing list ONLY.
Printout of the files as necessary (report/hardcopy portion of the assignment). The cover page supplied on the next page must be the first page of your assignment file Fill in the blank area for each field.
The sequence of the hardcopy submission is:
**1. Cover sheet
VII. Sample Cover Sheet: