Data Link Layer

hellhollowreadingNetworking and Communications

Oct 26, 2013 (3 years and 9 months ago)

78 views

DataLink Layer

3
-
1

2013 session 1

TELE3118: Network Technologies


Week 3: Data Link Layer

Wireless,

Ethernet

Some slides have been taken from:


Computer Networking: A Top Down Approach Featuring the Internet
, 3
rd

edition.
Jim Kurose, Keith Ross. Addison
-
Wesley, July 2004.

All material copyright 1996
-
2004. J.F Kurose and K.W. Ross, All Rights Reserved.


Computer Networks
, 4
th

edition. Andrew S. Tanenbaum. Prentice
-
Hall, 2003.

DataLink Layer

3
-
2

IEEE 802.11 Wireless LAN


802.11b


2.4
-
5 GHz unlicensed
radio spectrum


up to 11 Mbps


direct sequence spread
spectrum (DSSS) in
physical layer


all hosts use same
chipping code


widely deployed, using
base stations



802.11a



5
-
6 GHz range


up to 54 Mbps


802.11g



2.4
-
5 GHz range


up to 54 Mbps


All use CSMA/CA for
multiple access


All have base
-
station
and ad
-
hoc network
versions

DataLink Layer

3
-
3

Wireless network characteristics

Multiple wireless senders and receivers create
additional problems (beyond multiple access):

A

B

C

Hidden terminal problem


B, A hear each other


B, C hear each other


A, C can not hear each other

means A, C unaware of their
interference at B


A

B

C

A’s signal

strength

space

C’s signal

strength

Signal fading:


B, A hear each other


B, C hear each other


A, C can not hear each other
interferring at B

DataLink Layer

3
-
4

IEEE 802.11: multiple access


avoid collisions: 2
+

nodes
transmitting at same time


802.11: CSMA
-

sense before transmitting


don’t collide with ongoing transmission by other node


802.11:
no

collision detection!


difficult to receive (sense collisions) when transmitting due
to weak received signals (fading)


can’t sense all collisions in any case: hidden terminal, fading


goal:
avoid collisions:

CSMA/C(ollision)A(voidance)

A

B

C

A

B

C

A’s signal

strength

space

C’s signal

strength

DataLink Layer

3
-
5

IEEE 802.11 MAC Protocol: CSMA/CA

802.11 sender

1
if sense channel idle

for
DIFS

then


transmit entire frame (no CD)

2 if

sense channel busy then


start random backoff time

timer counts down while channel idle

transmit when timer expires

if no ACK, increase random backoff
interval, repeat 2

802.11 receiver

-

if frame received OK


return ACK after
SIFS
(ACK needed due
to hidden terminal problem)

sender

receiver

DIFS

data

SIFS

ACK

DataLink Layer

3
-
6

Avoiding collisions (more)

idea:


allow sender to “reserve” channel rather than random
access of data frames: avoid collisions of long data frames


sender first transmits
small

request
-
to
-
send (RTS) packets
to BS using CSMA


RTSs may still collide with each other (but they’re short)


BS broadcasts clear
-
to
-
send CTS in response to RTS


RTS heard by all nodes


sender transmits data frame


other stations defer transmissions


Avoid data frame collisions completely

using small reservation packets!

DataLink Layer

3
-
7

Collision Avoidance: RTS
-
CTS exchange

AP

A

B

time

DATA (A)

reservation collision

defer

DataLink Layer

3
-
8

Ethernet

“dominant” wired LAN technology:


cheap $20 for 100Mbs!


first widely used LAN technology


Simpler, cheaper than token LANs and ATM


Kept up with speed race: 10 Mbps


10 Gbps


Metcalfe’s Ethernet

sketch

DataLink Layer

3
-
9

Ethernet Addressing





6 byte address (unique to each adapter)


Example: 08
-
0b
-
db
-
e4
-
b1
-
02


2^48 = 281 trillion; can produce 100 million LAN devices
every day for 2000 years!


Interpretation of address:


Upper 24 bits OUI (Organizationally Unique Identifier)


Lower 24 bits Organization
-
assigned portion


Unicast: lowest bit of first byte is 0


Multicast: lowest bit of first byte is 1


