78
[email protected] IUST- Data Link Layer 5-1 Chapter 5 Link Layer ري ت و ي پ م كا هاي ه ك ب ش ري ت و ي پ م كا هاي ه ك ب شComputer Networks Computer Networks

[email protected] IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

Embed Size (px)

Citation preview

Page 1: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-1

Chapter 5Link Layer

شبكه هاي كامپيوتريشبكه هاي كامپيوتري Computer NetworksComputer Networks

Page 2: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-2

Chapter 5: Link Layer

The goals: understand principles behind link layer

services: error detection, correction sharing a broadcast channel: multiple

access link layer addressing reliable data transfer, flow control: done!

instantiation and implementation of various link layer technologies

Page 3: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-3

5.1 Introduction and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet 5.6 Hubs, bridges, and switches

Chapter 5 outline

Page 4: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-4

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

PDU: frame, encapsulates datagram

link layer has responsibility of transferring datagram from one node to adjacent node over a link.

application

transportnetworkdata linkphysical

networkdata linkphysicalnetwork

data linkphysical

networkdata linkphysical

networkdata linkphysical

application

transportnetworkdata linkphysical

modem

modem

“link”

Page 5: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-5

Layers

Application SoftwareApplication Software

Application protocols (softwares) Transport Protocols (softwares) Network(Internetwork)

Protocols(softwares)

Link & Physical Protocols (Software + Hardware)

TCP/IPProtocol

Stack Logical Link ControlProtocols (software)

Medium Access ControlProtocols (Hardware)

Physical Protocols(Hardware)

Ethernet, Token Ring, Token BusFDDI, ...,

Page 6: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-6

Link layer: context

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

Each link protocol provides different services e.g., may or may not

provide reliable data transfer (rdt) over link

tourism analogy: trip from Tehran to Toos

taxi: Tehran to Mehrabad Airport

plane: Mehrabad to Mashhad

bus: Mashhad to Toos

tourist = datagram taxi, plane, bus =

communication link transportation mode =

link layer protocol tour agent = routing

algorithm

Page 7: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-7

Physical Frame Transfer

IP Add: ALAN Add: B

ppp, 33.3kbps

IP Add: IR11LAN Add;LR12

IP Add: IR13LAN Add: LR13

client

server

Src IP Add=ADst IP Add=S

Src LAN Add=BDst LAN Add=LR12

client to router1

Frame:router1

router2

router3

router4

Ethernet, 10Mbps

IP Add: IR22LAN Add: LR22

IP Add: SLAN Add: T

Src IP Add=ADst IP Add=S

Src LAN Add=LR13Dst LAN Add=LR22

router1 to router2

Frame:

Src IP Add=ADst IP Add=S

Src LAN Add=LR42Dst LAN Add=T

router4 to server

Frame:

IP Add: IR42LAN Add: LR42

Fast ethernet

LAN Add: 48 bit(6 × 8bit)(example: 74-29-9C-E8-FF-55)

Page 8: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-8

Link Layer Services

Framing, link access: encapsulate datagram into frame, adding header,

trailer channel access if shared medium ‘physical addresses’ used in frame headers to

identify source, destination. different from IP address!

Reliable delivery between adjacent nodes 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?

Link layer header Link layer trailerNetwork layer datagram

Layer 2 PDU: FrameLayer 2 PDU: Frame

Page 9: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-9

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

Page 10: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-10

Adaptors Communicating

link layer implemented in “adaptor” (NIC) Ethernet card, PCMCI

card, 802.11 card

sending side: encapsulates datagram

in a frame adds error checking bits,

rdt, flow control, etc.

receiving side looks for errors, rdt, flow

control, etc extracts datagram,

passes to receiving node

adapter is semi-autonomous

link & physical layers

sendingnode

frame

receivingnode

datagram

frame

adapter adapter

link layer protocol

Page 11: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-11

Chapter 5 outline

5.1 Introduction and services

5.2 Error detection and correction

5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet 5.6 Hubs, bridges, and switches

