Project 3 FAQ

From CS415

Q. Parameters for the various minimsg functions: What is the role of the various parameters in miniport_send and miniport_receive functions?

In

int minimsg_send(miniport_t local, miniport_t remote, minimsg_t msg, int len);

local is the local port from which the message is to be sent, remote is the port (remote or local) to which the message is to be sent, msg is the message to be sent and len is the size of the msg buffer. The int returned is either 0 for success or -1 for failure. In

int minimsg_receive(miniport_t local, miniport_t* remote, minimsg_t msg, int *len);

local is the local port on which the message is to be received, remote is a pointer to a remote port from which the message was sent (and therefore can be responded to on), msg is the buffer into which the message has to be received and len is the size of the msg buffer. You need to set *len to the number of bytes received. Return 0 for success and -1 for failure.

Q. Port information Local: ports and remote ports need to contain different kinds of information and yet they are both supposed to have type struct miniport *. How do we do this?

To get started you can declare struct miniport to have all the kinds of information that either local or remote ports need to contain. If there are pieces of information that are valid for local ports but not for remote ports and vice versa then in creating an instance of the corresponding ports these variables can be set to NULL or dummy values. You can then either use this aspect to find the "type" of the port or explicitly keep a variable that indicates if the struct you are looking at is a remote or local port. For example, struct miniport might look like this

       struct miniport { 
               int islocal;
               // local port stuff goes here
               ...
               // remote port stuff goes here
       };

Your code then needs to check the type of the port and behave appropriately. Of course, items common to both local and remote ports should be shared, not duplicated, in the structure.

Q. Header information: Why should I include the sender's network address in the header of each message if I can take this information from the parameter given to the network handler ?.

Your implementation of unreliable communication will be used throughout the entire semester. In the Project 5 you will need to implement an Ad-hoc networking in which a packet should pass through a chain of computers. To apply Ad-hoc routing policies you will need the address of the source of the packet.

Q. Host IP address: How can we get the IP address assigned to a computer ?

Network_initialize function prints the IP address of the local host. So, when system runs a program that uses network_initialize function, the program prints host's IP address .

Q. miniport_remote_create() and "remote" ports: We need to implement miniport_remote_create function. When must applications use this function ?

When application A sends a remote message to application B, minimsg_send needs to know the port on which B listens (B's local port). That's why application A creates a remote port that is bound to the B's local port (see network[5-6] examples). The minimsg_receive creates the remote port bound to the sender, not the application that uses the function. You may use miniport_remote_create function inside minimsg_receive function and store in the "remote" parameter the structure assigned to the remote port.