60
1 CSE524: Lecture 15 Data-link layer Functions

CSE524: Lecture 15

  • Upload
    maida

  • View
    19

  • Download
    0

Embed Size (px)

DESCRIPTION

Data-link layer Functions. CSE524: Lecture 15. Administrative. No office hours next Wednesday Demos 12/9 See web site for available slots Sign up for a slot after class or via e-mail Read e-mail message for instructions on what to submit before demo. Where we’re at…. - PowerPoint PPT Presentation

Citation preview

Page 1: CSE524: Lecture 15

1

CSE524: Lecture 15

Data-link layerFunctions

Page 2: CSE524: Lecture 15

2

Administrative

• No office hours next Wednesday• Demos 12/9

– See web site for available slots– Sign up for a slot after class or via e-mail– Read e-mail message for instructions on what to

submit before demo

Page 3: CSE524: Lecture 15

3

Where we’re at…• Internet architecture and history• Internet protocols in practice• Application layer• Transport layer• Network layer• Data-link layer

– Functions– Specific link layer examples and devices

• Physical layer

Page 4: CSE524: Lecture 15

4

Data-link layer

Page 5: CSE524: Lecture 15

5

Data-link layer

• Two physically connected devices:– host-router, router-router, host-host, host-switch, host-hub

• Implemented on network adapter card– typically includes: RAM, DSP chips, host bus interface,

and link interface

applicationtransportnetwork

linkphysical

networklink

physical

M

M

MM

Ht

HtHn

HtHnHl MHtHnHl

framephys. link

data linkprotocol

adapter card

Page 6: CSE524: Lecture 15

6

Data-link layer functions

• Moving datagrams between adjacent nodes– Digital to analog conversion

– Framing

– Physical addressing

– Demux to upper protocol

– Error detection and correction

– Flow control

– Reliable delivery

– Security

– Media access and quality of service

Page 7: CSE524: Lecture 15

7

DL: Digital to analog conversion

• Bits sent as analog signals– Photonic pulses of a given wavelength over optical

fiber– Electronic signals of a given voltage

Page 8: CSE524: Lecture 15

8

DL: Digital to analog conversion

• Will cover electronic transmission (optical transmission left for you to research)

• Biggest issue– When to sample voltage?

– Detecting sequences involves clocking with the same clock• How to synchronize sender and receiver clocks?

– Need easily detectible event at both ends• Signal transitions help resync sender and receiver

• Need frequent transitions to prevent clock skew

– http://www.mouse.demon.nl/ckp/telco/encode.htm

Page 9: CSE524: Lecture 15

9

DL: RZ

• Return to Zero (RZ)– 1=pulse to high, dropping back to low– 0=no transition

Page 10: CSE524: Lecture 15

10

DL: NRZ-L

• Non-Return to Zero Level (NRZ-L)– 1=high signal, 0=lower signal– Long sequence of same bit causes difficulty

• DC bias hard to detect – low and high detected by difference from average voltage

• Clock recovery difficult

– Used by Synchronous Optical Network (SONET)• SONET XOR’s bit sequence to ensure frequent transitions

– Used in early magnetic tape storage

Page 11: CSE524: Lecture 15

11

DL: NRZ-L

Page 12: CSE524: Lecture 15

12

DL: NRZ-M

• Non-Return to Zero Mark– Less power to transmit versus NRZ– 1=signal transition at start of bit, 0=no change– No problem with string of 1’s– NRZ-like problem with string of 0’s– Used in SDLC (Synchronous Data Link Control)– Used in modern magnetic tape storage

Page 13: CSE524: Lecture 15

13

DL: NRZ-S

• Non-Return to Zero Space– 1=no change, 0=signal transition at start of bit– No problem with string of 0’s– NRZ-like problem with string of 1’s

Page 14: CSE524: Lecture 15

14

DL: Manchester (Bi-Phase-Level) coding

• Used by Ethernet

• 0=low to high transition, 1=high to low transition

• Transition for every bit simplifies clock recovery

• Not very efficient– Doubles the number of transitions– Circuitry must run twice as fast

Page 15: CSE524: Lecture 15

15

DL: Manchester coding

• Encoding for 110100

Bit stream

1 1 0 1 0 0

Manchester encoding

Page 16: CSE524: Lecture 15

16

DL: Other coding schemes