Page 12: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-12

Error DetectionEDC= 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 13: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-13

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 UDP or TCP 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? More later ….

Goal: detect “errors” (e.g., flipped bits) in transmitted segment (note: used at transport layer only)

Page 14: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-14

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= add without carry)

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 (ATM, HDCL)

D: data bits to be sent R: CRC bits

d [bits] r [bits]

bit patternbit pattern

mathematical formula: [D×2r XOR R]

Page 15: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-15

CRC Example

want:D×2r XOR R = n×G

equivalently:D×2r = n×G XOR R

equivalently: if we divide D×2r by

G, want remainder R

R = remainder[ ]

D×2r

G

D=101110, G=1001r=3, D×2r=101110000

D×2r

G =101110000 10011001 101011 101 000 1010 1001 110 000 1100 1001 1010 1001 011

R

Page 16: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-16

Chapter 5 outline

5.1 Introduction and services 5.2 Error detection and correction

5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet 5.6 Hubs, bridges, and switches

Page 17: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-17

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 upstream Hybrid Fiber Coaxial 802.11 wireless LAN Efficiency: Low Latency & High Throughput [in

average]

Computer1

Computer2

Computer3

Computer4

Computer5

terminatorterminator

Page 18: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-18

Local ISP (LAN)

LANs Bus Star (Hub) (Collision) Star (Switch)

Symmetric Asymmetric

LANs Bus Star (Hub) (Collision) Star (Switch)

Symmetric Asymmetric

hub

Client

Printer

Server

Client

LAN Switch

Client

Remote Access ServerModem pools

TelephoneLines

Router

External Link

Serversmodem

modem

Client

PPP for dial-up access

point-to-point link between LAN switch and hosts.

Page 19: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-19

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1. 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/M3. Fully decentralized:

no special node to coordinate transmissions no synchronization of clocks, slots

4. Simple

Page 20: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-20

MAC Protocols: a taxonomy

Three broadcast 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” (Token/Polling) tightly coordinate shared access to avoid collisions

Page 21: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-21

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: slotted ALOHA ALOHA CSMA, CSMA/CD, CSMA/CA

Page 22: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-22

Slotted ALOHA

Assumptions all frames same size time is divided into

equal size slots : time to transmit 1 frame

nodes start to transmit frames only at beginning of slots

nodes are synchronized if 2 or more nodes

transmit in slot, all nodes detect collision

Operation when node obtains fresh

frame, it transmits in next slot

no collision detected -> send a frame in next slot

collision detected -> retransmit a frame in each subsequent slot with probability p until success

Page 23: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-23

Slotted Aloha Efficiency

Suppose N nodes with many frames to send, each transmits in slot with probability p

probability that first node has success in a slot = p(1-p)N-1

probability that any node has a success is = Np(1-p)N-1

Suppose N nodes with many frames to send, each transmits in slot with probability p

probability that first node has success in a slot = p(1-p)N-1

probability that any node has a success is = Np(1-p)N-1

For max efficiency with N nodes, find pm that maximizes Np(1-p)N-1

For many nodes, take limit of N pm(1- pm)N-1 as N goes to infinity, gives 1/e = 0.37

At best: channel used for useful transmissions 37% of time!

Page 24: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-24

Channel Utilization

0.1

0.3

0.4

0.2

1 2 3 4 5 6 7

Slotted ALOHA

Non-slotted ALOHA0.18

0.5

Offered Load [Frame/T], T=“512bits”- time

Th

rou

gh

pu

t [F

ram

e/T

]

0.37

Page 25: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-25

CSMA (Carrier Sense Multiple Access)

CSMA: listen before transmit: If channel sensed idle: transmit entire frame If channel sensed busy, defer transmission

Page 26: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-26

CSMA collisions

collisions can still occur:propagation delay means two nodes may not heareach other’s transmissioncollision:entire packet transmission time wastednote:role of distance & propagation delay in determining collision probability

A B C D

time

t0

t1

distance

CollisionDetection

Time

Fra

me tra

nsm