Broadcast: ff
-
ff
-
ff
-
ff
-
ff
-
ff


Adaptor accept frame if and only if:


Destination address matches adapter address, or


Destination address is broadcast, or


Destination address is multicast and adapter has been
configured to accept it

DataLink Layer

3
-
10

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

DataLink Layer

3
-
11

Ethernet Frame Structure (more)


Addresses:

6 bytes


if adapter receives frame with matching destination
address, or with broadcast address (eg ARP packet), it
passes data in frame to net
-
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



DataLink Layer

3
-
12

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 app is using TCP


otherwise, app will see the gaps

DataLink Layer

3
-
13

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

DataLink Layer

3
-
14

Ethernet CSMA/CD algorithm

1. Adaptor receives
datagram from net layer &
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,…,2
m
-
1}. Adapter
waits K
·
512 bit times and
returns to Step 2




DataLink Layer

3
-
15

Ethernet’s CSMA/CD (more)

Jam Signal:

make sure all
other transmitters are
aware of collision; 48 bits

Bit time:

.1 microsec for 10
Mbps Ethernet ;

for K=1023, wait time is
about 50 msec




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
·

512
bit transmission times


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


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

See/interact with Java

applet on AWL Web site:

highly recommended !

DataLink Layer

3
-
16

CSMA/CD efficiency


T
prop

= max prop between 2 nodes in LAN


t
trans

= time to transmit max
-
size frame





Efficiency goes to 1 as t
prop

goes to 0


Goes to 1 as t
trans

goes to infinity


Much better than ALOHA, but still decentralized,
simple, and cheap





DataLink Layer

3
-
17

Ethernet Technologies: Coax


10Base2
:


10
Mbps,
2
00 meters max cable length


thin coaxial cable in a bus topology


repeaters

connect multiple segments


DataLink Layer

3
-
18

Ethernet Technologies: Twisted Pair


10BaseT / 100BaseT

“fast ethernet”:


10/100
Mbps,
T
wisted pair


Nodes connect to a
hub

in “star topology”

hub

nodes

DataLink Layer

3
-
19

Hubs

Hubs are essentially physical
-
layer repeaters:


bits coming from one link go out all other links


at the same rate


no frame buffering


no CSMA/CD at hub: adapters detect collisions


provides net management functionality

twisted pair

hub

DataLink Layer

3
-
20

Interconnecting with hubs


Backbone hub interconnects LAN segments


Extends max distance between nodes


But individual segment collision domains become one
large collision domain


Can’t interconnect 10BaseT & 100BaseT

hub

hub

hub

hub

DataLink Layer

3
-
21

Ethernet Technologies: Switching


1 Gbps and 10 Gbps Ethernet
!


High data speed + larger distance + increasing
number of devices per LAN =>
switching


Switch: Link layer device


Stores
-
and
-
forwards Ethernet frames


when frame is to be forwarded on segment, uses
CSMA/CD to access segment


Transparent: hosts unaware of presence of switches


Plug
-
and
-
play: do not need to be configured

DataLink Layer

3
-
22

Switching



How do determine onto which LAN segment to
forward frame?



Looks like a routing problem...

hub

hub

hub

switch

1

2

3

DataLink Layer

3
-
23

Self learning


A switch has a
switch table


entry in switch table:


(MAC Address, Interface, Time Stamp)


stale entries in table dropped (TTL can be 60 min)


switch

learns

which hosts can be reached through
which interfaces


when frame received, switch “learns” location of
sender: incoming LAN segment


records sender/location pair in switch table

DataLink Layer

3
-
24

Filtering/Forwarding

When switch receives a frame:


index switch table using MAC dest address

if
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

DataLink Layer

3
-
25

Switch example 1

Suppose C sends frame to D


Switch receives frame from from C


notes in bridge table that C is on interface 1


because D is not in table, switch forwards frame into
interfaces 2 and 3


frame received by D

hub

hub

hub

switch

A

B

C

D

E

F

G

H

I

address

interface

A

B

E

G



1

1

2

3

1

2

3

DataLink Layer

3
-
26

Switch example 1

Suppose D replies back with frame to C.



Switch receives frame from from D


notes in bridge table that D is on interface 2


because C is in table, switch forwards frame only to
interface 1


