CIS 677 LAB ASSIGNMENT I(a)
Due date: Friday, May 1, 1998 by the beginning of class.

1 Goals

2 Layered architecture

For the purpose of this lab, assume that each node in the network has three layers: physical layer, datalink layer (DLC) and application layer. Nodes in the network are connected to one another via links. Each layer in a node can be thought of as an abstract entity that performs certain functions. Similarly, links are also entities that have some functionality. Figure 1 outlines the three layers in a node connected by a link entity. In this lab, you will learn how these entities communicate with one another, and will develop a simple DLC layer entity.



Figure 1Layered Architecture

3 Protocol Data Units

Each layer communicates through Protocol Data Units (PDU). The application layer PDU is called A PDU, the DLC PDU is called D_PDU, and the physical layer PDU is called PH_PDU. The A_PDU, D PDU and PH_PDU formats are defined below. These definitions, together with some others are provided to you in the file pdu.h .

 typedef struct {          int  snode;                    /* source node address      */          int  dnode;                    /* destination node address */          char data[DATASIZE];           /* data                     */  } A_PDU_TYPE;    typedef struct {          int               curr_node;   /* address of this node     */          int               next_node;   /* address of next node     */          A_PDU_TYPE        a_pdu;       /* application pdu          */          enum boolean      error;  } D_PDU_TYPE;    typedef struct {          int               type;          D_PDU_TYPE        d_pdu;       /* dlc  pdu          */  } PH_PDU_TYPE;    typedef struct {          union {                               /* structure containing a_pdu */                  A_PDU_TYPE        a_pdu;      /* d_pdu or ph_pdu as a union */                  D_PDU_TYPE        d_pdu;                  PH_PDU_TYPE       ph_pdu;          } u;          int type;  /* One of: TYPE_IS_A_PDU, TYPE_IS_D_PDU, TYPE_IS_PH_PDU */  } PDU_TYPE;

The application layer sends an a_pdu to the DLC layer. The DLC layer receives this a_pdu and encapsulates it within a d_pdu. It then performs its functions on the d_pdu and sends the d_pdu to the physical layer. In the same manner, the physical layer receives the d_pdu, encapsulates it within a ph_pdu and sends it to the link entity. The link entity receives a ph_pdu from one physical layer and delivers it to the physical layer at the other end. When a physical layer receives a ph_pdu from the link, it extracts the d_pdu from it and sends it to the dlc layer. The dlc layer checks the d_pdu for errors, extracts the a_pdu and sends it to the application layer.

4 Service Primitives

Inter layer communication takes place by means of service primitives. At the physical-datalink layer interface, there are two service primitives: PH_DATA_request and PH_DATA_indication. At the datalink-application layer interface, there are two service primitives: DLC_DATA_request and DLC DATA_indication.

A service primitive, say DLC_DATA_request, is implemented as two procedures: ApplicationToDatalink() and DatalinkFromApplication(). ApplicationToDatalink() puts a_pdu's into the dlc entity, while DatalinkFromApplication() gets a_pdu's from the dlc entity. Notice that ApplicationToDatalink() is called by the application layer to send a_pdu's, and DatalinkFromApplication() is called by the datalink layer to receive these a_pdu's.

5 Methodology