ission tim

e

terminatorterminator

Page 27: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-27

CSMA collisionscollision occurs:A finishes transmitting a frame, then receives DD’s frame so A cannot detect the collision.

F: Frame length [bit]R: Transmission Rate (Bandwidth) [bit/sec] —› TF=F/Rd: A to BB distance [m]V: signal propagation velocity in channel [m/sec] —› TAD= d/V

TF ≥ 2×TAD —› F ≥ 2×R×TAD

F: Frame length [bit]R: Transmission Rate (Bandwidth) [bit/sec] —› TF=F/Rd: A to BB distance [m]V: signal propagation velocity in channel [m/sec] —› TAD= d/V

TF ≥ 2×TAD —› F ≥ 2×R×TAD

Collision detection condition:TF: Frame transmission Time [sec]TAD: A to D propagation time [sec]Then: TF≥ 2×TAD

Collision detection condition:TF: Frame transmission Time [sec]TAD: A to D propagation time [sec]Then: TF≥ 2×TAD

A B C D

time

t0t1

distance

CollisionDetection Time=0

TAD

TDATF ‹ (TAD+TDA) = 2×TAD

TF

Page 28: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-28

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: receiver shut off while transmitting

Page 29: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-29

“Taking Turns” MAC protocols

channel partitioning MAC protocols: share channel efficiently and fairly 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

Page 30: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-30

“Taking Turns” MAC protocols

Polling: master node

“invites” slave nodes to transmit in turn

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 high latency at low offered

load single point of failure

(token)

Page 31: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-31

Summary of MAC protocols

What do you do with a shared media? Channel Partitioning, by 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 site, token passing

Page 32: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-32

5.1 Introduction and services 5.2 Error detection and correction 5.3Multiple access protocols

5.4 LAN addresses and ARP 5.5 Ethernet 5.6 Hubs, bridges, and switches

Chapter 5 outline

Page 33: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-33

LAN technologies

Data link layer so far: services, error detection/correction, multiple

access

Next: LAN technologies addressing Ethernet (802.3) hubs, bridges, switches 802.11 PPP ATM

Page 34: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-34

LAN Addresses and ARP

32-bit IP address: network-layer address used to get datagram to destination IP network

(recall IP network definition)

LAN (or MAC or physical or Ethernet) address:

used to get datagram from one interface to another physically-connected interface (same network)

48 bit MAC address (for most LANs) burned in the adapter ROM

Page 35: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-35

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Page 36: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-36

LAN Address (more)

MAC address allocation administered by IEEE

manufacturer buys portion of MAC address space (to assure uniqueness)

MAC flat address —› portability can move LAN card from one LAN to another

IP hierarchical address NOT portable depends on IP network to which node is

attached

Page 37: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-37

Recall earlier routing discussion

Starting at A, given IP datagram addressed to B:

look up net. address of B, find B on same net. as A

link layer send datagram to B inside link-layer frame

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4 223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2223.1.3.1

223.1.3.27 E

A

B

datagram

B’s MACaddr

A’s MACaddr

A’s IPaddr

B’s IPaddr

IP payload

frame source,dest address

datagram source,dest address

CRC

framedatagram

Page 38: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-38

ARP: Address Resolution Protocol

Each IP node (Host, Router) on LAN has ARP 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 Bknowing B’s IP address?

Page 39: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-39

ARP protocol A wants to send

datagram to B, and A knows B’s IP address.

Suppose B’s MAC address is not in A’s ARP table.

A broadcasts ARP query packet, containing B's IP address all machines on LAN

receive ARP query B receives ARP packet,

replies to A with its (B's) MAC address frame sent to A’s MAC

address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out) soft state: information

that times out (goes away) unless refreshed

ARP is “plug-and-play”: nodes create their ARP

tables without intervention from network administrator

Page 40: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-40

Routing to another LAN-1walkthrough: send datagram from A to B via R

(assume A knows B’s IP address)

walkthrough: send datagram from A to B via R (assume A knows B’s IP address)

A

RB

