This program will simulate a simple Computer Network. Your job is to create a simulated network using threads to simulate each node in the network. For this program, we will focus upon creating the pseudo-network of nodes and simulate messages between said nodes.
We will assume that there are 10 nodes in the network and that there is asynchronous behavior between all nodes. Your first assignment is due in one week. It is a written assignment that will describe how you intend to model this simulation. Each team will submit a CLEAR description of how they intend to implement this simulated network.
Your program should be able to create 10 individual nodes representing networked stations. Each station should be able to send and receive packets from any one node to any other node. The messaging should effectively simulate normal network communication. That is, your model should behave in an asynchronous manner.
I would ask that each team investigate Java content beyond what we currently have covered. For this assignment I expect you to produce a “centralized” model with a multithreaded server which handles all messages from all nodes – think a STAR topology (for now), where all messages are transferred via one centralized server. That is, all network nodes are directly connected to a single message server that receives messages to be delivered and forwards them to the recipient nodes.
PLEASE be specific as to how your model will handle this problem. I want to see some visuals and some examples as to how concurrent communication can take place when we have 11 entities and centralized model. The first is the centralized message server and the other 10 are the actual network nodes that wish to exchange messages.
I want you to present a clear 5-10 minute description of your plan/model that will be presented in one week. You may go a bit longer (no more than 15 minutes!!! More or less) but be reasonable.
Your team is to produce a model for implementing this simple star-network with a centralized message model. You should produce a simple but clear PowerPoint presentation that presents and describes your model. I fully understand that many teams may produce similar models. At this point, we have officially seen very few Java constructs for threading and concurrency. I am asking you to seek out more advanced models if necessary. I would like you to comprehend and model based upon the ServerSocket and Socket classes and the Thread class or Runnable Interface.
Obviously, you may use any data structures you like including Java’s Collection classes. I will also accept the use of Java’s synchronized methods. I am making available some slides I have produced covering a variety of different Java Concurrency constructs.
Your program should create 10 Node objects. Each of which should use a Socket object to connect with the main program (server). This obviously means that your main program (server) should be sure to maintain Sockets to each Node thread AND maintain Input and Output streams to all Nodes.
Each Node thread will receive a file path to a file which will instruct it as to its scheduled behavior. Each node will read the data file and carry out its instructions. The file will be a standard text file which will indicate a series of messages to be sent to one of the other Nodes. The Node objects should be numbered from 0-9. The file will also indicate indications of milliseconds of time that the Thread (Node) will sleep between sending messages.
The thread should also receive messages and “process them” (print them out – see below) between the sending of messages and sleep. When all messages have been sent and all messages received, the threaded Nodes should cease execution. Similarly, when all nodes have ceased execution, the server/program should halt.
Obviously, some groups may discover techniques and/or classes that others are not familiar with. I am asking, and I expect each group to identify any network or thread-related or concurrency classes or constructs they intend to use and provide an explanation of them unless we have discussed them in class.
I was, and still am, very pleased with the presentations I saw. With that in mind, I am going to ask you all to implement your model (or alter it and still meet the specification. This is still a group project so please try to work out the details. Please do not try to cover for anyone who is not doing their share of the work or slacks in any way.
The idea of this program is to produce an actual application that will run on multiple machines. It will simulate network communication with string messages and said messages should be strings delivered using an asynchronous simulation. Each “node” will open an appropriate file named #input.txt where the # is replaced by the node number 1-N. So node 4 will open and read 4input.txt – is that clear?
Each process’s input file will be named Xinput.txt (where X is the process identifier/integer 0-9) and will contain data as follows… Each line will be of one of the following forms:
This indicates that the current node (the node reading the file) is to send the given message to the indicated node.
Other messages will look simply like this…
- this is the value that should be given to the sleep( ) method for the Thread class. It will also simulate a series of sequential instructions.
The algorithm that we will implement, is the simple Lamport Logical Clock. That is, each node will keep its own time beginning at 0. Each shall implement its local clock by 1 at each Logical step. This will include the calculation of Current_time = Current_time + MAXIMUM( (msg_time) + 1 , (Current_time) + 1). The normal Lamport timing.
Now, if the entry is a “local, sequential” entry (e.g. 12) then it indicates that the local clock should both increment the local logical clock by the value indicated AND should sleep for that many seconds. So, if the line in the input file says “21” then this reflects a local timing of 21 seconds of sequential calculations and thus the local clock should be incremented by 21 AND the thread should sleep for 21 seconds (or as close as the OS will allow).
On the other hand, if the file entry is of the form then the local logical clock should be incremented and the message should be sent with updated “ local logical clock” followed by the message.
Each process should output to standard output when it is about to sleep along with the number of seconds as in
PROCESS #3 Sleeping for 1.6 seconds Local time = X
PROCESS #7 Sleeping for .3 seconds Local time = Y
PROCESS #5 Sleeping for 8.5 seconds Local time = Z
Where X,Y, and Z reflects the local logical Lamport clock time.
Also, each process should indicate the messages that it is sending as …
PROCESS #4 Sending message “…blah blah blah ….” to PROCESS #1 Local time = A
PROCESS #6 Sending message “yada yada yada…” to PROCESS #3 Local time = B
Again, A and B reflect the local logical Lamport clock time for the SENDER.
Finally, each process, should output upon the receipt of a message, as in
PROCESS #9 receiving message “whatever it is” Local time = S
PROCESS #4 receiving message “again whatever the message says” Local time = T
Times S and T should reflect the local Lamport logical clock time AFTER an increment.
Please remember that ALL messages are expected to be ASYNCHRONOUS. That is, non-blocking.
An example file for a process X might look like this…
5 “message from process X to process “
4 “message from process X to process”
5 “yup another message from X to “
5 “last message to from X to “
1 “message from process X to process”
PLEASE note that output messages need to match the style/form presented above.