Hi guys,

I have this project question that is just REALLY boggling me and I am getting nowhere :(

The project description is really large and I can't post all of it hear but I'd just like to post the part I'm on and how far I've gotten with the code.

Here it is:

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
1. 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 arbitrary 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 transferred.
6. a list of id's of neighbors of the process
We will have a single program foo.c (or whatever you want to call it) which has the code for a node. Since we have multiple nodes, we will run the same program, multiple times, in parallel (in the background in Unix). 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 foo be your program that represents a node. The arguments of the program are as follows
foo 3 100 5 "this is a message" 20 2 1
The following would execute the program foo, 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 arbitrary 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)
> foo 0 100 2 "this is a message from 0" 20 1 &
> foo 1 100 2 "this is a message from 1" 20 0 2 &
> foo 2 100 2 1 &
This will run three copies of foo 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 files. File name "from0to1" corresponds 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" corresponds to the channel from node 1 to node 0, and process 1 opens this file for writing and process 0 opens this file for reading.
Program foo (which represents a node) will contain a transport layer, a network layer, and a data link layer.

The main program simply consists of two subroutine calls:
1. A call to the transport layer to send new data messages if possible
2. A call to the data-link layer to receive messages from the input channels

It should look something like this
main(argc, argv) {
Intialization steps (parsing arguments, opening files, etc)
let life = # seconds of life of the process according to the arguments
let start = # seconds before you can send your first data message at the transport layer
for (i=0; i < life; i++) {
send 10 zero bits over each of the output channels
if i >= start then transport_send_string();

Right now, I'm at the "initialization" steps, but I don't understand what the next step is....am I supposed to create files?

Here is my code

public class Node {
    public Node() {
    public Node(int id, int duration_sec, int PID, String transport_text, int sec_of_wait, int ... n_id2) {
    	node_id = id;
    	node_duration = duration_sec;
    	dest_process_id = PID;
    	transportTXT = transport_text;
    	wait_time = sec_of_wait;
    	//neighbor_id1 = n_id1;
    	//neighbor_id2 = n_id2;
    	for (int i=0; i < n_id2.length; i++) {
    public static void main(String[] args) {
    	  Node node1 = new Node(3, 100, 5, "this is a message", 20, 2, 1);
		  int node_id;
	      int node_duration;
	      int dest_process_id;
	      String transportTXT;
	      int wait_time;

    	ArrayList<Integer> nList = new ArrayList<Integer>();

		if (args.size() > 5)
			node_id = Integer.parseInt(args[0]);
			node_duration = Integer.parseInt(args[1]);
			dest_process_id = Integer.parseInt(args[2]);
			transportTXT = args[3];
			wait_time = Integer.parseInt(args[4]);
			for (int i=5; i < args.length; i++) {
				nList = Integer.parseInt(args[i]);

Can someone please help???

Thanks a lot!!!

This article has been dead for over six months. Start a new discussion instead.