The MAC Layer: Jean-Yves Le Boudec Fall 2009
The MAC Layer: Jean-Yves Le Boudec Fall 2009
The MAC Layer: Jean-Yves Le Boudec Fall 2009
Contents
1. MAC as Shared Medium 2. MAC as interconnection at small scale 3. MAC and Link layer
ALOHA
central host
data
ack
transmission procedure
i i= 1 =1 while (i <= maxAttempts) do while (i <= maxAttempts) do send packet send packet wait for acknowledgement or timeout wait for acknowledgement or timeout if ack received then leave if ack received then leave wait for random time wait for random time increment i i increment end do end do
6
i i= 1 =1 while (i maxAttempts) do while (i maxAttempts) do listen until channel idle listen until channel idle transmit immediately transmit immediately wait for acknowledgement or timeout wait for acknowledgement or timeout if ack received then leave if ack received then leave wait random time /* collision*/ wait random time /* collision*/ increment i i increment end do end do
7
CSMA avoids some collisions, but not all Some collisions can be avoided, but not completely. This is because of
propagation delays. If two or more stations may sense that the medium (= the channel) is free and start transmitting at time instants that are close enough for a collision to occur. Assume propagation time between A and B is 2 ms and that all stations are silent until time 0. At time 0, station A starts transmitting for 10 ms, at time 1 ms, station B has not received any signal from A yet, so it can start transmitting. At time 2ms, station B senses the collision but it is too late according to the protocol. The CSMA protocol requires that stations be able to monitor whether the channel is idle or busy (no requirements to detect collisions). It is a simple improvement to Aloha, at the expense of implementing the monitoring hardware. The effect of the CSMA protocol can be expressed in the following way. Call T the maximum propagation time from station A to any other stations; if no collision occurs during a time interval of duration T after A started transmitting, then A has seized the channel (no other station can send). CSMA works well only if the transmission time is much larger than propagagation, namely bandwidth-delay product << frame size. In order to avoid repeated collisions, it is required to wait for a random delay before re-transmitting. If all stations choose the random delays independently, and if the value of the delay has good chances of being larger than T, then there is a high probability that only one of the retransmitting stations seizes the channel. 8
10
t2
11
t2
t1
12
CSMA/CD improves on CSMA by requiring that stations detect collisions and stop transmitting (after 32 bits, called jam bits, in order to ensure that all circuits properly recognize the presence of collisions). CSMA/CD has a better performance than Aloha or CSMA After a collision is detected, stations will re-attempt to transmit after a random time. Acknowledgements are not necessary because absence of collision means that the frame could be transmitted (see Minimum Frame Size). The interframe delay (gap) is 9.6 s. It is used to avoid blind times, during which adapters are filtering typical noise at transmission ends. The random time before retransmission is chosen in such a way that if repeated collisions occur, then this time increases exponentially. The effect is that in case of congestion (too many collisions) the access to the channel is slowed down.
13
Exponential Backoff
random time before re-transmission is given by:
k = min (10, AttemptNb) k = min (10, AttemptNb) rr= random (0, 2kk-1) slotTime = random (0, 2 -1) slotTime
AttemptNb is the number of the re-transmission attempt that will be attempted after the random time (k=1 for the first retransmission); random returns an integer, uniformly distributed between the two bounds given in argument;
15
Ethernet exists at 10, 100, 1000 Mb/s; is the same for all => network diameter is scaled down
2 km/s at 10 Mb/s , 200 m at 100 Mb/s At 1 Gb/s, ethernet does not use CSMA/CD
16
CSMA/CD with exponential backoff as shown earlier. Ethernet PDU is called packet or more often frame
Ethernet history
1980 : Ethernet V1.0 (Digital, Intel, Xerox) 1982 : Ethernet V2.0 1985 : IEEE 802.3 standard
small differences in both specifications; adapters today support both 1995 : IEEE 802.3 100Mb/s standard
802.3 frame
4 B
The preamble is used for the receivers to synchronize (01010101 terminated by 0). With Ethernet, transmission starts asynchronously (stations start independently), and between transmissions, the channel is idle. SFD (start frame delimiter) is used to validate the beginning of a frame. Destination length is used to indicate the total length before padding. Padding is required if the minimum frame size of 512 bits = 64 bytes is not reached. With the Ethernet proprietary (=non standard) format, this field is not present. It is up to the layer using Ethernet to know that frames have to be at least 512 bits, and perform the padding. Maximum size of data part is 1500 Bytes (limitation imposed by buffer sizes). The type field indicates the type of upper layer that uses the protocol (for example: IP or Appletalk). With 802.3, this field is absent; it is replaced by an intermediate layer, called LLC that provides mainly this multiplexing function. LLC is not needed with the non-standard Ethernet. Type values are larger than the maximum size so both formats can exist on the same network (even on the same station). The FCS (frame check sequence) is a 32-bit cyclic redundancy check. It can detect all single, double, triple errors, all error bursts of Ethernet works for a local area only. This is because the CSMA/CD protocol has poor utilization as the bandwidth-delay
length <= 32, most double bursts of length up to 17. The probability that a random collection of bit errors is undetected is 2e-10.
18
Addressing
Problem: know whom a packet is addressed to Solution: MAC addresses MAC address: 48 bits = adapter number (in principle can be configured). Unique worldwide, in principle. sender puts destination MAC address in the frame all stations read all frames; keep only if destination address matches Sent in the clear, no encryption
MAC address A
08:00:20:71:0d:d4
D
00:00:c0:3f:6c:a4
Ethernet addresses are known as MAC addresses. Every Ethernet interface has its own MAC address, which is in fact the serial number of the adapter, put by the manufacturer. MAC addresses are 48 bit-long. The 1st address bit is the individual/group bit, used to differentiate normal addresses from group addresses. The second bit indicates whether the address is globally administered (the normal case, burnt-in) or locally administered. Group addresses are always locally administered. When A sends a data frame to B, A creates a MAC frame with source addr = A, dest addr = B. The frame is sent on the network and recognized by the destination. Some systems like DEC networks require that MAC addresses be configured by software; those are so-called locally administered MAC addresses. This is avoided whenever possible in order to simplify network management. Data on Ethernet is transmitted least significant bit of first octet first (a bug dictated by Intel processors). Canonical representation thus inverts the order of bits inside a byte(the first bit of the address is the least significant bit of the first byte); examples of addresses: 01:00:5e:02:a6:cf (a group address) 08:00:20:71:0d:d4 (a SUN machine) 00:00:c0:3f:6c:a4 (a PC ) 00:00:0c:02:78:36 (a CISCO router) FF:FF:FF:FF:FF:FF the broadcast address
20
solution
21
More Questions
In an Ethernet packet there is (true/ false)
The MAC address of the destination The MAC address of the source
When I use my laptop at EPFL, I can see in the MAC address that I am at EPFL (true/false)
When I use my laptop at EPFL, I can see in the IP address that I am at EPFL (true/false)
22
In this section we discuss the MAC layer as it is today for wired networks. To understand this, we need to go through history. With the MAC layer, we can build a small network without routers
23
24
The 1st Day, the Active Hub was Invented as Solution to the Cable Debugging Nightmare
One network with repeaters = one collision domain Even with repeaters, network is limited
propagation time / 51.2s slotTime includes repeaters /at most 4 repeaters in one path
repeaters
UTP
27
Bridge
port 3 C
Forwarding Table Dest Port Dest Port MAC Nb MAC Nb addr addr A A B B C C D D 1 1 2 2 3 3 2 2
28
port 2
B D 3 collision domains
29
The 4th day, the Point to Point Only Cable was invented
Unshielded twisted pair (similar to telephone analog line cables) (UTP) is cheaper and easier to install (can be bent) but does not support well many multiple tranmitters or receivers Since Ethernet is now based on point to point cables, we can use UTP
30
31
32
Bridge UTP
Bridge
Bridge
33
34
*Security Issues
Q. Are there security benefits in having only point to point links and active hubs, as opposed to shared links ?
solution
35
End System
Repeater
Bridge
End System
Bridges are layer 2 intermediate systems Repeaters are in layer 1intermediate systems There also exist layer 3 intermediate systems (IP routers) -> see next chapter
36
1. A MAC address is
a. The address of the machine, given by a system administrator b. The serial number of the Ethernet adapter
2. Original Ethernet is
a. Shared medium, one collision domain per LAN b. Point to point links, one collision domain per LAN c. Point to point links, several collision domains per LAN
3. Todays Ethernet is
a. Shared medium, one collision domain per LAN b. Point to point links, one collision domain per LAN c. Point to point links, several collision domains per LAN
4. WiFi is
a. Shared medium, one collision domain per LAN b. Point to point links, one collision domain per LAN c. Point to point links, several collision domains per LAN
38
6. An Ethernet Switch is
a. A bridge b. A repeater c. A router
6. A Repeater is
a. A frame forwarding device inside one collision domain b. A bit-forwarding device inside one collision domain c. An IP packet forwarding device inside one collision domain
6. A Bridge is
a. A frame forwarding device inside one local area network b. A bit-forwarding device inside one local area network c. An IP packet forwarding device one local area network
6. A Bridge
a. Coordinates collisions between several cables b. Separates several collision domains
6. A system that allows several cables to be part of the same collision domain is
a. A bridge b. A repeater c. A router solution
39
40
Repeater port 2
B D 3 collision domains
41
Q3. Assume you would design Ethernet for full duplex links only (it would work only on point to point links and bridges). What features of the real Ethernet would you keep or modify ?
Q4. Is a MAC address unique ? Q5. Someone proposed to solution increase the maximum packet size. Discuss the pros and cons.
42
Conclusion
The MAC layer for wireless medium (WiFi) takes care of sharing the radio waves in a local environment. The MAC layer for wired medium (Ethernet) was originally for sharing a cable; in this form it uses a protocol, called CSMA/CD very similar to WiFi The MAC layer for wired medium (Ethernet) has now got rid of any protocol (full duplex Ethernet), using interconnected bridges. It thus forms an interconnection layer of local scope.
43
How ?
A Cyclic Redundancy Checksum (CRC, 32 bits) is computed for every frame. It is a polynomial code. It detects frames that have an error. That is all for Ethernet On wireless MAC there are additional mechanisms
Coding Error recovery See TCP module
44
Solutions
45
Security Issues
Q1. MAC addresses are sent in the clear. What weaknesses does that imply ? A1. On a true shared medium link someone elses data can easily be overheard, or you can impersonate some other system. Q2. What solution can you propose ? A2. One solution is to handle the shared medium as an insecure medium and use end to end security or a virtual private network (VPN): all data is encrypted and overhearing or impersonation is impossible. However, free riding (unauthorized use of network) is possible. An alternative is used with WiFi in infrastructure mode (when there is a base station). The content of the back frame is encrypted, only the header is in the clear. 46
Security Issues
Q1. Are there security benefits in having only point to point links and active hubs, as opposed to shared links ? A1.Yes, an active hub can keep track of which MAC address is connectd to which port, and can thus control who connects to the network. Also, it is not possible to overhear or impersonate someone else.
back
48
2. Original Ethernet is
a. Shared medium, one collision domain per LAN a. Point to point links, one collision domain per LAN b. Point to point links, several collision domains per LAN
3. Todays Ethernet is
a. Shared medium, one collision domain per LAN b. Point to point links, one collision domain per LAN a. Point to point links, several collision domains per LAN
4. WiFi is
a. Shared medium, one collision domain per LAN a. Point to point links, one collision domain per LAN b. Point to point links, several collision domains per LAN
6. An Ethernet Switch is
a. A bridge a. A repeater b. A router
6. A Repeater is
a. A frame forwarding device inside one collision domain a. A bit-forwarding device inside one collision domain a. An IP packet forwarding device inside one collision domain
6. A Bridge is
a. A frame forwarding device inside one local area network a. A bit-forwarding device inside one local area network b. An IP packet forwarding device one local area network
6. A Bridge
a. Coordinates collisions between several cables a. Separates several collision domains
6. A system that allows several cables to be part of the same collision domain is
a. A bridge a. A repeater a. A router
back
50
back
51
52