Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 The Data Link Layer Based on slides by Shiv. Kalyanaraman and B. Sidkar RPI Kurose and Ross from their book Modified by Michalis Faloutsos UCR.

Similar presentations


Presentation on theme: "1 The Data Link Layer Based on slides by Shiv. Kalyanaraman and B. Sidkar RPI Kurose and Ross from their book Modified by Michalis Faloutsos UCR."— Presentation transcript:

1 1 The Data Link Layer Based on slides by Shiv. Kalyanaraman and B. Sidkar RPI Kurose and Ross from their book Modified by Michalis Faloutsos UCR

2 2 Understand principles behind data link layer services: error detection, correction sharing a broadcast channel: multiple access link layer addressing reliable data transfer, flow control Instantiation and implementation of various link layer technologies Goals

3 3 link layer services error detection, correction multiple access protocols and LANs link layer addressing, ARP specific link layer technologies: Ethernet IEEE LANs PPP ATM hubs, bridges, switches Overview

4 4 Link Layer: setting the context - 1

5 5 two physically connected devices: host-router, router-router, host-host unit of data: frame M adapter card application transport network link physical network link physical M M M M H t H t H n H t H n H l H t H n H l frame phys. link data link protocol Link Layer: setting the context - 2

6 6 Link Layer Services - 1 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!

7 7 Link Layer Services - 2 Reliable delivery between two physically connected devices: 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?

8 8 Link Layer Services - 3 Flow Control: pacing between sender and receivers 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

9 9 Link Layer: Implementation Implemented in “adapter” e.g., PCMCIA card, Ethernet card typically includes: RAM, DSP chips, host bus interface, and link interface application transport network link physical network link physical M M M M H t H t H n H t H n H l M H t H n H l frame phys. link data link protocol adapter card

10 10 Some basic concepts Link capacity limits Bandwidth and throughput Bandwidth delay product Note: many times the definition depends on the context

11 11 Link Capacity: Shannon How much capacity (data rate) can a link support? Shannon’s theorem - classic theorem: C = B log2 (1 + S/N) Where C is link capacity B is the bandwidth of the line S is average signal power N is average noise power S/N is the signal to noise ratio Expressed in decibels: db = 10 log10 (S/N) Signal strength is reported relative to noise Assume db = 30, and B = 3000Hz (phone line) Then log10 (S/N) = 3 => S/N = 1000 From Shannon’s: C = 3000 log2(1+1000) ~ 30Kbps

12 12 Bandwidth See PetDav p.40 Bandwidth: the range of frequencies a channel can use Tel. Line: Hz -> 3000Hz How fast we can push bits out Bandwidth commonly used as number of bits per sec that can be transmitted

13 13 Latency How long does a packet take to go from one host to another. Also called “Delay”. Latency = Node processing + Queueing Delay + Transmission Delay + Propagation Delay Depending on context delay can refer to subset of the above delays Link delay = Transmission + Propagation

14 14 Throughput Throughput: the number of bits that can be delivered successfully defined per layer For Link level, same as bandwidth For application level, information that can go through Goodput: useful throughput throughput - overhead

15 15 Round Trip Time Packet is sent from sender to receiver. Receiver sends ACK (assume immediately) to sender. Total time delay incurred between the instance the packet is set to the time the ACK is received. Note: if forward delay = backward delay, RTT = 2 * Delay (although not always accurate).

16 16 Bandwidth Delay Product B, Bandwidth is how fast I can push bits on the link D, Delay is the time it takes for information to arrive at the destination B x D is the amount of bits that can be in flight on a link before the receiver is aware of anything Bandwidth Delay

17 17 Example For a transcontinental channel -- latency = 50 milliseconds. Bandwidth = 45 Mbps. Bandwidth delay product = 50 x x 45 x 10 6 = 2.25 Mbits We can transmit 2.25 M bits before the first bit reaches the other end of the channel !

