Ee 122: Ethernet: Ion Stoica Tas: Junda Liu, DK Moon, David Zats
Ee 122: Ethernet: Ion Stoica Tas: Junda Liu, DK Moon, David Zats
CSMA/CD
Frame structure Length/timing constraints due to Collision Detection Repeaters and hubs Bridges and switches Self-learning (plug-and-play) Spanning trees (time permitting)
Share channel efficiently and fairly at high load Inefficient at low load (where load = # senders):
Eliminates empty slots without causing collisions Overhead in acquiring the token Vulnerable to failures (e.g., failed node or lost token) Efficient at low load: single node can fully utilize channel High load: collision overhead
Carrier sense
Listen before speaking, and dont interrupt Checking if someone else is already sending data and waiting till the other node is done
Collision detection
If someone else starts talking at the same time, stop Realizing when two nodes are transmitting at once by detecting that the data on the wire is garbled
Dont start talking again right away Waiting for a random time before trying again
Randomness
CSMA Collisions
Collisions can still occur:
propagation delay means two nodes may not hear each others transmission in time. At time t1, D still hasnt heard Bs signal sent at the earlier time t0, so D goes ahead and transmits: failure of carrier sense.
Collision:
entire packet transmission time wasted
5
Collisions detected within short time Colliding transmissions aborted, reducing wastage
Collision detection
Easy in wired LANs: measure signal strengths, compare transmitted, received signals Difficult in wireless LANs
Reception shut off while transmitting Even if on, might not be able to hear the other sender, even though the receiver can Leads to use of collision avoidance instead
Carrier sense: wait for link to be idle Collision detection: listen while transmitting
Why enforce a minimum packet size? Give a host enough time to detect collisions In Ethernet, minimum packet size = 64 bytes (two 6-byte addresses, 2-byte type, 4-byte CRC, and 46 bytes of data) If host has less than 46 bytes to send, the adaptor pads (adds) bytes to make it 46 bytes What is the relationship between minimum packet size and the length of the LAN?
9
Host 1
b) Time = t + d; Host 2 starts to send a frame, just before it hears from host 1s frame c) Time = t + 2*d; Host 1 hears Host 2s frame detects collision
Host 1
Time to propagate a packet from one end to the other And B sees an idle line at a time just before t+d so B happily starts transmitting a packet But A cant see collision until t+2d
11
So, A should keep transmitting during this period and keep an eye out for a possible collision Maximum length of the wire: 2,500 meters Minimum length of a frame: 512 bits (64 bytes)
12
512 bits = 51.2 sec (at 10 Mbit/sec) For light in vacuum, 51.2 sec 15,000 meters vs. 5,000 meters round trip to wait for collision
Preamble: synchronization
Seven bytes with pattern 10101010, followed by one byte with pattern 10101011 Used to synchronize receiver & sender Usually IP (but also Novell IPX, AppleTalk, )
13
If destination address matches the adaptors Or the destination address is the broadcast address (ff:ff:ff:ff:ff:ff) Or the destination address is a multicast group receiver belongs to Or the adaptor is in promiscuous mode Assigned by NIC vendors (top three octets specify vendor) During any given week, > 500 vendor codes seen at LBNL
Data:
14
Maximum: 1,500 bytes Minimum: 46 bytes (+14 bytes header + 4 byte trailer = 512 bits)
Ethernet, cont
15
Connectionless No handshaking between sending and receiving adapter Unreliable Receiving adapter doesnt send ACKs or NACKs Packets passed to network layer can have gaps Gaps will be filled if application is using TCP Otherwise, application will see the gaps 2,700 page IEEE 802.3 standardization http://standards.ieee.org/getieee802/802.3.html Note, classical Ethernet has no length field instead, sender pauses 9.2 sec when done 802.3 shoehorns in a length field
Benefits of Ethernet
Easy to administer and maintain Inexpensive Increasingly higher speed Evolved from shared media to switches
And from electrical signaling to also optical Changes everything except the frame format A good general lesson for evolving the Internet:
The right interface (service model) can often accommodate unanticipated changes
16
Physical layer: electrical signals (repeaters and hubs) Link layer: frames (bridges and switches) Network layer: packets (routers)
Application gateway
Transport gateway Router Bridge, switch Repeater, hub Frame header Packet header TCP header User data
17
Electrical signal becomes weaker as it travels Imposes a limit on the length of a LAN
Analog electronic device Continuously monitors electrical signals on each LAN Transmits an amplified copy
Repeater
18
Do not necessarily amplify the signal Also operates at the physical layer
hub
hub
hub
hub
19
Every bit is sent everywhere So, aggregate throughput is limited E.g., three departments each get 10 Mbps independently and then if connect via a hub must share 10 Mbps Repeaters/hubs do not buffer or interpret frames So, cant interconnect between different rates or formats E.g., no mixing 10 Mbps Ethernet & 100 Mbps Ethernet
20
5 Minute Break
Questions Before We Proceed?
21
Extracts destination address from the frame Looks up the destination in a table Forwards the frame to the appropriate LAN segment
collision domain
collision domain
22
A
switch
23
24
Only forwards frames as needed Filters frames to avoid unnecessary load on segments Sends frames only to segments that need to see them Extends the geographic span of the network Separate collision domains allow longer distances Improves privacy by limiting scope of frames Hosts can snoop the traffic traversing their segment but not all the rest of the traffic If needed, applies carrier sense & collision detection Does not transmit when the link is busy Applies exponential back-off after a collision Joins segments using different technologies
Higher cost
More complicated devices that cost more money Bridge/switch must receive and parse the frame and perform a look-up to decide where to forward Introduces store-and-forward delay
25
Bridge/switch needs to construct a forwarding table Ideally, without intervention from network administrators Solution: self-learning
Large benefit if switch/bridge forward frames only on segments that need them
Allows concurrent use of other links Maps destination MAC address to outgoing interface Goal: construct the switch table automatically
B
Switch table
A
switch
26
Inspect source MAC address Associate address with the incoming interface Store mapping in the switch table Use time-to-live field to eventually forget the mapping
Soft state
B
27
Hopefully, this case wont happen very often When destination replies, switch learns that node, too
B
28
29
Problems?
Upon receiving a frame with an unfamiliar destination Upon receiving a frame sent to the broadcast address Implemented by flooding
Broadcast storm
30
Ensure the forwarding topology has no loops Avoid using some of the links when flooding to prevent loop from forming Spanning tree (K&R pp. 406-408) Sub-graph that covers all vertices but contains no cycles Links not in the spanning tree do not forward frames
31
root
Three hops
33
Initially, each switch proposes itself as the root Switch sends a message out every interface proposing itself as the root with distance 0 Example: switch X announces (X, 0, X) Switches update their view of the root Upon receiving message (Y, d, Z) from Z, check Ys id If new id smaller, start viewing that switch as root Switches compute their distance from the root Add 1 to the distance received from a neighbor Identify interfaces not on shortest path to the root and exclude them from the spanning tree If root or shortest distance to it changed, flood updated message (Y, d+1, X)
Switch #4 thinks it is the root Sends (4, 0, 4) message to 2 and 7 Then, switch #4 hears from #2 Receives (2, 0, 2) message from 2 and thinks that #2 is the root And realizes it is just one hop away Then, switch #4 hears from #7 Receives (2, 1, 7) from 7 And realizes this is a longer path So, prefers its own one-hop path And removes 4-7 link from the tree
3
2 4 7
34
35
Switch #2 hears about switch #1 Switch 2 hears (1, 1, 3) from 3 Switch 2 starts treating 1 as root And sends (1, 2, 2) to neighbors Switch #4 hears from switch #2 Switch 4 starts treating 1 as root And sends (1, 3, 4) to neighbors Switch #4 hears from switch #7 Switch 4 receives (1, 3, 7) from 7 And realizes this is a longer path So, prefers its own three-hop path And removes 4-7 Iink from the tree
3
2 4 7
Periodically reannouncing itself as the root (1, 0, 1) Other switches continue forwarding messages Switch waits to hear from others Eventually times out and claims to be the root
36
Topology restricted to a spanning tree Large networks require large ARP tables Broadcast storms can cause the network to collapse Cant accommodate non-Ethernet segments (why not?)
37
Summary
Hubs & repeaters: physical-layer interconnects Bridges / switches: link-layer interconnects Self learning of the switch table Spanning trees
39