Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or...

29
Data Link Layer (Layer 2, L2) Data Link Layer (Layer 2, L2) 염염염

Transcript of Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or...

Page 1: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

Data Link Layer (Layer 2, L2)Data Link Layer (Layer 2, L2)

염익준

Page 2: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

2

CablesCables

• Used to connect nodes in the same room or building.

Cable Typical Bandwidths Distances

Cat-5 twisted pairThin-net coaxThick-net coaxMultimode fiberSingle-mode fiber

10-100 Mbps10-100 Mbps10-100 Mbps100 Mbps100-2400 Mbps

100 m200 m500 m2 km40 km

Page 3: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

3

Leased LinesLeased Lines

• Used to connect site to site. Service Bandwidth

DS1 (or T1)DS3 STS-1 (or OC1)STS-3STS-12STS-48STS-192

1.544 Mbps44.736 Mbps51.840 Mbps155.250 Mbps622.080 Mbps2.488320 Gbps9.953280 Gbps

Page 4: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

4

Last-Mile LinksLast-Mile Links

• POTS (Plain Old Telephone Service): 56 Kbps• ISDN (Integrated Services Digital Network): 64-128 Kbps• xDSL (Digital Subscriber Line): 16 Kbps – 55.2 Mbps

– Asymmetric DSL (ADSL): Upstream (16 – 640 Kbps) and Downstream (1.544 – 8.448 Mbps)

– Very-high rate DSL (VDSL): 12.96 – 55.2 Mbps• Symmetric• Running over much shorter distances (1000 to 4500

feet)• Cable modem

– Using cable network– 40 Mbps downstream on a single CATV channel (6 MHz)

Page 5: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

5

Wireless LinksWireless Links

• Global links – PCS, GSM• Wireless LAN – IEEE 802.11a, b, g• Wireless MAN – IEEE 802.16, WiBro• Piconet – Bluetooth (upto 1 Mbps)

Page 6: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

6

Encoding - NRZEncoding - NRZ

Signalling component

Signal

Bits

Node NodeAdaptor Adaptor

Bits

NRZ

0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0

• Problems of NRZ– Consecutive 0s – cannot distinguish with dead links– Consecutive 1s - Baseline wander– Clock recovery

Page 7: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

7

NRZI and Manchester CodingNRZI and Manchester Coding

• NRZI (Non Return to Zero Inverted)– Transition to encode 1– Stay to encode 0– Solving the problem of

consecutive 1s• Manchester encoding

– Transmitting the exclusive-OR of the NRZ-encoded data and the clock

– Bit rate is half the baud rate.

Bits

NRZ

Clock

Manchester

NRZI

0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0

*baud rate: the rate at which the signal changes

Page 8: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

8

4B/5B Coding4B/5B Coding

• Insert extra bits to break up long sequence of 0s or 1s.

• Every 4 bits are encoded in a 5 bit code.

• 5 bit codes are selected so that– No more than one leading

0– No more than two tailing

0s• Resulting that no more than

three consecutive 0s.• Transmitted using the NRZI.

4 bit data 5 bit code

0000000100100011010001010110011110001001101010111100110111101111

11110010011010010101010100101101110011111001010011101101011111010110111110011101

Page 9: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

9

FramingFraming

Frames

BitsAdaptor Adaptor Node BNode A

Page 10: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

10

Byte-Oriented ProtocolsByte-Oriented Protocols

• Sentinel approach

• Byte-counting approach

SY

N Header Body

8 8 8 8 168S

YN

SO

H

ST

X

ET

X CRC

SY

N

Header Body

8 8 4214 168

SY

N

Cla

ss CRCCount

Page 11: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

11

Bit-Oriented ProtocolsBit-Oriented Protocols

• A frame is a collection of bits.• HDLC (High-Level Data Link Control)

– 01111110 is used for distinguishing both the beginning and the end of a frame.

Header Body

8 16 16 8

CRCBeginningsequence

Endingsequence

Page 12: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

12

Error-Detection: Naïve Error-Detection: Naïve approachapproach• Send a message twice• Compare two copies at the receiver

– If different, some errors exist

• How many bits of error can you detect?• What is the overhead?

Page 13: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

13

Error DetectionError Detection

• Problem: detect bit errors in packets (frames)• Solution: add extra bits to each packet• Goals:

– Reduce overhead, i.e., reduce the number of redundancy bits– Increase the number and the type of bit error patterns that can be

detected

• Examples:– Two-dimensional parity– Checksum– Cyclic Redundancy Check (CRC) – Hamming Codes

Page 14: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

14

Reliable Transmission Reliable Transmission

• Overhead for error correction is too large.• Corrupt frames are discarded -> Link-level packet

loss.• Reliable transmission is implemented by

acknowledgment and timeout. (called automatic repeat request (ARQ))

Page 15: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

15

Stop and Wait (1/2)Stop and Wait (1/2)

• The simplest ARQ scheme• A sender sets a timer

before sending a packets.• The sender sends the next

packet if it receives an ACK before the timer is expired.

• Otherwise, the sender retransmits the packet.

• Potential to cause duplicate copies of a packet (refer to Figure (c) and (d)).