18 18 What if ACK is expected ? Note if ACK is expected, how many bits can the user transmit before he expects to have an ACK ? RTT X Bandwidth For symmetric channels, we can assume: RTT = 2 X Delay X Bandwidth.

19 19 Modulation Data is in bits -- we need to somehow translate this to signal variations. This process is modulation. Vary either the amplitude, frequency or phase of the signal --- dictated by the bit stream.

20 20 Encoding Represent binary data as signals. Let us ignore modulation for the moment. We have two signals -- high and low for representing 0s and 1s. signals represent voltages. 1 is high voltage, 0 is low voltage As an example +5 V and -5 V.

21 21 The NRZ scheme Straighforward: High voltage = 1 Low voltage = 0

22 22 Problems with NRZ Receiver keeps an average of the signal received so far. Compares incoming signal to this average If significantly higher -- high, if significantly lower, then low. If too many zeroes or ones, difficult to track this average -- the average wanders -- called the baseline wander. If there are clock drifts between the sender and receiver, this cannot be detected -- how many bits were transmitted ?

23 23 Other encoding schemes NRZI : Transition from current signal to encode a `1’. Stay at the same signal if it is a `0’. Solves problem with consecutive 1s but not zeroes.

24 24 Manchester Encoding X-OR the NRZ with a clock 0 --> represented as a low to high transition > represented as a high to low transition.

25 25 Problems with Manchester Encoding Doubles the rate of transitions. Half the time for the receiver to detect each pulse Increase in complexity Bit rate = 1/2 Baud rate for Manchester encoding. baud rate represents signal rate a channel property Bit rate : how many bits (information) I can send Typically: Bit rate is lower than baud rate In some cases, bit rate could be higher than baud rate -- multiple bits mapped onto a signal. See PetDavie

26 26 Error Detection - 1 EDC= Error Detection and Correction bits (redundancy) D = Data protected by error checking, may include header fields Error detection check if there is an error protocol may miss some errors, but rarely larger EDC field yields better detection and correction Error detection code introduce overhead More bits to send!

27 27 Error Detection - 2

28 28 Parity Checking Single Bit Parity: Detect single bit errors Two Dimensional Bit Parity: Detect and correct single bit errors 0 0

29 29 Internet checksum 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. But maybe errors nonetheless? Goal: detect “errors” (e.g., flipped bits) in transmitted segment (note: used at transport layer only)

30 30 Sharing A Link

31 31 Multiple Access Links and Protocols Three types of “links”: Point-to-point (single wire, e.g. PPP, SLIP) Broadcast (shared wire or medium; e.g, Ethernet, Wavelan, etc.) Switched (e.g., switched Ethernet, ATM etc)

32 32 Multiple Access Protocols - 1 single shared communication channel two or more simultaneous transmissions by nodes: interference only one node can send successfully at a time multiple access protocol: distributed algorithm that determines how stations share channel, i.e., determine when a station can transmit

33 33 Multiple Access Protocols - 2 multiple access protocol (cont.): communication about channel sharing must use channel itself! Issues in multiple access protocols: synchronous or asynchronous information needed about other stations robustness (e.g., to channel errors) performance

34 34 Multiple Access protocols - 3 claim: humans use multiple access protocols all the time How do we share?

35 35 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, simple, decentralized

36 36 Channel Partitioning MAC protocols: TDMA - 1 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

37 37 Channel Partitioning MAC protocols: FDMA - 2 Example: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6 idle frequency bands time

38 38 Channel Partitioning (CDMA) - 1 CDMA (Code Division Multiple Access) used mostly in wireless broadcast channels (cellular, satellite, etc) all users share same frequency, but each user has own “chipping” sequence (ie code) to encode data Users can transmit at the same time!

39 39 Channel Partitioning (CDMA) - 2 Encoded signal = (original data) X (chipping sequence) Decoding: (received data) X (chipping sequence) Think of it as multiplying with 1 or -1 twice Not in Peterson Davie!

