Purpose
In this lab you will learn about the IEEE 802.3 Ethernet standard and how data is transmitted between computers. You will also learn about error correction and detection through transmitted code words by using a cyclic redundancy checking (CRC) algorithm. Finally, you will create an assembled Ethernet packet, calculate the CRC check, and check if it works correctly.
Introduction
First, be warned. This lab contains a lot of reading. But, fear not because you will find that the program, once you understand, is actually rather simple. That is, after you do the reading....
With the rise of the Internet and e-commerce, computer communication has become one of the hottest fields in Computer Engineering. Your Coldfire demonstration board actually has a NE2000 compatible Ethernet card built into it. With this lab, you'll learn about how the IEEE standard for Ethernet works and how it relates to the Coldfire board.
Ethernet Specification 802.3, Type 10-Base-T
The NE2000 compatible chipset on the Coldfire Microprocessor incorporates the IEEE 802.3 Ethernet Standard for communication. Although the protocol is already implemented on the board, it is important to understand how it works.
Your Lab Assignment:
First, use the code provided to create an Ethernet packet that can be transmitted on the Cold Fire board. Then, implement a function that will create a CRC check in the packet. You should know what needs to be checked with the information in this document. Also, create a CRC decoder function to test your CRC encoder.
Finally, create a function to copy your packet to a new location in memory. While there is very little chance that there will be an error in this small transmission, it will simulate a transfer between two computers. Decode your packet CRC to make sure that everything was transmitted correctly.
To test your program, the lab TA will come over after you have created the CRC on your packet. He will modify the data slightly. If the CRC check then fails, you know the CRC decoder portion of the program works correctly.
To get you started, here is some basic code to set up your packet and CRC program. Do a search of the Internet if you need some more help on how to create a CRC function. There are lots of resources available. You can program exclusively in assembly language code or create a C function and the GCC compiler to create your program.
START=0x20000 | The start of this program ENDSTART=0x23000 | The start of the output packet CRCSTART=ENDSTART+0x8 | The start of the CRC'ed area DESTIPh=0xFFFFFF00 | The source IP address DESTIPl=0xFFFF | (6 bytes) SRCIPh=0x00FF00FF | The destination IP address SRCIPl=0xEEEE | (6 bytes) DATASTART=0x22000 | The start and length of the data LENGTH=16 | to be packetized movl #0x2000,A7 | Set Stack movl #0x04c11db7, D0 | CRC mask movl #16, D1 | Number of bytes to data movl #0x3000,A0 | Set start byte of Data clrl D2 | D2 = CRC code holder movl D1,D3 | D3 = temporary counter movl #ENDSTART,A3 | Start byte for constructed packet movl #0xAAAAAAAA,(A3)+ | Preamble movl #0xAAAAAAAB,(A3)+ movl #DESTIPh,(A3)+ movw #DESTIPl,(A3)+ movl #SRCIPh,(A3)+ movw #SRCIPl,(A3)+ movw #LENGTH,(A3)+ movl #DATASTART,A4 subl #0x01,d3 copyloop: movb (A4)+,D6 | Copy the data into the packet movb D6,(A3)+ dbf D3,copyloop movl #0x00000000,(A3)+ | 32 bits for CRC movl #CRCSTART,A0 | Put your CRC code here | append it at A3-4 bytes, which has just been | reset to all 0's. trap #14 trap #14Pseudocode for CRC Check:
CRCMASK[8]=32 bit array representing CRC mask;
CRC=32 bit array=0x0000;
/*
If CRC=the CRC check for this packet instead of 0's, this will function as
a decoder. If the CRC array is anything EXCEPT 0, there is an error.
*/
CRCDATA=IP's+Length+Data+32 0's;
bool bitset;
for (int it=0; it<(length(CRCDATA)); it++)
/*
This length includes 32 bits for the CRC, the data, IP's, 8 bit length.
The length is in BITS
*/
{
if CRC[31]='1' then bitset=true; else bitset=false;
Left_Shift_Logical(CRC);
CRC[0]=CRCDATA[it];
if (bitset) then CRC=CRC xor CRCMASK;
}