Two ARP tables in router R, one for each IP network (LAN) In routing table at source Host, find R’s IP address=111.111.111.110 In ARP table at source, find R’s MAC address E6-E9-00-17-BB-4B

Two ARP tables in router R, one for each IP network (LAN) In routing table at source Host, find R’s IP address=111.111.111.110 In ARP table at source, find R’s MAC address E6-E9-00-17-BB-4B

Page 41: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-41

A creates datagram with source A, destination B A uses ARP to get R’s MAC address for

111.111.111.110 A creates link-layer frame with R's MAC address

as destination, frame contains A-to-B IP datagram

A’s data link layer sends frame R’s data link layer receives 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 creates datagram with source A, destination B A uses ARP to get R’s MAC address for

111.111.111.110 A creates link-layer frame with R's MAC address

as destination, frame contains A-to-B IP datagram

A’s data link layer sends frame R’s data link layer receives 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

Routing to another LAN-2

Page 42: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-42

5.1 Introduction and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet 5.6 Hubs, bridges, and switches

Chapter 5 outline

Page 43: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-43

Ethernet

“dominant” LAN technology: cheap even 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 Ethernetsketch

Page 44: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-44

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble: 7 bytes with pattern 10101010 followed by one

byte with pattern 10101011 used to synchronize receiver, sender clock rates

PAD

46 to 1500 Bytes8B 6B 6B

(2B)

4B

Mini :6+6+2+46+4= 64 BytesMax :6+6+2+1500+4= 1518 Bytes

Page 45: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-45

Ethernet Frame Structure (more)

Addresses: 6 bytes if adapter receives frame with matching destination

address, or with broadcast address (e.g. ARP packet), it passes data in frame to network layer protocol

otherwise, adapter discards frame

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

Page 46: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-46

Unreliable, connectionless service

Connectionless: No handshaking between sending and receiving adapter.

Unreliable: receiving adapter doesn’t send ACKs or NACKs to sending adapter stream of datagrams passed to network layer can

have gaps gaps will be filled if application is using TCP otherwise, application will see the gaps

Page 47: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-47

Ethernet uses CSMA/CD

No slots adapter doesn’t

transmit if it senses that some other adapter is transmitting, that is, carrier sense

transmitting adapter aborts when it senses that another adapter is transmitting, that is, collision detection

Before attempting a retransmission, adapter waits a random time, that is, random access

Page 48: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-48

Ethernet CSMA/CD algorithm

1. Adaptor gets datagram and creates frame

2. If adapter senses channel idle, it starts to transmit frame. If it senses channel busy, waits until channel idle and then transmits

3. If adapter transmits entire frame without detecting another transmission, the adapter is done with frame !

1. Adaptor gets datagram and creates frame

2. If adapter senses channel idle, it starts to transmit frame. If it senses channel busy, waits until channel idle and then transmits

3. If adapter transmits entire frame without detecting another transmission, the adapter is done with frame !

4. If adapter detects another transmission while transmitting, aborts and sends jam signal

5. After aborting, adapter enters exponential backoff: after the mth collision, adapter chooses a K at random from {0,1,2,…,2m-1}. Adapter waits K×512 bit times and returns to Step 2

Page 49: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-49

Ethernet’s CSMA/CD (more)

Bit time: 0.1 µsec for 10 Mbps Ethernet ;for K=1023, wait time is about 50 msec

Jam Signal: makes sure all other transmitters are aware of collision; 48 bits;

Bit time: 0.1 µsec for 10 Mbps Ethernet ;for K=1023, wait time is about 50 msec

Jam Signal: makes sure all other transmitters are aware of collision; 48 bits;

Exponential Backoff: Goal: adapt retransmission

attempts to estimated current load heavy load: random wait

will be longer first collision: choose K

from {0,1}; delay is K x 512 bit transmission times

after second collision: choose K from {0,1,2,3}…

after 10 collisions, choose K from {0,1,2,3,4,…,1023}

Exponential Backoff: Goal: adapt retransmission

