Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Computer Networking Assignment NOTE: your project MUST run on one of the Unix machines on campus, NOT on your PC, preferrably those in the CS department. I recommend cs1.utdallas.edu and...

1 answer below »
Computer Networking Assignment
NOTE: your project MUST run on one of the Unix machines on campus, NOT on your PC, prefe
ably those in the CS department. I recommend cs1.utdallas.edu and cs2.utdallas.edu. 
You will submit your source code and any instructions on how to compile it (i.e. which machine you compiled it on and using what command)
We will run your code and see if it works.
Overview
Processes, files, and arguments
We will simulate a very simple network by having a process co
espond to a computer in the network, and files co
espond to channels in the network. We will call the computers ``nodes''
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
1. The id of this node (i.e., a number from 0 to 9)
2. The duration, in seconds, that the node should run before it terminates
3. The destination id of a process to which the transport protocol should send data 
4. a string of a
itrary text which the transport layer will send to the destination
5. The number of seconds after the node begins when it will begin to transfer the string to the destination.This wait is necessary to allow the routing to find a path to the destination before data begins to be transfe
ed. 
6. 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 computer in the network. The arguments of the program are as follows
node XXXXXXXXXX "this is a message" 20 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", followed by the number of seconds to wait (20) before the node begins to transfer the string to the destination, and ending in 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 XXXXXXXXXX "this is a message from 0" 20 1 &
node 1 100  2  "this is a message from 1" 20 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 it does not have a "begin time" for the transfer since it does not have a string to send)..
The channels will be modeled via text files. File name "from0to1" co
esponds to the channel from node 0 to node 1. Therefore, node 0 opens this file for appending and node 1 opens this file for reading. File name "from1to0" co
esponds to the channel from node 1 to node 0, and process 1 opens this file for appending and process 0 opens this file for reading.
The contents of the files will be simple ASCII characters. Thus, we can observe their contents with any text editor. Note that files are opened for appending, and thus, no byte is ever overwritten. This means that at the end of the execution,  the file will contain a copy of all the messages that were sent along that channel (makes it nice for us to grade :)
Program node (which represents a computer in the network) will contain a transport layer, a network layer, and a data link layer.
Overview of each laye
The dataling layer reads a never ending sequence of bytes from each of the input channels to the process. It's job is to separate the sequence of bytes into messages and give them to the network layer. It also has to be able to receive messages from the network layer and then encode them and append them out to the appropriate output file.
The network layer will determine if this node is the destination of the message. If it is, it gives the message to the transport layer. If it is not, it gives the message to the link layer to be forwarded to the channel towards the destination (the destination may be multiple hops away)
The network layer will also performs a routing protocol to be able to find the path to each node.
The transport layer will do two things:
a. Send the string given in the argument to the appropriate destination (by
eaking it up giving it to the network layer) 
. Receive messages from the network layer. Only those messages that are, of course, addressed to this node 
c. Output to a file called "nodeXreceived" where X is the node id XXXXXXXXXXThe contents of this file should look like this for node 2 in the example above:
From 0 received: this is a message from 0
From 1 received: this is a message from 1
That is, it should contain one line for every message received, it should say from which node the message originated and what was the contents of the message.
Detail of Each Laye
Datalink laye
Since the channel is a file, you can read one byte at a time form the file, however, you need to determine when the frame (data link message) begins and when it ends. 
Each message is a sequence of bytes. The first byte is the start-of-header byte, denoted by an upper-case s, i.e., `S'. Following this are two bytes indicating the length of the message (in ASCII), the maximum message length is 99 bytes. This lenght inclues all bytes in the message, from the 'S' all the way to the check byte at the trailer. Following that is the payload of the message (the actual data). Following that are two bytes that contain a checksum. The value of the checksum is from '00' to '99', and it is obtained by adding together the ascii codes of all the bytes in the message, starting with the 'S' modulo 100
For example, a data link message could look like
S08abc81
 Note that the data part of the message could contain an S. If the receiver loses track of the beginning/end of messages, which BTW I can simulate by feeding inco
ect file contents to one of your programs, then the receiver should be able to recover by looking for the next S and check if the checksum is co
ect. 
The datalink layer has two su
outines (the su
outines don't have to have exactly the same parameters, you can add more or change them if you want, they are just a guideline)
a. datalink_receive_from_network(char * msg, int len, char next_hop)  
This function will be called by the network layer to give a network layer message to the datalink layer. The network layer message is pointed to by char * msg, and the length of the message is integer len. If the network layer is sending a data message, then argument next_hop  is the id of the neighboring node that should receive this message. This routine will output to the output channel (text file) the message given by the network layer, encoded as described above (checksum, etc).
. datalink_receive_from_channel()
This function reads from each of the input files (i.e. the channels from each neighbor) until it reaches an end of file in each of these files. Whenever it has a complete message it gives it to the network layer by calling network_receive_from_datalink() (see network layer below). Again, the fact that it reached an end-of-file does not mean that there are no more bytes, since these bytes may not have a
ived yet. Thus, you have to read until you get end-of-file, and then you have to put your program to "sleep" for 1 second. When it wakes up you should try to read more. If there is nothing to read you go to sleep for one second more, etc.. (See Program Skeleton below) Also, note that the fact that one file has no more data does not mean that there is no more data from other files. Thus, once you reach an end-of-file on ALL input files, then you go to sleep for a second
Network Laye
The network layer will implement the distace vector routing protocol with split-horizon and poisoned reverse. Thus, we have two types of messages: data messages and routing messages. Data messages simply are forwarded to their destination. Routing messages contain the distance vector necessary to compute the routing path.
The network layerdata  message contains the following fields:
1. 1st byte is a D (i.e. for data :)
2. 2nd byte, is the source id (in ascii, i.e., either character '0', or '1' etc up to '9' 
3. 3rd byte is the destination id (also in ascii)
4. Two bytes indicating the length of the message. They are also in ascii, and can be from '00' up to '99'.  
5. The remaining bytes in the message are the data bytes, i.e., the transport layer message.
We use distance vector routing to find a path to each destination. Note that, if the destination is a neighbor, there is no need for routing, i.e., you send the message directly to your neighbor. Thus, even if distance-vector routing is not working properly, you should at all times be able to send messages to your neighbors.
If a data message has a destination that is not a neighbor
Answered Same Day Dec 03, 2021

Solution

Ria answered on Dec 10 2021
131 Votes
node/A.sh
node/B.sh
node/from0to1.txt
"this is a message from 0"
node/from0to2.txt
"this is a message from 0"
node/from1to0.txt
"this is a message from 1"
node/from1to2.txt
"this is a message from 1"
node/from2to0.txt
"this is a message from 2"
node/from2to1.txt
"this is a message from...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here