40 40 CDMA Encode/Decode

41 41 CDMA: two-sender interference

42 42 Performance of channel partitioning Dividing resources (e.g in time) Avoids collisions May lead to inefficient use of the channel A channel not used by “owner” stays idle Assume: N users: Channel capacity C / N per user Only one user active: 1/N utilization

43 43 Performance of Fixed Assignment Protocols - 1 Fixed assignment protocols are ideal for continuous streams such as video or audio What about for packet switched data? A “perfect” multiple access scheme would always use the channel when there are packets waiting (statistical multiplexing) The mean delay for statistical multiplexing is just like for the M / M / 1 queue: where is the arrival rate and  is the service rate

44 44 Performance of Fixed Assignment Protocols - 2 OTOH fixed assignment protocols divide the channel into N separate independent,  /N identical subchannels If each user has arrival rate /N, each user/subchannel pair can be modeled as a separate M / M / 1 queue And the mean delay for a packet is So, if we use fixed assignment protocols for packet switched data, mean delay goes up by a factor of N!!

45 45 Random Access Protocols - 1 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)

46 46 Random Access Protocols - 2 Examples of random access MAC protocols: ALOHA (not in PetDavie) slotted ALOHA (not in PetDavie) CSMA and CSMA/CD

47 47 The Rules of Sharing CSMA: Collision Sensing Multiple Access Sense the channel before sending CSMA/CD: CSMA with Collision Detection Sense the channel before sending Sense the channel WHILE sending too

48 48 Pure (unslotted) ALOHA - 1 Unslotted Aloha: simpler, no synchronization pkt needs transmission: send when you have a packet (expect ack) If failure, wait some time and retry Collision: pkt sent at t 0 collide with pkts sent in [t 0 -1, t 0 +1]

49 49 Carrier Sensing Multiple Access (CSMA) - 1 In some shorter distance networks, it is possible to listen to the channel before transmitting In radio networks, this is called “ sensing the carrier” Human analogy: Don’t interrupt others The CSMA protocol works just like Aloha except: If the channel is sensed busy, then the user waits to transmit its packet, and a collision is avoided This really improves the performance in short distance networks!

50 50 Carrier Sensing Multiple Access (CSMA) - 2 How long does a blocked user wait before trying again to transmit its packet? Three basic variants: 1-persistent: Blocked user continuously senses channel until its idle, then transmits 0-persistent: Blocked user waits a randomly chosen amount of time before sensing channel again p-persistent: combine the two: with probability p behave like a 1-persistent, with 1-p, behave like a 0-persistent

51 51 CSMA collisions collisions can occur: propagation delay means two nodes may not year hear each other’s transmission collision: entire packet transmission time wasted spatial layout of nodes along ethernet note: role of distance and propagation delay in determining collision prob.

52 52 CSMA/CD (Collision Detection) CSMA improves performance, but still it wastes the channel during collisions Collision Detection: listen while transmitting (in addition to listening before transmitting) If we detect a collision while transmitting, abort the transmission and free up the channel sooner This idea was proposed by R. Metcalfe and Boggs at Xerox PARC in the mid 1970s under the name Ethernet. Human analogy: the polite conversationalist

53 53 CSMA/CD collision detection

54 54 “Taking Turns” MAC protocols - 1 Channel partitioning MAC protocols: share channel efficiently at high load inefficient at low load: delay in channel access, 1/N bandwidth allocated even if only 1 active node! Random access MAC protocols efficient at low load: single node can fully utilize channel high load: collision overhead “Taking turns” protocols look for best of both worlds!

55 55 Polling: Master node “invites” slave nodes to transmit in turn Request to Send, Clear to Send messages Concerns: polling overhead latency single point of failure (master) Token passing: Control token passed from one node to next sequentially. Token message Concerns: token overhead latency single point of failure (token) “Taking Turns” MAC protocols - 2