• Bi-Phase-Mark, Bi-Phase-Space– Level change at every bit period boundary– Mid-period transition determines bit

• Bi-Phase-M: 0=no change, 1=signal transition

• Bi-Phase-S: 0=signal transition, 1=no change

Page 17: CSE524: Lecture 15

17

DL: Other coding schemes

• Differential Bi-Phase-Space, Differential Bi-Phase-Mark– Level change at every mid-bit period boundary– Bit period boundary transition determines bit

• Diff-Bi-Phase-M: 0=signal transition, 1=no change

• Diff-Bi-Phase-S: 0=no change, 1=signal transition

Page 18: CSE524: Lecture 15

18

DL: Framing

• Data encapsulation for transmission over physical link

• Data embedded within a link-layer frame before transmission

• Data-link header and/or trailer added

• Physical addresses used in frame headers to identify source and destination (not IP)

Page 19: CSE524: Lecture 15

19

DL: Fixed length framing

• Length delimited– Beginning of frame has length– Single corrupt length can cause problems

• Must have start of frame character to resynchronize

• Resynchronization can fail if start of frame character is inside packets as well

Page 20: CSE524: Lecture 15

20

DL: Variable length framing

• Byte stuffing– Special start of frame byte (e.g. 0xFF)– Special escape byte value (e.g. 0xFE)– Values actually in text are replaced (e.g. 0xFF by

0xFEFF and 0xFE by 0xFEFE)– Worst case – can double the size of frame

• Bit stuffing– Special bit sequence (0x01111110)– 0 bit stuffed after any 11111 sequence

Page 21: CSE524: Lecture 15

21

DL: Clock-Based Framing

• Used by SONET

• Fixed size frames (810 bytes)

• Look for start of frame marker that appears every 810 bytes

• Will eventually sync up

Page 22: CSE524: Lecture 15

22

DL: Physical addressing

• LAN (or MAC or physical) address– Used to get datagram from one interface to another

physically-connected interface (same network)• IP address used to route between networks

– 48 bit MAC address (for most LANs) burned in adapter ROM• ifconfig –a• arp -a

– Address space assigned and managed by IEEE• Manufacturer buys portion of MAC address space to ensure

uniqueness

– Special LAN broadcast address• FF-FF-FF-FF-FF-FF

Page 23: CSE524: Lecture 15

23

DL: Physical addressing

• Why have separate IP and hardware addresses?●Assign adapters an IP address

●Hardware only works for IP (no IPX, DECNET)

●Must be reconfigured when moved

●Use hardware address as network address●Need standardized fixed length hardware address

●No route aggregation

Page 24: CSE524: Lecture 15

24

DL: Physical addressing

• Analogy:

(a) MAC address: like Social Security Number

(b) IP address: like postal address

• MAC flat address => portability – can move LAN card from one LAN to another

• IP hierarchical address NOT portable– depends on network to which one attaches

Page 25: CSE524: Lecture 15

25

DL: ARP: Address Resolution Protocol

• Each IP node (Host, Router) on LAN has ARP module, table

• ARP Table: IP/MAC address mappings for some LAN nodes

< IP address; MAC address; TTL> < …………………………..

>

– TTL (Time To Live): time after which address mapping will be forgotten (typically 20 min)

Question: how to determineMAC address of Bgiven B’s IP address?

Page 26: CSE524: Lecture 15

26

DL: ARP protocol

• A knows B's IP address, wants to learn physical address of B

• A broadcasts ARP query pkt, containing B's IP address – all machines on LAN receive ARP query