attempts to estimated current load heavy load: random wait

will be longer first collision: choose K

from {0,1}; delay is K x 512 bit transmission times

after second collision: choose K from {0,1,2,3}…

after 10 collisions, choose K from {0,1,2,3,4,…,1023}

Page 50: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-50

Frame Ready for Transmission

Sense Channel

Idle Busy

Frame Transmission & Channel Sense

BusyCollisionAbort Transmission; Send Jam Signal

Ethernet CSMA/CD algorithm( Flow Chart )

Exponential backoff

exponential backoff: after the mth collision, adapter chooses a K at random from {0,1,2,…,2m-1}. Adapter waits K×512 bit times.

Frame successfully transmitted

Page 51: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-51

CSMA/CD efficiency

tprop=max propagation time between 2 nodes in LAN

ttrans = time to transmit max-size frame

Efficiency goes to 1 as tprop goes to 0

Goes to 1 as ttrans goes to ∞ Much better than ALOHA, but still decentralized,

simple, and cheap

transpropproptrans

trans

ttttt

/511

5efficiency

transpropproptrans

trans

ttttt

/511

5efficiency

Page 52: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-52

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 only! has become a legacy technology

Page 53: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-53

Hubs are essentially physical-layer repeaters: bits coming in one link go out all other links no frame buffering no CSMA/CD at hub: adapters detect

collisions provides network management functionality

Hubs

hub

node1

node2node3

node4

node5

node6

To higher level hubs/switches

Page 54: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-54

Manchester encoding

Used in 10BaseT, 10Base2 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!

This is physical-layer!

Used in 10BaseT, 10Base2 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!

This is physical-layer!

Page 55: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-55

IEEE 802.3 10Mbps Mediums

Coaxial Cable(50

Ohm)

Coaxial Cable (50

Ohm)

Unshielded twisted pair

850-nm optical fiber

pair

Baseband (Manchester)

Baseband (Manchester)

Baseband (Manchester

)

Manchester/On-Off

Bus Bus Star Star

500 185 100 500

100 30 ---- 33

10 5 0.4 to 0.662.5/12.5

µm

10Base5 10Base2 10Base-T 10base-FP

Transmissionmedium

Signalingtechnology

Topology

Max segmentlength [m]

Nodes persegment

Cable diameter[mm]

Page 56: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-56

2 pair, STP2 pair,

Category 5 UTP

2 optical fibers

4 pair, cat.3, 4 or

5 UTP

MLT-3 MLT-3 4B5B, NRZI 8B6T, NRZ

100 Mbps 100 Mbps 100 Mbps 100 Mbps

100 100 100 100

200 200 400 200

100Base-TX 100Base-FX 100Base-T4

Transmissionmedium

Signalingtechnology

Data rate

Max segmentlength [m]

Networkspan [m]

IEEE 802.3 100Mbps Mediums

STP: Shielded twisted pair; UTP: Unshielded twisted pairNRZ: NonReturn to Zero; NRZI: NRZ Invertwd

Page 57: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-57

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 10 or 40 Gbps now !

Page 58: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-58

Chapter 5 outline

5.1 Introduction and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet 5.6 Hubs, bridges, and switches

Page 59: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-59

Interconnecting LAN segments

Hubs Bridges Switches

Remark: switches are essentially multi-port bridges.

What we say about bridges also holds for switches!

Page 60: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-60

Interconnecting with hubs Backbone hub interconnects LAN segments Extends max distance between nodes But individual segment collision domains become one

large collision domain if a node in CS and a node EE transmit at same time: collision

Can’t interconnect 10BaseT & 100BaseT

Page 61: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-61

Bridges

Link layer device stores and forwards Ethernet frames examines frame header and selectively forwards

frame based on MAC dest address when frame is to be forwarded on segment, uses

CSMA/CD to access segment transparent

hosts are unaware of presence of bridges plug-and-play, self-learning

bridges do not need to be configured

Page 62: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-62

Bridges: traffic isolation

Bridge installation breaks LAN into LAN segments bridges filter packets:

