320 likes | 348 Views
EEC-484/584 Computer Networks. Lecture 13 Wenbing Zhao wenbingz@gmail.com. Outline. CRC Medium Access Control (MAC) Ethernet Manchester Encoding The Ethernet MAC Sublayer Protocol The Binary Exponential Backoff Algorithm. Checksumming: Cyclic Redundancy Check.
E N D
EEC-484/584Computer Networks Lecture 13 Wenbing Zhao wenbingz@gmail.com
Outline CRC Medium Access Control (MAC) Ethernet Manchester Encoding The Ethernet MAC Sublayer Protocol The Binary Exponential Backoff Algorithm EEC-484/584: Computer Networks
Checksumming: Cyclic Redundancy Check view data bits, D, as a binary number choose r+1 bit pattern (generator), G goal: choose r CRC bits, R, such that <D,R> exactly divisible by G (modulo 2) receiver knows G, divides <D,R> by G. If non-zero remainder: error detected! can detect all burst errors less than r+1 bits widely used in practice (Ethernet, 802.11 WiFi) 1/7/2020 3 EEC484/584: Computer Networks
CRC Example Want: D.2r XOR R = nG equivalently: D.2r = nG XOR R equivalently: if we divide D.2r by G, want remainder R D.2r G R = remainder[ ] 1/7/2020 4 EEC484/584: Computer Networks
Medium Access Control Two types of “links”: point-to-point PPP for dial-up access point-to-point link between Ethernet switch and host broadcast (shared wire or medium) old-fashioned Ethernet 802.11 wireless LAN humans at a cocktail party (shared air, acoustical) shared wire (e.g., cabled Ethernet) shared RF (e.g., 802.11 WiFi) shared RF (satellite) 1/7/2020 5 EEC484/584: Computer Networks
MAC Protocols Assumption Single shared broadcast channel Two or more simultaneous transmissions by nodes: interference Collision if node receives two or more signals at the same time MAC protocols Distributed algorithm that determines how nodes share channel, i.e., determine when node can transmit Communication about channel sharing must use channel itself! No out-of-band channel for coordination 1/7/2020 6 EEC484/584: Computer Networks
Ideal MAC Protocol Broadcast channel of rate R bps 1. when one node wants to transmit, it can send at rate R. 2. when M nodes want to transmit, each can send at average rate R/M 3. fully decentralized: no special node to coordinate transmissions no synchronization of clocks, slots 4. simple 1/7/2020 7 EEC484/584: Computer Networks
MAC Protocols: a taxonomy Three broad classes: Channel Partitioning divide channel into smaller “pieces” (time slots, frequency, code) allocate piece to node for exclusive use Random Access channel not divided, allow collisions “recover” from collisions “Taking turns” nodes take turns, but nodes with more to send can take longer turns 1/7/2020 8 EEC484/584: Computer Networks
Channel Partitioning MAC protocols: TDMA TDMA: time division multiple access access to channel in "rounds" each station gets fixed length slot (length = pkt trans time) in each round unused slots go idle example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle 6-slot frame 3 3 4 4 1 1 1/7/2020 9 EEC484/584: Computer Networks
Channel Partitioning MAC protocols: FDMA FDMA: frequency division multiple access channel spectrum divided into frequency bands each station assigned fixed frequency band unused transmission time in frequency bands go idle example: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6 idle time frequency bands FDM cable 1/7/2020 10 EEC484/584: Computer Networks
Random Access Protocols When node has packet to send transmit at full channel data rate R. no a priori coordination among nodes two or more transmitting nodes ➜ “collision”, random access MAC protocol specifies: how to detect collisions how to recover from collisions (e.g., via delayed retransmissions) Examples of random access MAC protocols: ALOHA slotted ALOHA CSMA, CSMA/CD, CSMA/CA 1/7/2020 11 EEC484/584: Computer Networks
Pure ALOHA pure Aloha: simple, no synchronization when frame first arrives transmit immediately collision probability increases: frame sent at t0 collides with other frames sent in [t0-1,t0+1] 1/7/2020 12 EEC484/584: Computer Networks
Pure Aloha efficiency P(success by given node) = P(node transmits) . P(no other node transmits in [p0-1,p0] . P(no other node transmits in [p0,p0+1] = p . (1-p)N-1 . (1-p)N-1 = p . (1-p)2(N-1) … choosing optimum p and then letting n -> infty ... = 1/(2e) = .18 1/7/2020 13 EEC484/584: Computer Networks
Slotted ALOHA Assumptions: all frames same size time divided into equal size slots (time to transmit 1 frame) nodes start to transmit only slot beginning nodes are synchronized if 2 or more nodes transmit in slot, all nodes detect collision Operation: when node obtains fresh frame, transmits in next slot if no collision: node can send new frame in next slot if collision: node retransmits frame in each subsequent slot with prob. p until success 1/7/2020 14 EEC484/584: Computer Networks
Slotted ALOHA Pros single active node can continuously transmit at full rate of channel highly decentralized: only slots in nodes need to be in sync simple Cons collisions, wasting slots idle slots clock synchronization 1/7/2020 15 EEC484/584: Computer Networks
Slotted Aloha efficiency suppose: N nodes with many frames to send, each transmits in slot with probability p prob that given node has success in a slot = p(1-p)N-1 prob that any node has a success = Np(1-p)N-1 max efficiency: find p* that maximizes Np(1-p)N-1 for many nodes, take limit of Np*(1-p*)N-1 as N goes to infinity, gives: Max efficiency = 1/e = .37 Efficiency: long-run fraction of successful slots (many nodes, all with many frames to send) At best: channel used for useful transmissions 37% of time! ! 1/7/2020 16 EEC484/584: Computer Networks
CSMA (Carrier Sense Multiple Access) CSMA: listen before transmit: If channel sensed idle: transmit entire frame If channel sensed busy, defer transmission human analogy: don’t interrupt others! 1/7/2020 17 EEC484/584: Computer Networks
CSMA collisions spatial layout of nodes collisions can still occur: propagation delay means two nodes may not hear each other’s transmission collision: entire packet transmission time wasted note: role of distance & propagation delay in determining collision probability 1/7/2020 18 EEC484/584: Computer Networks
CSMA/CD (Collision Detection) CSMA/CD: carrier sensing, deferral as in CSMA collisions detected within short time colliding transmissions aborted, reducing channel wastage collision detection: easy in wired LANs: measure signal strengths, compare transmitted, received signals difficult in wireless LANs: received signal strength overwhelmed by local transmission strength 1/7/2020 19 EEC484/584: Computer Networks
CSMA/CD collision detection 1/7/2020 20 EEC484/584: Computer Networks
Ethernet “dominant” wired LAN technology: • cheap $20 for NIC • first widely used LAN technology • simpler, cheaper than other schemes • kept up with speed race: 10 Mbps – 10 Gbps Metcalfe’s Ethernet sketch
application transport network link physical fiber physical layer copper (twister pair) physical layer 802.3 Ethernet Standards: Link & Physical Layers • Many different Ethernet standards • common MAC protocol and frame format • different speeds: 2 Mbps, 10 Mbps, 100 Mbps, 1Gbps, 10G bps • different physical layer media: fiber, cable MAC protocol and frame format 100BASE-T2 100BASE-FX 100BASE-TX 100BASE-BX 100BASE-SX 100BASE-T4
Manchester Encoding Binary encoding Hard to distinguish 0 bit (0-volt) from idle (0-volt) Requires clocks of all stations synchronized Manchester encoding used in 10BaseT each bit has a transition allows clocks in sending and receiving nodes to synchronize to each other no need for a centralized, global clock among nodes! EEC-484/584: Computer Networks
Ethernet Frame Structure Preamble: for clock synchronization First 7 bytes with pattern 10101010, last byte with pattern 10101011 The two consecutive 1’s indicate the start of a frame How can the receiver tell the end of the frame? No current on the wire (interesting discussion at http://www.tomshardware.com/forum/19951-42-detecting-length-ethernet-frame) Not considered as part of the header! >= 64 bytes EEC-484/584: Computer Networks
Ethernet Frame Structure Destination address: 6 bytes (48 bits) Highest order bit: 0 individual, 1 multicast; all 1’s broadcast Frames received with non-matching destination address is discarded Type/Length: type of network layer protocol (or length of payload) Pad – used to produce valid frame >= 64 bytes Checksum – 32-bit cyclic redundancy check EEC-484/584: Computer Networks
CSMA with Collision Detection If two stations start transmitting simultaneously, both detect collision and stop transmitting Monitor collision while sending Minimum time to detect collision => minimum frame length Time divided into slots Length of slot = 2t = worst-case round-trip propagation time To accommodate longest path, slot time = 512 bit times = 51.2 msec (10Mbps Ethernet) => min frame length: 51.2 msec X 10 Mbps = 512 b = 64 byte EEC-484/584: Computer Networks
Minimum Time to Detect Collision (in worst-case scenario) To ensure the sender can detect collision All frames must take more than 2t to send so that transmission is still taking place when the noise burst gets back to the sender 1/7/2020 EEC-484/584: Computer Networks Wenbing Zhao
Ethernet MAC Sublayer Protocol Connectionless: No handshaking between sending and receiving NICs Ethernet resides in the Network Interface Card (NIC) Unreliable: receiving NIC doesn’t send acks or nacks to sending NIC stream of datagrams passed to network layer can have gaps (missing datagrams) gaps will be filled if app is using TCP otherwise, app will see gaps Ethernet’s MAC protocol: CSMA/CD EEC-484/584: Computer Networks
Ethernet CSMA/CD algorithm 1. NIC receives datagram from network layer, creates frame 2. If NIC senses channel idle, starts frame transmission If NIC senses channel busy, waits until channel idle, then transmits 3. If NIC transmits entire frame without detecting another transmission, NIC is done with frame ! 4. If NIC detects another transmission while transmitting, aborts and sends jam signal 5. After aborting, NIC enters exponential backoff: after mth collision, NIC chooses K at random from {0,1,2,…,2m-1}. NIC waits K·512 bit times, returns to Step 2 EEC-484/584: Computer Networks
Randomization and Binary Exponential Backoff After 1st collision, station picks 0 or 1 at random, waits that number of slots and tries again After 2nd collision, station picks 0,1,2,3 at random, waits that number of slots and tries again …. After i-th collision, station picks 0,1,…,2i-1 at random, … If 10 <= i < 16, station picks 0,1,…,210-1 at random If i=16, controller reports failure to computer Why randomization is needed? EEC-484/584: Computer Networks
Exercise An IP packet to be transmitted by Ethernet is 60 bytes long. Is padding needed in the Ethernet frame, and if so, how many bytes? EEC-484/584: Computer Networks
Exercise Consider building a CSMA/CD network running at 1 Gbps over a 1-km cable. The signal speed in the cable is 200,000 km/sec. What is the minimum frame size? EEC-484/584: Computer Networks