ECE 354 Lab3

Download Report

Transcript ECE 354 Lab3

ECE 354
Lab 3: Transmitting and Receiving
Ethernet Packets
ECE Department: University of Massachusetts, Amherst
Big Picture Introduction
 Transmit and Receive Ethernet packets between
two DE2 boards
 Implement the 5-layer Internet model
 Primarily written in C code
 Use a preexisting SOPC system from the
DE2_NET project
ECE 354
2
Skills to learn
 Understanding previously written code
 Using a peripheral device: DM9000A chip
 Connect to a device that you did not design:
DM9000A Ethernet chip
 Internet protocol stack
ECE 354
3
Additional Hardware
 Two DE2 boards
 Ethernet cable
ECE 354
4
The Internet protocol stack –as we will use it
 Consists of 5 layers: Application, Transport, Network, Link,
and Physical layer; ignore Session and Presentation (OSI)
ECE 354
5
Overview of Lab
 Each group should specify the information in Layers 2
through 5 (Link, Network, Transport, and Application)
 The payload should be 16 bits selected by 16 switches
(switch_pio) on the DE2 board and should be displayed on
the LEDs (led_red) of the other DE2 board
 Only packets with the correct source MAC, IP, and port
addresses should be allowed to update the LEDs
 Each group should modify the DM9000A.H file so that the
last byte of the MAC address matches their group number
 Test protocol compliance by working with another group
and using their MAC address as your destination MAC
address and your own MAC as the source. This shall fail (or
else you need to update it).
ECE 354
6
Overview of DE2_NET project
 Important files: hello_led.c, DM9000A.c, and DM9000A.h
 Three functions to control DM9000A chip
• DM9000_init();
• TransmitPacket(TXT, length);
• ReceivePacket(RXT, &length);
 Copy the DE2_NET from the DE2 CD and use that project
in Quartus.
 If running two boards on the same computer, make two
folders with each holding a copy of the DE2_NET project
ECE 354
7
Layers you will use
 Create an Application Layer (5)
message (data) by using the sixteen
switches on the DE2 board
 Encapsulate it into segment at the
Transport Layer (4)
 Encapsulate the segment in a
datagram at the Network Layer (3)
 Encapsulate the datagram in a frame
at the Link Layer (2)
 The frame will be sent over the
Physical Layer (1)
ECE 354
8
User Datagram Protocol (UDP) – Layer 4 (Transport Layer)
 The Application Data will be encapsulated within a UDP
segment
 The Segment Header includes the Source Port, Destination
Port, Length of Segment, and Checksum
 The Source and Destination Port numbers can be
determined by the user, but the Length and Checksum will
have to be calculated.
ECE 354
9
The Network Layer (3) - IPv4
 The Segment from the Transport Layer will be
encapsulated within an IPv4 Datagram
 Dominant network layer protocol on the internet
 Data-oriented protocol to be used on a packet
switched network, such as Ethernet
 Note about Checksums:
• Begin by first setting the checksum field of the header
to zero.
• Checksums involve the one’s compliment addition
operation. In C take the one’s compliment of a number
A by: unsigned int complimentA = ~A
ECE 354
10
IPv4 packet structure

Packet consists of two sections:
 header and data

The parts of each section that
you will use in the is lab are:
Version: IP packet version (4)
Header length (between 5 and
15)
Total Length (size of datagram)
 Identification: uniquely
identifying fragments
 Header checksum
 Source and Destination address
 Data



ECE 354
11
Link Layer (2) – Ethernet Frame
 The Datagram from the Network Layer is
encapsulated within an Ethernet Frame
 The Destination and Source MAC addresses
should be set to uniquely identify each DE2 board
 Extra credit will be awarded if you perform CRC
Checksum, otherwise set it to a value of zero
ECE 354
12
The Physical Layer (1)
 Refers to the network hardware or physical cabling
 Provides the means of transmitting raw bits
 You can also use a loopback (included with kit) to send
packets back your own board
ECE 354
13
What to demonstrate
 Display data payload on the red binary LEDs
 Display the number of packets transmitted on
the seven segment display
 Only packets with the correct source MAC
address, IP address, and port address should be
displayed
ECE 354
14
Where does this project lead?
 The next Lab (number 4) will put Lab 2 and Lab
3 together
 Implement a reliable system
ECE 354
15
References
 The two documents located at
DE2_System_v1.6\Datasheets\Ethernet
 DE2_System_v1.6\DE2_demonstrations\
DE2_NET project
 For detailed description of headers
http://en.wikipedia.org/wiki/Internet_protocol_s
uite
 Method of calculating the CRC
http://en.wikipedia.org/wiki/Cyclic_redundancy_
check
ECE 354
16
Comments and/or Questions
ECE 354
17