Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
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”)
Machines are devices that respond to a set of stimuli (events) by generating predictable responses (actions) based on a history of prior events (current state). Any object that behaves according to this stimulus/response relationship may be considered as a machine.
In order to represent a machine as a computational model, you need to define:
States represent the particular configurations that a machine can assume.
Events define the various inputs that a machine will recognize
Transitions represent a change of state from a current state to another (possibly the same) state that is dependent upon a specific event. In a Mealy machine, an FSM may generate an output upon a transition.
The Start State is the state of the machine before is has received any events.Generally, finite a state machine is classified as either a Mealy machine - one that generates an output for each transition, or a Moore machine - one that generates an output for each state.
Moore machines can do anything a Mealy machine can do (and vice versa).
Practically, Mealy machines are more useful for implementing communications protocols.
The FSM that you will experiment with in this assignment is a Mealy machine.
|
EVENT |
Input string |
|
Passive Open |
PASSIVE |
|
Active Open |
ACTIVE |
|
SYN received |
SYN |
|
SYN + ACK received |
SYNACK |
|
ACK received |
ACK |
|
Data received from network |
RDATA |
|
Data to be sent from application |
SDATA |
|
FIN received |
FIN |
|
Client or Server issues close() |
CLOSE |
|
Timed wait ends |
TIMEOUT |
Events in standard input will be separated by white space (note: EOL is also white space!).
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.
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. |
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:
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 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 whichwould 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:
where xxx is the invalid event. Your program should then continue as if the
OK, so how do I use these classes to make an FSM?
NOTE: Use ONLY the constructor that allows you to specify the FSM name and starting state: public FSM(String fsmName, State start)
How to I "send" events into the FSM?
The FSM class has a "doEvent" method that takes an Event object as its input.
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:
For the Actions on the ESTABLISHED/(R|S)DATA Transitions, write the message:
where n is a number representing the number of SDATA or RDATA Events received to date, including this (R|S)DATA Event.
How does my program terminate?
When you detect the end of the input stream on standard input, just exit.
Your assignment file must be submitted via NYU Brightspace. The file must be created and sent by the beginning of class. After the class period, the homework is late. The Brightspace clock is the official clock.
Your assignment file should include your program source code packaged as a JAR file along with a report document.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:
Include the jar file in your assignment zip file and submit the zip file via NYU Brightspace.
The associated documentation provided in your zip file MUST include a readme file containing the name of the class that contains the main() method. It should also include a report document that elaborates on the design of your solution and other applicable details.
The cover page supplied on the next page must be the first page of your report file.
Report Layout (5%)
- Report is neatly assembled on 8 1/2 by 11 page layout.
- Cover page with your name (last name first followed by a comma then first name), date, NYU ID, and course section number with a signed statement of
- Program and documentation submitted for independent effort is included. Lab #6 are satisfactory.
- File name is correct.