56 56 Reservation-based protocols - 1 Distributed Polling: Time divided into slots Begins with N short reservation slots reservation slot time equal to channel end-end propagation delay station with message to send posts reservation reservation seen by all stations

57 57 Reservation-based protocols - 2 After reservation slots, message transmissions ordered by known priority

58 58 Ethernet “Dominant” LAN technology: Cheap $20 for 100Mbs! First widely used LAN technology Simpler, cheaper than token LANs and ATM Kept up with speed race: 10, 100, 1000 Mbps Metcalfe’s Ethernet sketch

59 59 Ethernet Frame Structure - 1 Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame Preamble: 7 bytes with pattern followed by one byte with pattern Used to synchronize receiver, sender clock rates

60 60 Ethernet Frame Structure - 2 Addresses: 6 bytes, frame is received by all adapters on a LAN and dropped if address does not match Type: indicates the higher layer protocol, mostly IP but others may be supported such as Novell IPX and AppleTalk) CRC: checked at receiver, if error is detected, the frame is simply dropped

61 61 Ethernet Basics Ethernet uses 1-persistent CSMA/CD on coaxial cable at 10 Mbps (802.3 allows other speeds & media) The maximum cable length allowed: 500m Longer distances covered using repeaters to connect multiple “segments” of cable Limit: No two stations can be separated by more than 2500 meters and 4 repeaters Including the propagation delay for 2500m and the store and forward delay in 4 repeaters, the maximum time for a bit to travel between any two stations is  max =25.6  sec (one way, 51.2  sec Round-trip time) Packet size at least 512bits

62 62 Limitation on packet size and length (distance of hosts) Why? Max Round-trip time: 51.2  sec Packet size at least 512bits We want: Sender is able to detect collisions Sender senses no collision = successful reception by all nodes on the wire (LAN) Thus: Transmissions of packets must be long enough Distance between nodes short enough