frame received by C

hub

hub

hub

switch

A

B

C

D

E

F

G

H

I

address

interface

A

B

E

G

C

1

1

2

3

1

DataLink Layer

3
-
27

Switch example 2: unicast

08
-
00
-
60
-
00
-
00
-
09

1

08
-
00
-
60
-
00
-
00
-
C2

4

08
-
00
-
60
-
00
-
00
-
23

3

08
-
00
-
60
-
00
-
00
-
46

1

08
-
00
-
60
-
00
-
00
-
51

2

08
-
00
-
60
-
00
-
00
-
92

3

08
-
00
-
60
-
00
-
00
-
17

2

08
-
00
-
60
-
00
-
00
-
1B

4

08
-
00
-
60
-
00
-
00
-
09

08
-
00
-
60
-
00
-
00
-
46

08
-
00
-
60
-
00
-
00
-
51

08
-
00
-
60
-
00
-
00
-
17

08
-
00
-
60
-
00
-
00
-
C2

08
-
00
-
60
-
00
-
00
-
1B

08
-
00
-
60
-
00
-
00
-
23

08
-
00
-
60
-
00
-
00
-
92

Learnt address table

port 4

port 1

port 2

port 3

08
-
00
-
60
-
00
-
46


08
-
00
-
60
-
00
-
17

08
-
00
-
60
-
00
-
46


08
-
00
-
60
-
00
-
09

DataLink Layer

3
-
28

Switch example 2: flooding / multicast

08
-
00
-
60
-
00
-
00
-
09

1

08
-
00
-
60
-
00
-
00
-
C2

4

08
-
00
-
60
-
00
-
00
-
23

3

08
-
00
-
60
-
00
-
00
-
46

1

08
-
00
-
60
-
00
-
00
-
51

2

08
-
00
-
60
-
00
-
00
-
92

3

08
-
00
-
60
-
00
-
00
-
17

2

08
-
00
-
60
-
00
-
00
-
1B

4

08
-
00
-
60
-
00
-
00
-
09

08
-
00
-
60
-
00
-
00
-
46

08
-
00
-
60
-
00
-
00
-
51

08
-
00
-
60
-
00
-
00
-
17

08
-
00
-
60
-
00
-
00
-
C2

08
-
00
-
60
-
00
-
00
-
1B

08
-
00
-
60
-
00
-
00
-
23

08
-
00
-
60
-
00
-
00
-
92

Learnt address table

port 4

port 1

port 2

port 3

08
-
00
-
60
-
00
-
00
-
2C

08
-
00
-
60
-
00
-
46


08
-
00
-
60
-
00
-
2C

DataLink Layer

3
-
29

Switch: traffic isolation


Breaks up a “
broadcast domain
” (LAN) into
multiple “
collision domains
” (LAN segments)


Increased total max throughput


limitless nodes and geographical coverage


Can connect different Ethernet types


Transparent “plug
-
and
-
play”

hub

hub

hub

switch

collision domain

collision domain

collision

domain

DataLink Layer

3
-
30

Institutional network

hub

hub

hub

switch

to external

network

router

IP subnet

mail server

web server

DataLink Layer

3
-
31

VLANs: motivation

What happens if:


CS user moves office to EE,
but wants connect to CS
switch?


single broadcast domain:


all layer
-
2 broadcast
traffic (ARP, DHCP)
crosses entire LAN
(security/privacy,
efficiency issues)


each lowest level switch has
only few ports in use


Computer

Science

Electrical

Engineering

Computer

Engineering

What’s wrong with this picture?

DataLink Layer

3
-
32

VLANs

Port
-
based VLAN
: switch ports grouped
(by switch management software) so
that
single

physical switch ……


Switch(es) supporting
VLAN capabilities can
be configured to
define multiple
virtual
LANS over single
physical LAN
infrastructure.

Virtual Local

Area Network

1

8

9

16

10

2

7



Electrical Engineering

(VLAN ports 1
-
8)

Computer Science

(VLAN ports 9
-
15)

15



Electrical Engineering

(VLAN ports 1
-
8)



1

8

2

7

9

16

10

15



Computer Science

(VLAN ports 9
-
16)

… operates as
multiple

virtual switches


DataLink Layer

