Assignment title: Information
6CC002 Systems Engineering Technologies
Mini-Project1 (Ethernet)
STUDENT NAME:
STUDENT NUMBER:
You will need to complete the workshop and submit report to WOLF topic along with your source code. You also need demo it on workshop session. It will be added into your final profile (20%).
The demo deadline is 21th/Jan/2016. The report submission deadline for mini-Project is 19th/Jan/2016. Each member contribution to the project should be clearly identified in the report. The group mark will be moderated for each individual on the basis of contribution about each individual.
1. Objective
The objective of this lab is to introduce you to Ethernet. We also study the EMAC EasyWEB example (from Keil) which illustrates a simple web server hosted on the MCBSTR91x board.
2. Project Task
Create a new uVision project and write a program that uses Ethernet to connect two boards and transmit the value of the potentiometer from one board to the other, where it is displayed on the LCD screen.
3. Ethernet Introduction
Ethernet is a Broadcast Network: hosts are connected to a network through a single shared medium. This has the advantage that messages don't have to be routed to their destination, as all hosts are present on the shared medium, but it does incur another set of problems. The main problem which needs to be addressed is that of Media Access Control (MAC) or giving fair access to multiple nodes on a shared medium.
Collisions: When a number of nodes are connected to a single shared medium, one of the issues is the possibility of two or more nodes trying to broadcast at the same time. This is called a collision and prevents any information passing along the network because the multiple messages would corrupt each other, destroying both. There are two main methods for reducing the effect of collisions 1) Collision Avoidance and 2) Collision Resolution. Collision Avoidance involves systems which prevent any collisions occurring in the first place, such as polling or token passing. Collision Resolution or Contention MAC Strategies rely on the fact that collisions will occur, and try to cope with them as well as possible. Ethernet uses Collision Resolution. Below, we discuss some collision resolution techniques.
ALOHA: The most basic form of Collision Resolution is to simply allow any station to send a message (or packet) whenever it is ready to send one. This form of transmission was first used in a prototype packet radio network, ALOHANET, commissioned in Hawaii in 1970, and has been known ever since as unslotted ALOHA. In Pure ALOHA, packets contain some form of error detection which is verified by the receiver. If the packet is received correctly, the destination returns an acknowledgment. If a collision occurs and the message is destroyed or corrupted, then no acknowledgment will be sent. If the sender does not receive an acknowledgment after a certain delay, it will re-send the message.
Carrier Sense Multiple Access (CSMA): The next stage in Collision Resolution after ALOHA was to add the ability for devices to detect whether the shared medium is idle or not. This is called "Carrier Sense Multiple Access" or CSMA. This, however, does not completely eliminate collisions, since two devices could detect the medium as idle, then attempt to send at approximately the same time.
CSMA is actually a family of protocols which vary by the method which they wait for the medium to become idle, known as the persistence strategy. Here is a list of two major strategies: 1-Persistent CSMA - In this strategy, when a device wants to send a message, it first listens to the medium. If it is idle the message is sent immediately, however, if it is busy the device continues to listen to the medium until it becomes idle and then sends the message immediately. The problem is that if a number of devices attempt to send during a busy period, then they shall all send as soon as the medium becomes idle, leading to a collision. nonpersistent CSMA - This strategy attempts to reduce the greediness of 1-Persistent CSMA. It again first listens to the medium to see if it is idle, if so it sends immediately. If the medium is busy, instead of continuing to listen for the medium to become idle and transmitting immediately, it waits a random period, then, it tries again. This means that in high load situations, there is less chance of collisions occurring.
Collision Window: A collision occurs when two devices send at approximately the same time. But how long does a device have to wait until it knows that its message has not been corrupted by a collision? Messages take a certain amount of time to travel from the device to the end of the signaling medium, which is known as the propagation delay. It would seem that a device only needs to wait for one propagation delay, until the message reaches the last receiver, to know if a collision has occurred. This, however, is not the case. Take for example the following situation. A device sends a message, which takes 1 propagation delay to reach the last device on the medium. This last device on the medium could then send a message just before the original message reaches it (i.e., just before 1 propagation delay). This new message would take an additional propagation delay to reach the original device, which means that this device would not know that a collision had occurred until after 2 propagation delays.
Collision Detection: Knowing how long is needed to wait to discover if a collision has occurred, we can use this to increase the effectiveness of CSMA. CSMA behaves inefficiently when a collision occurs, since both stations continue to send their full packet, even though it will be corrupted. A simple enhancement to CSMA is the addition of Collision Detection (CSMA/CD). A simple check is made to make sure that the signal present on the medium is the same as the outgoing message. If it isn't, then, a collision is occurring, and the message can be aborted. This means that the time spent sending the doomed messages can utilized for something else.
Ethernet Protocol
The Ethernet protocol is made up of a number of components:
a) Ethernet frames
b) Physical Layer
c) MAC operation.
a) Frame Structure:
Information is sent around an Ethernet network in discreet messages known as frames. The frame structure consists of the following fields:
Preamble - This consists of seven bytes, all of the form "10101010". This allows the receiver's clock to be synchronized with the sender's.
Start Frame Delimiter - This is a single byte ("10101011") which is used to indicate the start of a frame.
Destination Address - This is the address of the intended recipient of the frame. The addresses in 802.3 use globally unique hardwired 48 bit addresses.
Source Address - This is the address of the source, in the same form as above.
Length - This is the length of the data in the Ethernet frame, which can be anything from 0 to 1500 bytes.
Data - This is the information being sent by the frame.
Pad - 802.3 frame must be at least 64 bytes long, so if the data is shorter than 46 bytes, the pad field must compensate. The reason for the minimum length lies with the collision detection mechanism. In
CSMA/CD the sender must wait at least two times the maximum propagation delay before it knows that no collision has occurred. If a station sends a very short message, then it might release the ether without knowing that the frame has been corrupted. 802.3 sets an upper limit on the propagation delay, and the minimum frame size is set at the amount of data which can be sent in twice this figure.
CRC: Cyclic Redundancy Check to detect errors that occur during transmission (DIX version of FCS). or FCS: Frame Check Sequence to detect errors that occur during transmission (802.3 version of CRC). This 32 bit code has an algorithm applied to it which will give the same result as the other end of the link, provided that the frame was transmitted successfully.
Ethernet vs. 802.3: Although the Ethernet and 802.3 standards are effectively the same thing, there are some subtle differences between Ethernet II and 802.3. The IEEE 802.3 standard was part of a bigger standard, 802. This contains a number of different network technologies, such as token ring, and token bus, as well as Ethernet. These technologies are brought together by a layer on top of these MAC Layers called Logical Link Control (LLC). Ethernet II, however, does not use this LLC layer.
b) Physical Layer:
The Physical Layer is concerned with the low level electronic way in which the signals are transmitted. In Ethernet, signals are transmitted using Manchester Phase Encoding (MPE). This encoding is used to ensure that clocking data is sent along with the data, so that the sending and receiving device clocks are in sync. The logic levels are transmitted along the medium using voltage levels of ±0.85V.
The table below lists some of the cable types utilized by Ethernet networks.
Cable Type Max Speed Max Length Operation Frequency
CAT5 100Mbps 100m 100MHz
CAT5e 1Gbps 100m 100MHz
CAT6 10Gbps 50m 250MHz
CAT6a 10Gbps 100m 500MHz
c) Media Access Control (MAC) Operation:
Ethernet is a CSMA/CD (Carrier Sense Multiple Access/Collision Detection) network. To send a frame, a station on an 802.3 network first listens to check if the medium is busy. If it is, then, the station uses the 1-persistent strategy, and transmits after only a short fixed delay (the inter-frame gap) after the medium becomes idle. If there is no collision, then this message will be sent normally. If the device detects a collision however, the frame transmission stops and the station sends a jamming signal to alert other stations of the situation. The station then decides how long to wait before re-sending using a truncated binary exponential backoff algorithm. The station waits for some multiple of 51.2us slots. The station first waits for either 0 or 1 slots, then transmits. If there is another collision, then the station waits for 0,1,2 or 3 slots before transmitting. This continues with the station choosing to wait a random number of slots from 0 to 2^k - 1 if there have been k collisions in the current transmission, until k=10 where the number of slots chosen from stops growing. After 16 continuous collisions, the MAC layer gives up and reports a failure to the layer above.
Many companies offer Ethernet MAC (EMAC) Controllers as SW or HW cores.
4. The Internet Protocol
The Internet Protocol suite is the set of communications protocols used for the Internet and similar networks. It is generally the most popular protocol stack for wide area networks. It is commonly known as TCP/IP, because of its most important protocols: Transmission Control Protocol (TCP) and Internet Protocol (IP), which were the first networking protocols defined in this standard. It is also referred to as the DoD model - due to the foundational influence of the ARPANET in the 1970s (operated by DARPA, an agency of the United States Department of Defense).
TCP/IP provides end-to-end connectivity specifying how data should be formatted, addressed, transmitted, routed and received at the destination. It has four abstraction layers which are used to sort all Internet protocols according to the scope of networking involved. From lowest to highest, the layers are:
1. Link layer: contains communication technologies for a local network.
2. Internet layer (IP): connects local networks, thus establishing internetworking.
3. Transport layer: handles host-to-host communication.
4. Application layer: contains all protocols for specific data communications services on a process-to-process level. It focuses more on network services, APIs, utilities, and operating system environments. For example, HTTP specifies the web browser communication with a web server.
5. Ethernet Block of MCBSTR91X
The Ethernet block contains a full featured 10 Mbps or 100 Mbps Ethernet MAC (Media Access Controller) designed to provide optimized performance through the use of DMA hardware acceleration. Features include a generous suite of control registers, half or full duplex operation, flow control, control frames, hardware acceleration for transmit retry, receive packet filtering and wake-up on LAN activity. Automatic frame transmission and reception with Scatter-Gather DMA off-loads many operations from the CPU.
The Ethernet block is an AHB master that drives the AHB bus matrix. Through the matrix, it has access to all on-chip RAM memories. A recommended use of RAM by the Ethernet is to use one of the RAM blocks exclusively for Ethernet traffic. That RAM would then be accessed only by the Ethernet and the CPU, and possibly the General Purpose Direct Memory Access Controller, giving maximum bandwidth to the Ethernet function.
The Ethernet block interfaces between an off-chip Ethernet PHY using the RMII (Reduced Media Independent Interface) protocol and the on-chip MIIM (Media Independent Interface Management) serial bus, also referred to as MDIO (Management Data Input/Output).
The block diagram of the Ethernet block consists of: The host registers module containing the registers in the software view and handling AHB accesses to the Ethernet block. The host registers connect to the transmit and receive data path as well as the MAC. The DMA to AHB interface. This provides an AHB master connection that allows the Ethernet block to access on-chip SRAM for reading of descriptors, writing of status, and reading and writing data buffers. The Ethernet MAC, which interfaces to the off-chip PHY via an RMII interface. The transmit data path, including:
– The transmit DMA manager which reads descriptors and data from memory and writes status to memory.
– The transmit retry module handling Ethernet retry and abort situations.
– The transmit flow control module which can insert Ethernet pause frames. The receive data path, including:
– The receive DMA manager which reads descriptors from memory and writes data and status to memory.
– The Ethernet MAC which detects frame types by parsing part of the frame header.
– The receive filter which can filter out certain Ethernet frames by applying different filtering schemes.
– The receive buffer implementing a delay for receive frames to allow the filter to filter out certain frames before storing them to memory.
6. Example of EasyWEB
This is the EasyWEB example that is downloadable from WOLF topic. The EMAC project is a simple embedded web server for the STR91x microcontrollers also known as "EasyWEB". This tiny web server was taken from the "Design & Elektronik" magazine extra issue "Embedded Internet". This software was adapted to work with a Keil MCBSTR9 board. The served web page shows the value of one analog input (AN2) which can be controlled via the blue potentiometer on the MCBSTR9 board.
Please read readme file (included in the downloadable archive for this project) to see how to set-up and run this example (use the CAT 5E cable). Compile, and download to the board. Observe operation and comment. When up and running you should see the webpage.
Take some time and read the source code in order to get a good understanding of what's happening.
7. Report Writing
Please refer to document MiniProject1 (USB).