• B receives ARP packet, replies to A with its (B's) physical layer address

• A caches (saves) IP-to-physical address pairs until information becomes old (times out) – soft state: information that times out (goes

away) unless refreshed

Page 27: CSE524: Lecture 15

27

DL: Routing to another LAN

walkthrough: routing from A to B via R

– In routing table at source Host, find router 111.111.111.110– In ARP table at source, find MAC address E6-E9-00-17-BB-

4B, etc

A

RB

Page 28: CSE524: Lecture 15

28

– A creates IP packet with source A, destination B

– A uses ARP to get R’s physical layer address for 111.111.111.110

– A creates Ethernet frame with R's physical address as dest, Ethernet frame contains A-to-B IP datagram

– A’s data link layer sends Ethernet frame

– R’s data link layer receives Ethernet frame

– R removes IP datagram from Ethernet frame, sees its destined to B

– R uses ARP to get B’s physical layer address

– R creates frame containing A-to-B IP datagram sends to B

A

RB

Page 29: CSE524: Lecture 15

29

DL: RARP, BOOTP, DHCP

ARP: Given an IP address, return a hardware addressRARP: Given a hardware address, give me the IP

addressDHCP, BOOTP: Similar to RARPHosts (host portion):• hard-coded by system admin in a file• DHCP: Dynamic Host Configuration Protocol:

dynamically get address: “plug-and-play”– host broadcasts “DHCP discover” msg– DHCP server responds with “DHCP offer” msg– host requests IP address: “DHCP request” msg– DHCP server sends address: “DHCP ack” msg

Page 30: CSE524: Lecture 15

30

DL: Demux to upper protocol

• Protocol type specification interfaces to network layer

• Data-link layer can support any number of network layers

• Type field in data-link header specifies network layer of packet

• IP is one of many network layers • Each data-link layer defines its own protocol

type numbering for network layer

Page 31: CSE524: Lecture 15

31

DL: Demux to upper protocol

• http://www.cavebear.com/CaveBear/Ethernet/type.html

• Some Ethernet protocol types– 0800 DOD Internet Protocol (IP) – 0806 Address Resolution Protocol (ARP)– 8037 IPX (Novell Netware) – 80D5 IBM SNA Services– 809B EtherTalk (AppleTalk over Ethernet)

Page 32: CSE524: Lecture 15

32

DL: Error detection/correction

• Errors caused by signal attenuation, noise.

• Receiver detects presence of errors

• Possible actions– Signal sender for retransmission– Drops frame– Correct bit errors if possible and continue

Page 33: CSE524: Lecture 15

33

DL: Error detection/correction

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

Page 34: CSE524: Lecture 15

34

DL: Parity checking

Single Bit Parity:Detect single bit errors

Two Dimensional Bit Parity:Detect and correct single bit errors

0 0

Page 35: CSE524: Lecture 15

35

DL: Checksums

Sender:• treat segment contents as

sequence of 16-bit integers• checksum: addition (1’s

complement sum) of segment contents

• simple to implement, weak detection (easily tricked by common bit error patterns)

• used by TCP, UDP, IP..• sender puts checksum value into

header

Receiver:• compute checksum of received

segment

• check if computed checksum equals checksum field value:

– NO - error detected

– YES - no error detected. But maybe errors nonethless? More later ….

Goal: detect bit errors in transmitted segment

Page 36: CSE524: Lecture 15

36

DL: Cyclic Redundancy Check (CRC)

• Polynomial code– Treat packet bits a coefficients of n-bit polynomial– Choose r+1 bit generator polynomial (well known –

chosen in advance)– Add r bits to packet such that message is divisible by

generator polynomial

• Better loss detection properties than checksums– All single bit errors, all double bit errors, all odd-

numbered errors, burst errors less than r

Page 37: CSE524: Lecture 15

37

DL: Cyclic Redundancy Check (CRC)

• Calculate code using modulo 2 division of data by generator polynomial– Subtraction equivalent to XOR

– Weak definition of magnitude• X >= Y iff position of highest 1 bit of X is the same or greater than the highest

1 bit of Y

• Record remainder after division and send after data

• Result divisible by generator polynomial

Page 38: CSE524: Lecture 15

38

DL: Cyclic Redundancy Check (CRC)

Page 39: CSE524: Lecture 15

39

DL: CRC example

Data:

101110

Generator Polynomial:

x3 + 1 (1001)

Send:

101110011

Page 40: CSE524: Lecture 15

40

DL: CRC example

Data:

10000

Generator Polynomial:

x2 + 1 (101)

Send:

1000001

101 1000000 101 010 000 100 101 010 000 100 101 01

10101

D

G

R

Page 41: CSE524: Lecture 15

41

DL: Cyclic Redundancy Check (CRC)

• CRC-16 implementation

• Shift register and XOR gates

Page 42: CSE524: Lecture 15

42

DL: CRC polynomials

• CRC-16 = x16 + x15 + x2+ 1 (used in HDLC)

• CRC-CCITT = x16 + x12 + x5 + 1

• CRC-32 = x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1 (used in Ethernet)

Page 43: CSE524: Lecture 15

43

DL: Forward error correction

• FEC– Use error correcting codes to repair losses– Add redundant information which allows receiver to

correct bit errors– Suggest looking at information and coding theory

work.

Page 44: CSE524: Lecture 15

44

DL: Flow control

• Pacing between sender and receiver

• Sender prevented from overrunning receiver

• Ready-To-Send, Clear-To-Send

Page 45: CSE524: Lecture 15

45

DL: Reliable delivery

• Reliability at the link layer

• Handled in a similar manner to transport protocols

• When and why should this be used? ●Rarely done over twisted-pair or fiber optic links●Usually done over lossy links for performance improvement (versus correctness)

Page 46: CSE524: Lecture 15

46

DL: Security

• Mainly for broadcast data-link layers– Encrypt payload of higher layers– Hide IP source/destination from eavesdroppers– Important for wireless LANs especially

• Parking lot attacks

• 802.11b and WEP

• If time permits, security will be covered at the end of the course….

Page 47: CSE524: Lecture 15

47

DL: Media access and quality of service

• How and when can a node transmit?• Directly controls per-hop quality-of-service• 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)

