Background:
Parts of HDLC have been used in many different protocols. The bit stuffing features of HDLC have been used by Ethernet to provide a unique preamble and postamble for the Ethernet frame. This allows an Ethernet receiver to synchronize on a frame boundary and to receive valid data. For this lab you will write the HDLC code that will format an Ethernet frame
Specifications:
You should study the material on pages 87-88 and 116-121 in order to complete this lab successfully. The format for an Ethernet packet will consist of the following fields. Note that this is slightly different than the Ethernet packet described in the text.
|
Preamble |
Dest Address |
Src Address |
Type |
Body |
CRC (ignored) |
Postamble |
|
8 bits |
48 bits |
48 bits |
16 bits |
1-56 bytes |
32 bits |
8 bits |
|
01111110 |
Bit stuffing |
01111110 |
||||
When you create a ethernet header, the "Src Address" should be the
address passed to you in the init(...)routine.
The "dst address" is the addr parameter from your push(...)
routine. The "Type" and "CRC" should be zero.
The Ethernet layer object will be very similar to the physical layer object you wrote in a prior lab. The ethernet layer object must support the following methods:
The initialization code will be called when the program is started and will store the addr for use later as this machines ethernet address.
The push method will:
When this method is called, you should:
* If you get a framing error, discard everything before the framing error and start looking for a PREAMBLE.
HDLC
One way to implement the bit stuffing code is to use a shift register. This is one of the easiest ways to detect long strings of ones, since they may cross byte boundaries. For example 0x07,0xf0 should be changed to 0x07,0xd8 even though neither of the bytes has more than 5 ones in a row. If you shift bits into a variable and look for strings of ones, then you can detect all problem bit patterns. We would like you to use some creativity in designing the bit-stuffing algorithm. You should be able to do it with the information provided in the text and by looking at the HDLC generated by the TA code. In this lab, you will be passing off against lab code and can look at what it returns in order to help you in the debug cycle. This is a common mode for networking code development. You have to reverse engineer a protocol by examining the output of a working protocol module.
Passoff:
We will provide you with the Ethernet framework in ~cs460ta/labs/ether_template to help you code and test your ethernet layer. Replace the physical.h and physical.cc files in the template with your own files from the physical layer lab.
The passoff procedure will test the following specific items
·
The lab code will send non-zero CRC, discard this data.
·
The lab code will send garbage data between the Postamble and Preamble,
discard this data.
· Good packets will be sent.
Run your code as a client against the compiled version of the ta's code (~cs460ta/labs/ether) running as the server in order to pass off your program for the TA during his office hours. This lab code will do the same thing as the framework code, but may run some different tests.
The T.A. server will first receive all of the packets you send from main. When you hit the ENTER key on the server window, it will send you frames with bad crc, bad destination address and framing errors as well as packets with more than one ethernet frame in each 90 byte packet. If you see bad bit stuffing, you should throw away everything you have seen so far and then start looking for a sentinal that will begin the next frame. Don't look for a closing sentinal on a frame with bad bitstuffing. You may want to run additional tests of your own to make sure that things are working.
The following passoff levels will apply to this lab:
|
Passoff Level |
Behavior |
Points |
|
Minimal Passoff |
At least one Ethernet packet is sent and received with correct bitstuffing |
2 Points |
|
Discards Bad CRC |
Must check CRC |
2 Points |
|
Framing |
Garbage frames are discarded, you should start looking for a beginning sentinal after you throw away the frame |
2 Points |
|
Perfect behavior |
Passes all tests |
4 Points |