640 likes | 792 Views
CSE401N :Computer Networks. Lecture-15 Data Link Layer EDC MAC. Our goals: Understand principles behind data link layer services: error detection, correction done! sharing a broadcast channel: multiple access reliable data transfer, flow control: done! link layer forwarding
E N D
CSE401N:Computer Networks Lecture-15 Data Link Layer EDC MAC
Our goals: Understand principles behind data link layer services: error detection, correction done! sharing a broadcast channel: multiple access reliable data transfer, flow control: done! link layer forwarding Instantiation and implementation of various link layer technologies Preview: The Data Link Layer Overview: • link layer services • error detection, correction • multiple access protocols and LANs • link layer addressing, ARP • specific link layer technologies: • Ethernet • hubs, bridges, switches • IEEE 802.11 LANs and wireless • PPP • ATM CSE 401N DLL
Link Layer: setting the context CSE 401N DLL
M H H H H H H H H H t t n n t t n l l M M application transport network link physical M Link Layer: setting the context • two physically connected devices: • host-router, router-router, host-host • unit of data: frame network link physical data link protocol M frame phys. link adapter card CSE 401N DLL
“link” Link Layer: Introduction Some terminology: • hosts and routers are nodes (bridges and switches too) • communication channels that connect adjacent nodes along communication path are links • wired links • wireless links • LANs • 2-PDU is a frame,encapsulates datagram CSE 401N DLL
Link layer: Context transportation analogy • trip from New Haven to San Francisco • taxi: home to union station • train: union station to JFK • plane: JFK to San Francisco airport • limo: airport to hotel • Data-link layer has responsibility of transferring datagram from one node to adjacent node over a link • Datagram transferred by different link protocols over different links: • e.g., Ethernet on first link, frame relay on intermediate links, 802.11 on last link CSE 401N DLL
Link Layer Services • Framing, link access: • encapsulate datagram into frame, adding header, trailer • implement channel access if shared medium, • ‘physical addresses’ used in frame headers to identify source, dest • different from IP address! • Reliable delivery between two physically connected devices: • we learned how to do this already (chapter 3)! • seldom used on low bit error link (fiber, some twisted pair) • wireless links: high error rates • Q: why both link-level and end-end reliability? CSE 401N DLL
Link Layer Services (more) • Flow Control: • pacing between adjacent sending and receiving nodes • Error Detection: • errors caused by signal attenuation, noise. • receiver detects presence of errors: • signals sender for retransmission or drops frame • Error Correction: • receiver identifies and corrects bit error(s) without resorting to retransmission • Half-duplex and full-duplex • with half duplex, nodes at both ends of link can transmit, but not at same time CSE 401N DLL
frame frame Adaptors Communicating datagram rcving node link layer protocol sending node adapter adapter • receiving side • looks for errors, rdt, flow control, etc • extracts datagram, passes to rcving node • adapter is semi-autonomous • link & physical layers • {RAM, DSP Chips, a host bus interface, link interface} • link layer implemented in “adaptor” (aka NIC) • Ethernet card, PCMCI card, 802.11 card • sending side: • encapsulates datagram in a frame • adds error checking bits, rdt, flow control, etc. CSE 401N DLL
OSI TCP/IP Application Application Presentation Session Transport Transport Network Internet Data Link Network Interface Physical CSE 401N DLL
Outline • Link layer overview • Error detection and correction CSE 401N DLL
Error Detection • EDC= Error Detection and Correction bits (redundancy) • D = Data protected by error checking, may include header fields • Error detection not 100% reliable! • protocol may miss some errors, but rarely • larger EDC field yields better detection and correction CSE 401N DLL
Error Detection: Parity Checking Two Dimensional Bit Parity: Detect and correct single bit errors Single Bit Parity: Detect single bit errors 1 Errors are generally bursty, i.e. several consecutive bits are flipped: column parity. 0 0 CSE 401N DLL
Sender: treat segment contents as sequence of 16-bit integers checksum: addition (1’s complement sum) of segment contents sender puts checksum value into checksum field Receiver: compute checksum of received segment check if computed checksum equals checksum field value: NO - error detected YES - no error detected Internet Checksum Goal: detect “errors” (e.g., flipped bits) in transmitted segment (note: used at transport layer only) CSE 401N DLL
Cyclic Redundancy Check: Background • Widely used in practice (ATM, Ethernet, HDCL,) • For a given data D, consider it as a polynomial D(x) • consider the string of 0 and 1 as the coefficients of a polynomial • e.g. consider string 10011 as x4+x+1 • addition and subtraction are modular 2, thus the same as xor • Choose generator polynomial G(x) with r+1 bits, where r is called the degree of G(x) CSE 401N DLL
Cyclic Redundancy Check: Objective • Given data G(x) and D(x), choose R(x) with r bits, such that • D(x)xr+R(x) is exactly divisible by G(x) • The bits correspond to D(x)xr+R(x) are sent to the receiver • Since G(x) is global, when the receiver receives the transmission T’(x), it divides T’(x) by G(x) • If non-zero remainder: error detected! • If zero remainder, assumes no error x + CSE 401N DLL
CRC: Steps and an Example • Suppose the degree of G(x) is r • Append r zero to D(x), i.e. consider D(x)xr • Divide D(x)xr by G(x). • Let R(x) denote the reminder • Send <D, R> to the receiver CSE 401N DLL
CRC Example Example: D=101110, G=1001, r=3 Want: D.2r XOR R = nG equivalently: D.2r = nG XOR R equivalently: if we divide D.2r by G, remainder is R D.2r G R = remainder[ ] In CRC calculations, addition and subtraction are equivalent to bitwise exclusive-or (XOR) Sender transmit: 101110 011 CSE 401N DLL
The Power of CRC • Let T(x) denote D(x)xr+R(x), and E(x) the polynomial of the error bits • The received signal is T(x)+E(x) • Since T(x) is divisible by G(x), we only need to consider E(x) divided by G(x) • A single bit of error: E(x) = xi • If G(x) contains two or more terms, E(x) is not divisible by G(x) • An odd number of errors: E(x) has an odd number of terms: • Lemma: if E(x) has an odd number of terms, E(x) cannot be divisible by (x+1) • suppose E(x) = (x+1)F(x), let x=1, the left hand will be 1, while the right hand will be 0 • If G(x) contains x+1 as a factor, E(x) will not be divided by G(x) • Many more errors can be detected by designing the right G(x) CSE 401N DLL
Example G(x) • CRC-16: x16+x15+x2+1 • CRC-CCITT: x16+x12+x5+1 • Both can catch • all single or double bit errors • all odd number of bit errors • All burst errors of length 16 or less • >99.99% of the 17 or 18 bits burst errors CSE 401N DLL
Part-2 CSE 401N DLL
Outline • Media access control (MAC) protocols: overview • Random MAC protocols CSE 401N DLL
Multiple Access Links and Protocols 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) • traditional Ethernet • 802.11 wireless LAN • satellite CSE 401N DLL
Multiple Access Protocols • Single shared broadcast channel • Two or more simultaneous transmissions by nodes: interference • only one node can send successfully at a time (see CDMA for an exception) multiple access protocol • Algorithm that determines how nodes share channel, i.e., determines when node can transmit • Communication about channel sharing must use channel itself! • What to look for in multiple access protocols: • synchronous or asynchronous • information needed about other stations • robustness (e.g., to channel errors) • performance CSE 401N DLL
Ideal Mulitple Access Protocol Broadcast channel of rate R bps 1. Efficiency: when one node wants to transmit, it can send at rate R. 2. Fairness: when M nodes want to transmit, each can send at average rate R/M 3. Decentralized: • no special node to coordinate transmissions • no synchronization of clocks 4. Simple CSE 401N DLL
Multiple Access protocols • claim: humans use multiple access protocols all the time • class can "guess" multiple access protocols • multiaccess protocol 1: • multiaccess protocol 2: • multiaccess protocol 3: • multiaccess protocol 4: CSE 401N DLL
MAC Protocols: a Taxonomy Three broad classes: • Channel Partitioning • divide channel into smaller “pieces” (time slots, frequency) • allocate piece to node for exclusive use • Random Access • allow collisions • “recover” from collisions • “Taking-turns” • tightly coordinate shared access to avoid collisions Goal: efficient, fair, decentralized, simple CSE 401N DLL
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 CSE 401N DLL
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 1 2 3 frequency bands 4 5 6 CSE 401N DLL
Example: 4 users FDMA frequency time TDMA frequency time FDMA and TDMA CSE 401N DLL
TDMA and FDMA • Often combined in practice, for example, in cellular phone networks: • TDMA cellular phones use 30 KHz channels, with each channel divided into three time slots. A single handset uses one timeslot for sending and the other for receiving. • e.g. Cingular (Nokia 8265, TDMA 800/ 1900 MHz, AMPS 800 mHz ), AT&T Wireless • GSM uses 200 KHz channels divided into eight time slots. A single handset uses one slot in two channels for sending and receiving. • Cingular, T-Mobile, AT&T are converting to it CSE 401N DLL
Channel Partitioning (CDMA) CDMA (Code Division Multiple Access) • Used mostly in wireless broadcast channels (cellular, satellite, etc) • Unique “code” assigned to each user; i.e., code set partitioning • All users share same frequency, but each user has its own “chipping” sequence (i.e., code) to encode data • e.g. code = 1 1 1 1 -1 -1 1 1 Examples: MetroPCS, Sprint and Verizon CSE 401N DLL
CDMA: Encoding and Decoding • Assume original data are represented by 1 and -1 • Encoded signal = (original data) x (chipping sequence) • Decoding: inner-product (summation of bit-by-bit product) of encoded signal and chipping sequence • if inner-product > threshold, the data is 1; else -1 CSE 401N DLL
CDMA Encode/Decode Code: 1 1 1 -1 1 -1 -1 -1 CSE 401N DLL
CDMA: Deal with Multiple-User Interference • Two codes Ci and Cj are orthogonal, if • , where we use “.” to denote inner product, e.g. • If codes are orthogonal, multiple users can “coexist” and transmit simultaneously with minimal interference: C1: 1 1 1 -1 1 -1 -1 -1 C2: 1 -1 1 1 1 -1 1 1 ----------------------------------------- C1 . C2 = 1 +(-1) + 1 + (-1) +1 + 1+ (-1)+(-1)=0 CSE 401N DLL Analogy: Speak in different languages!
CDMA: Two-Sender Interference Code 1: 1 1 1 -1 1 -1 -1 -1 Code 2: 1 -1 1 1 1 -1 1 1 . . . . CSE 401N DLL
Outline • Media access control (MAC) protocols: overview • Random MAC protocols • Random Access • Compete for each packet • Aloha, CSMA, CSMA/CD • “Taking-turns” CSE 401N DLL
Random Access Protocols • When node has packets 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: • slotted ALOHA and pure ALOHA • CSMA and CSMA/CD, CSMA/CA CSE 401N DLL
Slotted Aloha • Time is divided into equal size slots (= pkt trans. time) • Node with new arriving pkt: transmit at beginning of next slot • If collision: retransmit pkt in future slots with probability p, until successful. Success (S), Collision (C), Empty (E) slots CSE 401N DLL
Slotted Aloha Efficiency Q: What is the fraction of successful slots? A: Suppose N stations have packets to send • each transmits in a slot with probability p • prob. successful transmission S(p) is: by single node: S(p)= p (1-p)(N-1) by any one of the N nodes S(p) = Prob (only one transmits) = N p (1-p)(N-1) when p=1/N, S(p) achieves the maximum (1-1/N)(N-1) CSE 401N DLL
At best: channel use for useful transmissions 37% of time! Maximum Efficiency vs. N 1/e = 0.37 CSE 401N DLL
Pure (unslotted) Aloha • Unslotted Aloha: simpler, no synchronization • Whenever pkt needs transmission: • send without awaiting for the beginning of slot • Collision probability increases: • pkt sent at t0 collide with other pkts sent in [t0-1, t0+1] CSE 401N DLL
0.4 0.3 Slotted Aloha protocol constrains effective channel throughput! 0.2 0.1 Pure Aloha 1.5 2.0 0.5 1.0 G = offered load = Np Pure Aloha (cont.) P(success by given node) = P(node transmits) . P(no other node transmits in [t0-1,t0] . P(no other node transmits in [t0, t0+1] = p . (1-p)N-1 . (1-p)N-1 P(success by any of N nodes) = N p . (1-p)N-1 . (1-p)N-1 Bound: 1/(2e) = .18 S = throughput = “goodput” (success rate) CSE 401N DLL
CSMA: Carrier Sense Multiple Access CSMA: listen before transmit: • If channel sensed idle: transmit entire pkt • If channel sensed busy, defer transmission • Persistent CSMA: retry immediately with probability p when channel becomes idle (may cause instability) • Non-persistent CSMA: retry after random interval • human analogy: don’t interrupt others! CSE 401N DLL
CSMA collisions spatial layout of nodes along Ethernet collisions can occur: propagation delay means two nodes may not year hear each other’s transmission collision: entire packet transmission time wasted note: role of distance and propagation delay in determining collision prob. CSE 401N DLL
CSMA/CD (Collision Detection) CSMA/CD: carrier sensing, deferral as in CSMA • collisions detected within short time • colliding transmissions aborted, reducing channel wastage • persistent or non-persistent retransmission • collision detection: • easy in wired LANs: measure signal strengths, compare transmitted, received signals • difficult in wireless LANs: receiver shut off while transmitting • human analogy: the polite conversationalist CSE 401N DLL
CSMA/CD Collision Detection instead of wasting the whole packettransmission time, abort after detection. CSE 401N DLL
MAC Rules & Collision Detection/Backoff CSE 401N DLL
MAC Rules and Collision Detection/Backoff CSE 401N DLL
Efficiency of CSMA/CD • Given collision detection, instead of wasting the whole packet transmission time (a slot), we only waste the time needed to detect collision. • In the normal case, we try approximately e times before each successful transmission, then for each successful transmission, which takes P/C, we waste a total of 2eT (5T) seconds on collision, where T is one-way propagation delay P: packet size, e.g. 1000 bitsC: link capacity, e.g. 10Mbps P/C CSE 401N DLL