Written by Tom Laramee for use in the senior level ECE course in Computer Networks 597A, and for use in the graduate-level course ECE671.
Presented is a sample Media Access Control protocol with sample output.
[ Tutorial Index | Lecture Notes | Skeleton Simulation Code | Media Access Simulation Code | Data Link Layer Simulation Code ]This is a relatively simple enhancement of the skeleton files (mainly sim.sh and main.c). It will be far more clear then Example #2 - which becomes fairly involved in places. I recommend using this as a guide to generate ideas and supply syntactical examples.
There are 3 zip files:
Download the 2nd file, gunzip it, and untar it.
NOTE: The contents of this tape archive should reside in their own directory. If it is untarred in the same directory as either the skeleton or the other example, there will be a file collision and some files will be overwritten and lost.
The filelist should be as follows:
Type the command:
You will see the following:
sim: Command line parameters are as follows sim: sim: Description.....command line flag: value sim: --------------------------------------------- sim: Number of nodes............(-n): 10 sim: Channel length.............(-l): 100 (meters) sim: Propagation delay..........(-T): 3.3e-7 (sec) sim: Channel capacity...........(-c): 2.048e6 (bps) sim: Number of bits/packet......(-x): 2048 (bits) sim: Number of bits/ACK.........(-a): 8 (bits) sim: Max number of buffers/node.(-b): 30 sim: Max contention window size.(-u): 1024 sim: Min window contention size.(-v): 4 sim: Prob[successful packet]....(-p): 0.0 sim: SIFS.......................(-s): 8.25e-07 (sec) sim: DIFS.......................(-d): 1.32e-06 (sec) sim: T3.........................(-t): 9.9e-07 (sec) sim: System arrival rate........(-S): 1 (frames per sec) sim: sim: Please enter a Probablity that there will be an sim: unsuccessful packet transmission (ex 0.0, 0.2, 0.5):
These are the command line paramters which will be passed into the simulation.
Follow the directions in the script and run the simulation.
The script runs the "dcf" program 20 times as the default. It collects statistics for 3 plots:
It will collect these statistics for any Probability that there will be an unsuccessful packet transmission. (See above)
Then it will Ghostview the plots at the end of the simulation.
NOTE: There is sample output in the directory sample.OP
This is a simplified version of the Media Access Control Protocol for the IEEE 802.11 proposed standard on wireless LANs.
An explanation of this protocol is beyond the scope of this module. The simulation focuses on specific areas of the protocol such as:
It does not attempt to implement the protocol exactly. This would require about 3000 more lines of code (and a lot more time than i have).
The genEvent? functions I added (to the skeleton) are:
The utilities I added (to the skeleton) are:
And the processEvent? functions I added (to the skeleton) are:
Again, an explanation of the way these functions work is beyond the scope of this module. They are all quite short, so if you're interested in the data flow, it is obtainable directly from the code.
I modified main.c to add the above functions.
Specifically, I added the following to the skeleton:
The major difference between this program and the skeleton is the lack of a "printStatus" function. I implement this function inside of main.c, which is probably not a good idea (sloppy).
Also, since this program is collecting 4 statistics, in the "showReport" function, I open 4 data files, "a", "b", "c", and "d". Each of these has it's own 2 number pair representing a statistic from the simulation.
After 1 run, the files look something like this:
(a) | (b) | (c) | (d) |
---|---|---|---|
1.000 0.054 | 1.000 0.2351 | 1.000 5 | 1.000 0 |
Since the program is being run but the script "sim.sh", these files are being concatenated to 4 data files, (data.utilization, data.packetdelay, data.queuelength, and data.re_arrivals) for plotting.
So, after 5 program runs, those data files look like this:
(data.utilization) | (data.packetdelay) | (data.queuelength) | (data.re_arrivals) |
---|---|---|---|
1.000 0.054 | 1.000 0.2351 | 1.000 5 | 1.000 0 |
51.00 0.089 | 51.00 0.2121 | 51.00 8 | 51.00 0 |
101.0 0.134 | 101.0 0.1965 | 101.0 11 | 101.0 23 |
151.0 0.345 | 151.0 0.1654 | 151.0 14 | 151.0 57 |
201.0 0.461 | 201.0 0.0143 | 201.0 17 | 201.0 85 |
These programs will be plotted using 4 GNUplot driver files:
These driver files are generated when sim.sh calls sim.gnuplot.sh. If you want to generate these files on your own to see what they look like, type:
where:
The sim.sh script required the most extensive modificaiton. Again, if you are unfamiliar with the UNIX operating system, no amount of explanation will make this script clear.
This script esentailly works the same way as the skeleton version - except it keeps track of the above 4 statistics altogether. This just means there are more files to keep track of, and therefore everything is esentially done 4 times, instead of once (as in the skeleton sim.sh).
It is liberally commented - so it is entirely possible to understand what it is doing by running it and looking @ the source.