Page 48: CSE524: Lecture 15

48

DL: Media access

• Point-to-point link and switched media no problem• Broadcast links?

– Network arbitration– Give everyone a fixed time/freq slot?

• Ok for fixed bandwidth (e.g., voice)• What if traffic is bursty?

– Centralized arbiter• Ex: cell phone base station• Single point of failure

– Distributed arbitration• Aloha/Ethernet

– Humans use multiple access protocols all the time

Page 49: CSE524: Lecture 15

49

DL: Media access protocols

• 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 station can transmit– communication about channel sharing uses 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

Page 50: CSE524: Lecture 15

50

DL: Media access protocols

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

Page 51: CSE524: Lecture 15

51

DL: Channel Partitioning MAC protocols

Synchronous TDMA: time division multiple access • TDM (Time Division Multiplexing): channel divided into N

time slots, one per user; access to channel in "rounds"

• each station gets fixed length slot (length = pkt trans time) in each round

• unused slots go idle – inefficient with low duty cycle users and at light load.

– example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle

Page 52: CSE524: Lecture 15

52

DL: Channel Partitioning MAC protocols

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

frequ

ency

bands time

Page 53: CSE524: Lecture 15

53

DL: Channel Partitioning MAC protocols

CDMA (Code Division Multiple Access) • unique “code” assigned to each user; ie, code set partitioning

• used mostly in wireless broadcast channels (cellular, satellite,etc)

• each user has own “chipping” sequence (ie, code) to encode data

• encoded signal = (original data) X (chipping sequence)

• decoding: inner-product of encoded signal and chipping sequence

• allows multiple users to “coexist” and transmit simultaneously with minimal interference (if codes are “orthogonal”)

Page 54: CSE524: Lecture 15

54

DL: Channel Partitioning MAC protocols

• CDMA Encode/Decode

Page 55: CSE524: Lecture 15

55

DL: Channel Partitioning MAC protocols

• CDMA: two sender interference

Page 56: CSE524: Lecture 15

56

DL: Random access protocols

• “Asynchronous” TDMA– 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”– To avoid deterministic collisions: randomize

• Random-access MAC protocols– specify how to recover from collisions (e.g., via delayed retransmissions)

– Examples: slotted ALOHA, ALOHA, CSMA, CSMA/CD

Page 57: CSE524: Lecture 15

57

DL: Random access MAC protocols

• 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

Page 58: CSE524: Lecture 15

58

DL: Random access MAC protocols

• Slotted Aloha efficiencyQ: 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: channeluse for useful transmissions 37%of time!

Page 59: CSE524: Lecture 15

59

DL: Random access MAC protocols

• Pure (unslotted) ALOHA – Simpler, no synchronization

– Packet needs transmission:• Send without awaiting for beginning of slot

– Collision probability increases:• Packet sent at t0 collides with other packets sent in [t0-1, t0+1]

Page 60: CSE524: Lecture 15

60

DL: Pure Aloha (cont.)

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

S =

thro

ughput

=

“goodput”

(

succ

ess

rate

)

G = offered load = Np0.5 1.0 1.5 2.0

0.1

0.2

0.3

0.4

Pure Aloha

Slotted Aloha

protocol constrainseffective channelthroughput!