same-LAN-segment frames not usually forwarded onto other LAN segments

segments become separate collision domains

bridge collision domain

collision domain

= hub

= host

LAN (IP network)

LAN segment LAN segment

Page 63: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-63

Forwarding

How do determine to which LAN segment to forward frame?• Looks like a routing problem...

Page 64: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-64

Self learning

A bridge has a bridge table entry in bridge table:

(Node LAN Address, Bridge Interface, Time Stamp) stale entries in table dropped (TTL can be 60 min)

bridges learn which hosts can be reached through which interfaces when frame received, bridge “learns” location of

sender: incoming LAN segment records sender/location pair in bridge table

Page 65: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-65

Filtering/Forwarding

When bridge receives a frame:

index bridge table using MAC destination addressif entry found for destination

then{ if dest. on segment from which frame arrived then drop the frame else forward the frame on interface

indicated } else flood

forward on all but the interface on which the frame arrived

Page 66: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-66

Bridge example

Suppose C sends frame to D and D replies back with frame to C.

Bridge receives frame from from C notes in bridge table that C is on interface 1 because D is not in table, bridge sends frame into

interfaces 2 and 3

frame received by D

Page 67: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-67

Bridge Learning: example

D generates frame for C, sends bridge receives frame

notes in bridge table that D is on interface 2 bridge knows C is on interface 1, so selectively

forwards frame to interface 1

Page 68: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-68

Interconnection without backbone

Not recommended for two reasons:- single point of failure at Computer Science hub- all traffic between EE and SE must path over CS segment

Page 69: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-69

Backbone configuration

Recommended !

Page 70: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-70

Bridges Spanning Tree for increased reliability, desirable to have redundant,

alternative paths from source to dest with multiple paths, cycles result - bridges may

multiply and forward frame forever solution: organize bridges in a spanning tree by

disabling subset of interfaces

Disabled

Page 71: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-71

Some bridge features

Isolates collision domains resulting in higher total max throughput

limitless number of nodes and geographical coverage

Can connect different Ethernet types Transparent (“plug-and-play”): no

configuration necessary

Page 72: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-72

Bridges vs. Routers both store-and-forward devices

routers: network layer devices (examine network layer headers) bridges are link layer devices

routers maintain routing tables, implement routing algorithms

bridges maintain bridge tables, implement filtering, learning and spanning tree algorithms

Page 73: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-73

Routers vs. Bridges

Bridges + and - + Bridge operation is simpler requiring less

packet processing+ Bridge tables are self learning - All traffic confined to spanning tree, even when

alternative bandwidth is available- Bridges do not offer protection from broadcast

storms

Page 74: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-74

Routers vs. Bridges

Routers + and -+ arbitrary topologies can be supported, cycling is

limited by TTL counters (and good routing protocols)

+ provide protection against broadcast storms- require IP address configuration (not plug and play)- require higher packet processing

bridges do well in small (few hundred hosts) while routers used in large networks (thousands of hosts)

Page 75: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-75

Ethernet Switches Essentially a multi-interface

bridge layer 2 (frame) forwarding,

filtering using LAN addresses Switching: A-to-A’ and B-to-

B’ simultaneously, no collisions

large number of interfaces often: individual hosts, star-

connected into switch Ethernet, but no

collisions!

Page 76: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-76

Ethernet Switches

cut-through switching: frame forwarded from input to output port without awaiting for assembly of entire frameslight reduction in latency

combinations of shared/dedicated, 10/100/1000 Mbps interfaces

Page 77: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-77

Not an atypical LAN (IP network)

Dedicated

Shared

Page 78: Analoui@iust.ac.ir IUST- Data Link Layer5-1 Chapter 5 Link Layer شبكه هاي كامپيوتري Computer Networks

[email protected] IUST- Data Link Layer 5-78

Summary comparison

hubs bridges routers switches

traffi cisolation

no yes yes yes

plug & play yes yes no yes

optimalrouting

no no yes no

cutthrough

yes no no yes