3
-
33

Port
-
based VLAN

1

8

9

16

10

2

7



Electrical Engineering

(VLAN ports 1
-
8)

Computer Science

(VLAN ports 9
-
15)

15




traffic isolation:

frames
to/from ports 1
-
8 can
only

reach ports 1
-
8


can also define VLAN based on
MAC addresses of endpoints,
rather than switch port


dynamic membership:

ports can be dynamically
assigned among VLANs

router


forwarding between VLANS:

done via routing (just as with
separate switches)


in practice vendors sell combined
switches plus routers

DataLink Layer

3
-
34

VLANS spanning multiple switches


trunk port:

carries frames between VLANS defined
over multiple physical switches


frames forwarded within VLAN between switches can’t be
vanilla 802.1 frames (must carry VLAN ID info)


802.1q protocol adds/removed additional header fields for
frames forwarded between trunk ports

1

8

9

10

2

7



Electrical Engineering

(VLAN ports 1
-
8)

Computer Science

(VLAN ports 9
-
15)

15



2

7

3

Ports 2,3,5 belong to EE VLAN

Ports 4,6,7,8 belong to CS VLAN

5

4

6

8

16

1

DataLink Layer

3
-
35

Type

2
-
byte Tag Protocol Identifier


(value: 81
-
00)

Tag Control Information (12 bit VLAN ID field,


3 bit priority field like IP TOS)


Recomputed

CRC


802.1Q VLAN frame format

802.1 frame

802.1Q frame

DataLink Layer

3
-
36

Loops: disaster!

08
-
00
-
60
-
00
-
09

08
-
00
-
60
-
00
-
46

08
-
00
-
60
-
00
-
51

08
-
00
-
60
-
00
-
17

08
-
00
-
60
-
00
-
C2

08
-
00
-
60
-
00
-
1B

08
-
00
-
60
-
00
-
23

08
-
00
-
60
-
00
-
92

port 4

port 1

port 2

port 3


Frame loops forever!


Learning messed up!


Inadvertant


Intentional: for redundancy

08
-
00
-
60
-
00
-
46


08
-
00
-
60
-
00
-
17

DataLink Layer

3
-
37

Breaking the loop: Spanning Tree


Disable set of switch interfaces so that resulting topology is
a “tree” that “spans” all LAN segments


Disabled

DataLink Layer

3
-
38

Spanning tree protocol (IEEE 802.1d)


Every bridge has bridge
-
id


bridge
-
id = 2
-
byte priority + 6
-
byte MAC addr


Question: MAC address of bridge??


Every port of bridge has


port
-
id = 1
-
byte priority + 1
-
byte port
-
number


port
-
cost = inversely proportional to link speed


Bridge with lowest bridge
-
id is
root bridge


On each LAN segment, bridge with lowest path
cost to root is
designated bridge

(use bridge
-
id
and port
-
id to break ties)


A bridge forwards frames through a port only if it
is a designated bridge for that LAN segment


DataLink Layer

3
-
39

STP terminology


Port roles:


Root port (switch port leading to root)


Designated port (LAN port leading to root)


Alternate / backup port (anything else)


Port states:


Blocking (no send/rcv, except STP bpdus)


Listening (prepare for learning/forwarding)


Learning (learn MAC addr but no forwarding)


Forwarding (send/rcv frames)


Can disable STP on port or switch


All frames are forwarded


How about Bridge Protocol Data Units (BPDUs)?

DataLink Layer

3
-
40

STP operation


BPDU carries 4
-
tuple:


<root
-
id, root
-
cost, bridge
-
id, port
-
id>


Store rcvd and send 4
-
tuple for each port:


port with best rcvd 4
-
tuple is root port


root bridge has no such port


if send 4
-
tuple better than rcv 4
-
tuple, port is
designated port


rest of the ports are alternate/backup ports


Various timers


DataLink Layer

3
-
41

Spanning tree example

root

DP

DP

DP

DP

DP

RP

DP

DP

DP

RP

RP

DP

DP

DP

RP

DataLink Layer

3
-
42

Ethernet Summary


Broadcast Ethernet


Framing


Addressing


Media access


From broadcast to switched Ethernet


Transparent bridging (switching)


Loops and the spanning tree protocol