In this lab, you will design the DatalinkToPhysical and DatalinkToApplication functions for the datalink layer. The outline of these functions is given in the Appendix, and provided in the file dlc layer.c

  1. In directory /usr/class/cis677/Lab1/Files/, you will find these files:

  2. Copy the above files to your working directory (e.g., /cis677/lab1/
  3. Experiment with lab1_demo. See section 6 for instructions on how to run your program.
  4. Study the source code files carefully. (don't worry about the config files).
  5. Now you are ready to write your program for the datalink layer. All you have to do in this lab is fill in the appropriate code for DatalinkToPhysical() and DatalinkToApplication() in dlc_layer.c.
  6. To compile your program, type make. This will produce an executable called lab1_exec in your working directory.
  7. Now execute your version of the code and use the configuration files to make sure it works.
  8. Run the script drawgraphs. The script will run your executable and produce several postscript files (one for each configuration). These files will contain graphs of the number of pdu's received by each dlc entity plotted against time. You must submit hard copies of these graphs. Note: This program may take a while to run, so please be patient with it.

6 Running your program: The Graphical User Interface

Login to an HP machine. NOTE: This program works only on HP machines. At your unix prompt, type lab1_demo. A window with the simulator interface will open on your terminal.



Figure 3Simulator Interface

Figure 3 shows the simulator window with the 3-nodes configuration. Each node has 3 layers denoted by three squares. Each link component is denoted by a square between the link connections. In addition to the simulator window, there are 5 smaller windows visible in the figure. Two of the windows are the space time diagrams for the data going between the links (the third space-time window is not visible in the figure but you will see it on the simulator). The other three windows are called the node graphs for the simulation. They allow you to send text data and/or a preloaded graphical image file over the network. The node-graph windows have the following functions:




Function Name
Description


Send msg
Send a message in the text window
Send graph
Send the graph in the graph window
Clear msg
Clear the text window
Clear graph
Clear the graph window
Load graph
Load a pre-defined graph in the graph window


The top of the main simulator window has a menu bar that has the following selections.






Menu
Submenu
Description



File
Load
Load config file
Exit
Stop the program and exit



Edit
Raise
Raise the node graphs and space-time diagrams
to the front of main window. Useful when you cannot see the
graphs.



Run
Run
Start the simulator. You need to send msg/graph
to see further animation.
Single Step
Enters single step mode. Use the space bar for a step.
Pause
Pause the simulation.
Resume
Resume the simulation.
Delay
Set delay between events. The default is 50. 5 is pretty fast.
Stop Time
The simulation time to stop.
Inc/Dec Debug Level
Increament/Decrement Debug Level, which is used in dprintf().



Help
About
About the CISE Project.
How to use
Help text.



The bottom of the main simulator window is the status bar with the following information.




Field
Description


Filename
The configuration file name.
Stop Time
The end time for the simulation
Delay
Delay between events.
DebugLevel
DebugLevel used in dprintf().
Simulation time
The clock in the simulator.


7 Submissions

You must submit the following by email to cis677@netlab.ohio-state.edu. The subject line of your email, should contain "cis677 lab1a submission userid" where userid is your cis login.

You must submit hard copies of the following:

8 Miscellaneous Notes

9 Appendix: dlc_layer.c

 #include "dlc_layer.h"    /* ----- DO NOT REMOVE OR MODIFY THIS FUNCTION ---- */    static dlc_layer_receive(DLC_LAYER_ENTITY_TYPE *dlc_layer_entity,                           GENERIC_LAYER_ENTITY_TYPE *generic_layer_entity,                           PDU_TYPE *pdu) {   if (DatalinkFromApplication(generic_layer_entity)) {        DatalinkToPhysical(dlc_layer_entity, pdu);   } else if (DatalinkFromPhysical(generic_layer_entity)) {        DatalinkToApplication(dlc_layer_entity, pdu);   }     return 0;  }  /********************************************************************/    DatalinkToPhysical(DLC_LAYER_ENTITY_TYPE *dlc_layer_entity,                   PDU_TYPE *pdu_from_application) {      PDU_TYPE *pdu_to_physical;      /* just a sanity check */    if (pdu_from_application->type != TYPE_IS_A_PDU) panic("Empty a_pdu\n");       /* ------ DO YOUR CODING HERE ----- */       /* create d_pdu: use pdu_alloc() */     /* use bcopy to copy the contents */       /* send to phy */     /* Use the macro:              send_pdu_to_physical_layer(dlc_layer_entity,pdu_to_physical);     */       pdu_free(pdu_from_application);     return 0;  }      /* -------------------------------------------------------- */  DatalinkToApplication(DLC_LAYER_ENTITY_TYPE *dlc_layer_entity,                      PDU_TYPE *pdu_from_physical) {    PDU_TYPE * pdu_to_application; /* use pdu_alloc() to create this */       /* just a sanity check */     if (pdu_from_physical->type != TYPE_IS_D_PDU) panic("Empty d_pdu\n");       /* ------ DO YOUR CODING HERE ----- */     /* Use the macro:       send_pdu_to_application_layer(dlc_layer_entity, pdu_to_application);     */       /* extract a_pdu, check for error and send to app app if error free*/       pdu_free(pdu_from_physical);       return 0;  }