63 63 Ethernet: uses CSMA/CD A: sense channel, if idle and you have a packet then { transmit and monitor the channel; If detect another transmission then { abort and send jam signal; update # collisions; delay as required by exponential backoff algorithm; goto A } else {done with the frame; set collisions to zero} } else {wait until ongoing transmission is over and goto A}

64 64 Ethernet’s Back-Off Intuition: double the amount of time you wait every time you fail for the same packet Ethernet’s Exponential backoff: 1.If your packet is in a collision, set K=2 2.Pick a number k at random from {0, 1,..,K-1} 3.After k*  seconds, sense channel, transmit if idle 4.If collision occurs, let K=2 x K, go to step 2 After 10 retries, stop doubling K After 16 retries, give up and tell layer above “I give up”

65 65 Ethernet’s Back-off: Randomness Why do we pick the time to wait randomly? If N nodes collide: Deterministic delay leads to synchronization They will collide again Randomness spreads them out

66 66 Ethernet’s CSMA/CD In order to ensure that every collision is “heard" by all stations, when a station detects a collision, it jams the channel Example Two stations, A and B, are close together A third station, C, is far away A and B will detect each other’s transmission very quickly and shut off This will only cause a short blip which may not be detected by C but will still cause enough errors to destroy C’s packet

67 67 Ethernet Technologies: 10Base2 10: 10Mbps; 2: under 200 meters max cable length Thin coaxial cable in a bus topology Repeaters used to connect up to multiple segments Repeater repeats bits it hears on one interface to its other interfaces: physical layer device!

68 68 10BaseT and 100BaseT /100 Mbps rate; latter called “fast ethernet” T stands for Twisted Pair Hub to which nodes are connected by twisted pair, thus “star topology”

69 69 Gbit Ethernet Use standard Ethernet frame format Allows for point-to-point links and shared broadcast channels In shared mode, CSMA/CD is used; short distances between nodes to be efficient Uses hubs, called here “Buffered Distributors” Full-Duplex at 1 Gbps for point-to-point links

70 70 Summary of MAC protocols What do you do with a shared media? Channel Partitioning: time, frequency or code Time Division,Code Division, Frequency Division Random partitioning (dynamic), ALOHA, S-ALOHA, CSMA, CSMA/CD carrier sensing: easy in some technologies (wire), hard in others (wireless) CSMA/CD used in Ethernet Taking Turns polling from a central cite, token passing

71 71 Slides Not used

72 72 Token Rings (IEEE 802.5) A ring topology is a single unidirectional loop connecting a series of stations in sequence Each bit is stored and forwarded by each station’s network interface

73 73 Token Rings: IEEE Versions that operate at 1, 4, and 16 Mbps over shielded twisted pair copper wire Max token holding time: 10 ms, limiting frame length SD, ED mark start, end of packet

74 74 AC: access control byte: Token bit: value 0 means token can be seized, value 1 means data follows FC Priority bits: priority of packet Reservation bits: station can write these bits to prevent stations with lower priority packet from seizing token after token becomes free Token Ring: IEEE

75 75 FC: frame control used for monitoring and maintenance Source, destination address: 48 bit physical address, as in Ethernet Data: packet from network layer Checksum: CRC FS: frame status: set by dest., read by sender set to indicate destination up, frame copied OK from ring DLC-level ACKing Token Ring: IEEE

76 76 Token Ring: IEEE After transmitting one or more packets (depending on the rules of the protocol), the node transmits a new token to the next node in one of 3 ways: 1.Single Packet Mode: Token is transmitted after receiving the last bit of transmitted packet(s) 2.Multiple Token Mode: Token is transmitted immediately after the last bit of the packet(s) is transmitted In small rings, the last two are the same

77 77 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 exactly divisible by G (modulo 2) receiver knows G, divides by G. If non-zero remainder: error detected! can detect all burst errors less than r+1 bits Widely used in practice (ATM, HDCL)

78 78 CRC Example Want: D. 2r XOR R = nG equivalently: D. 2r = nG XOR R equivalently: if we divide D. 2r by G, want reminder R R = remainder[ ] D. 2r G See picture from book (this is weird)

79 79 4B/5B encoding Insert extra bits into bit stream to break long sequences of 0’s and 1’s. Specifically every four bits of data encoded into a five bit code. Codes such that no more than 2 trailing zeroes and no more than 1 leading zero. (When codes are transmitted back to back no more than 3 consecutive zeroes. Resulting codes transmitted using NRZI. Specific codes Line idle Line dead Halt

80 80 10BaseT and 100BaseT - 1 Max distance from node to Hub is 100 meters Hub can gather monitoring information, statistics for display to LAN administrators

81 81 Pure (unslotted) ALOHA - 1 Unslotted Aloha: simpler, no synchronization pkt needs transmission: send when you have a packet Collision probability increases: pkt sent at t 0 collide with other pkts sent in [t 0 -1, t 0 +1]

82 82 Success if none starts right before or right after: P(success by given node) = P(node transmits). P(no other node transmits in [t 0 -1,t 0 ]. P(no other node transmits in [t 0,t 0 +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) … choosing optimum p as N -> infty... = 1/(2e) =.18 Pure (unslotted) ALOHA - 2

83 83 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

84 84 Slotted Aloha Efficiency Q: What is max fraction slots successful? A: Suppose N stations have packets to send each transmits in slot with probability p prob. successful transmission S is: by single node: S= p (1-p) (N-1) by any of N nodes S = Prob (only one transmits) = N p (1-p) (N-1) … choosing optimum p as N -> infty... = 1/e =.37 as N -> infty At best: channel use for useful transmissions 37% of time!

85 85 Performance Comparison S = throughput = “goodput” (success rate) G = offered load = Np Pure Aloha Slotted Aloha protocol constrains effective channel throughput!


Download ppt "1 The Data Link Layer Based on slides by Shiv. Kalyanaraman and B. Sidkar RPI Kurose and Ross from their book Modified by Michalis Faloutsos UCR."

Similar presentations


Ads by Google