Simulating a very simple network by having a process correspond to a node in the network
Additional instructions and materials on the attachment. Overview Processes, files, and arguments We will simulate a very simple network by having a process correspond to a node in the network, and files correspond to channels in the network. We will have at most 10 nodes in the network, nodes 0 , 1, 2, . . . , 9, or LESS, not all nodes need to be present. Each process (i.e. node) is going to be given the following arguments id of this node (i.e., a number from 0 to 9)the duration, in seconds, that the node should run before it terminatesthe destination id of a process to which the transport protocol should send dataa string of arbitrary text which the transport layer will send to the destinationthe starting time for the transport layer (explained much later below)a list of id's of neighbors of the process We will have a single program node.c (or node.java, or node.cc whatever) which has the code for a node. Since we have multiple nodes, we will run the same program multiple times, in parallel. The only difference between each of the copies of the program running in parallel are the arguments to the program. For example, assume I have two programs, A and B, and I want to run them at the same time. At the Unix prompt >, I would type the following > A & > B & By typing the & we are putting the program in the "background", i.e., the program runs in the background and you can keep typing things at the terminal. Therefore, A and B are running in parallel at the same time. Again, let node be your program that represents a node. The arguments of the program are as follows node 3 100 5 "this is a message" 40 2 1 The following would execute the program node, and the first argument is the id of the node (3), the second is the number of seconds the process will run (100), followed by the destination for this node (5), then the message string "this is a message", then the time at which the transport layer begins, and the last arguments is a list of neighbors (i.e. 2 and 1 are neighbors of 3) For example, assume I have a network with three nodes, 0 , 1, 2, and I want node 0 to send a string "this is a message from 0" to node 2, and node 1 to send a message "this is a message from 1" to node 2. Also, assume 0 and 1 are neighbors, and 1 and 2 are neighbors. Then I would execute the following commands at the Unix prompt > (your prompt may, of course, be different) > node 0 100 2 "this is a message from 0" 30 1 & > node 1 100 2 "this is a message from 1" 30 0 2 & > node 2 100 2 1 & This will run three copies of node in the background, the only difference between them are the arguments each one has. For node 2, since the "destination" is 2 itself, this means 2 should not send a transport level message to anyone, and the list of neighbors is just node 1. Note that it does not have a start time for the trasnport layer Note that each node can be the source of a string or not be a source at all. However, each node may receive strings from many other nodes. You cannot know from whom in advance. The channels will be modeled via TEXT files (when we grade, we should be able to read them via a typical text editor, the files should contain only normal characters, i.e., digits, letters, spaces, etc.). File name "from0to1.txt" corresponds to the channel from node 0 to node 1. Therefore, node 0 opens this file for writing (actually, appending, you don't overwrite any previous contents) and node 1 opens this file for reading. File name "from1to0.txt" corresponds to the channel from node 1 to node 0, and process 1 opens this file for writing (appending) and process 0 opens this file for reading. Note that at the end of the execution, when all nodes have finished, the file "from1to0.txt" will contain all the messages that were sent from node 1 to node 0 during the execution. I.e., messages are appended to this file, they are never deleted. We will look at your channel files at the end of the execution to check that all the messages were sent correctly. Program node (which represents a node) will contain a transport layer, a network layer, and a data link layer, which we overview next.