Sender Receiver

Frame

ACK

Tim

eout

Tim

e

Sender Receiver

Frame

ACK

Tim

eout

Frame

ACKTim

eout

Sender Receiver

Frame

ACKTim

eout

Frame

ACKTim

eout

Sender Receiver

Frame

Tim

eout

Frame

ACKTim

eout

(a) (c)

(b) (d)

Page 16: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

16

Stop and Wait (2/2)Stop and Wait (2/2)

• Use 1 bit sequence number to distinguish packets.

• The main shortcoming is low utilization.

Frame 0

ACK 0

Sender Receiver

Frame 1

ACK 1

Frame 0

ACK 0

Page 17: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

17

Sliding WindowSliding Window

• Window is defined as “the number of frames to be sent without ACK.”

• Trying to keep the pipe full.

• Sequence number is needed to identify packets. (be careful not to be wrapped up)

• ACK– Cumulative– Negative– Selective

Sender Receiver

……

Page 18: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

18

Ethernet (IEEE 802.3)Ethernet (IEEE 802.3)

• Developed in the mid 1970s at the Xerox Palo Alto Research Center.

• Successful example of CSMA/CD (Carrier Sense Multiple Access with Collision Detect) technology.

Page 19: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

19

Physical Properties of Physical Properties of EthernetEthernet• Implemented on a coaxial cable of up to 500m.• Can be extended by repeaters (up to four repeaters).• An Ethernet is limited to supporting a maximum of 1024 hosts.• Terminator are used to absorb the signal and keep it from

bouncing back and interfering with trailing signals.• Manchester encoding scheme is used.• 10Base2, 10Base5, 10BaseT, 100BaseT,…

Page 20: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

20

Ethernet Frame FormatEthernet Frame Format

• The 64 bit preamble alternating 0s and 1s allows the receiver to synchronize with the signal.

• Each frame contains up to 1500 bytes of data.– for bounding delay

• A frame must contain at least 46 bytes of data to detect collision.

Destaddr

64 48 32

CRCPreamble Srcaddr

Type Body

1648

Page 21: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

21

Ethernet AddressEthernet Address

• 48 bit • Unique address for each adaptor• 8:0:2b:e4:b1:2 -> 00001000 00000000 00101011

11100100 ….• An Ethernet adaptor receives all frames and accepts

– Frames addressed to its own address– Frames addressed to the broadcast address (consisting

of all 1s)– Frames addressed to a multicast address (the first bit

set to 1 but is not the broadcast address), if it has been instructed to listen to that address.

– All frames, if it has been placed in promiscuous mode.

Page 22: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

22

Ethernet Transmitter Ethernet Transmitter AlgorithmAlgorithm• When the adaptor has a frame to send and the line

is idle, it transmits the frame immediately.• When an adaptor has a frame to send and the line

is busy, it waits for the line to go idle, and then transmits immediately (1-persistent).

• If collision is detected, the sender transmits a 32-bit jamming sequence and then stops the transmission.

• Once an adaptor has detected a collision and stopped its transmission, it waits a certain amount of time and tries again.

• Exponential backoff

Page 23: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

23

IEEE 802.11 WLANIEEE 802.11 WLAN

Physical Layer

Date Link Layer

Network Layer

Transport Layer

Application Layer

IEEE 802.11

Page 24: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

24

IEEE 802.11 WLANIEEE 802.11 WLAN

Data Link Layer

Logical Link Layer (802.2)Interface with upper layer,

framing, error control

MAC Layer (802.11)CSMA/CA

802.11FHSS

802.11DSSS

802.11aOFDM

802.11bHR/DDSS

Physical Layer

Page 25: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

25

Technical IssuesTechnical Issues

• Unstable channel• Hidden terminal problem• Exposed terminal problem

Page 26: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

26

802.11 MAC802.11 MAC

Point Coordination Function (PCF)

Distributed Coordination Function (DCF)

Contention-freeDelivery Contention-based

Delivery

Page 27: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

27

Access ModeAccess Mode

• Point Coordination Function (PCF):– for delay sensitive service– use polling for channel access control– not widely deployed

• Distributed Coordination Function (DCF):– for best-effort data service– use CSMA/CA for channel access control– may use RTS/CTS scheme

Contention-free PeriodContention Period

A Super Frame

Page 28: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

28

DCF Access ControlDCF Access Control

• SIFS (Short Inter Frame Spacing)– Highest priority, for ACK, CTS, Polling response

• PIFS (PCF IFS)– Medium priority, for time-bounded service using PCF

• DIFS(DCF IFS)– Lowest priority, for asynchronous data service

Busy Transmission

DIFS

SIFSPIFS

Contention Window

Page 29: Data Link Layer (Layer 2, L2) 염익준. 2 Cables Used to connect nodes in the same room or building. CableTypical BandwidthsDistances Cat-5 twisted pair Thin-net.

29

Backoff TimerBackoff Timer

• Randomize interframe space to avoid collision• backoff time = slot time * random no.• Pick a random integer between 0 to CW• CW is initially set to 7• for each collision occur, CW = 2*CW+1• increased upto 255