the link layer. 2 announcements no cs 415 section tomorrow, tuesday project 4 is due next monday,...

29
The Link Layer

Post on 15-Jan-2016

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

The Link Layer

Page 2: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

2

Announcements• No CS 415 section tomorrow, Tuesday

• Project 4 is due next Monday, April 9th

• Prelim II will be Thursday, April 26th, 7-9:30pm, in PH 101

Page 3: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

3

Review: OSI Levels• Physical Layer

– electrical details of bits on the wire

• Data Link Layer– sending “frames” of bits and error detection

• Network Layer– routing packets to the destination

• Transport Layer– reliable transmission of messages, disassembly/assembly, ordering,

retransmission of lost packets

• Session Layer– really part of transport, typically Not implemented

• Presentation Layer– data representation in the message

• Application– high-level protocols (mail, ftp, etc.)

Page 4: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

4

Review: OSI Levels

Presentation

Transport

Network

Data Link

Physical

Application

Presentation

Transport

Network

Data Link

Physical

ApplicationNode A Node B

Network

Session Session

Page 5: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

5

What is purpose of this layer?• Invoke Physical Layer

– Physically encode bits on the wire

• Link = pipe to send information– E.g. point to point or broadcast

• Can be built out of:– Twisted pair, coaxial cable, optical fiber, radio waves, etc

• Links should only be able to send data– Could corrupt, lose, reorder, duplicate, (fail in other ways)

Page 6: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

6

Broadcast Networks Details

• Delivery: When you broadcast a packet, how does a receiver know who it is for? (packet goes to everyone!)

– Put header on front of packet: [ Destination | Packet ]– Everyone gets packet, discards if not the target– In Ethernet, this check is done in hardware

• No OS interrupt if not for particular destination– This is layering: we’re going to build complex network protocols by layering on

top of the packet

Header(Dest:2)

Body(Data)

MessageID:1

(ignore)

ID:2(receive)

ID:4(ignore)

ID:3(sender)

Page 7: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

7

Point-to-point networks

• Why have a shared broadcast medium? Why not simplify and only have point-to-point links + routers/switches?

– Didn’t used to be cost-effective– Now, easy to make high-speed switches and routers that can forward

packets from a sender to a receiver.• Point-to-point network: a network in which every physical wire

is connected to only two computers• Switch: a bridge that transforms a shared-bus configuration

into a point-to-point network.• Router: a device that acts as a junction between two networks

to transfer data packets among them.

Router

Intern

et

Switch

Page 8: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

8

Point-to-Point Networks Discussion• Advantages:

– Higher link performance• Can drive point-to-point link faster than broadcast link since less capacitance/less

echoes (from impedance mismatches)– Greater aggregate bandwidth than broadcast link

• Can have multiple senders at once– Can add capacity incrementally

• Add more links/switches to get more capacity– Better fault tolerance (as in the Internet)– Lower Latency

• No arbitration to send, although need buffer in the switch• Disadvantages:

– More expensive than having everyone share broadcast link– However, technology costs now much cheaper

• Examples– ATM (asynchronous transfer mode)

• The first commercial point-to-point LAN• Inspiration taken from telephone network

– Switched Ethernet• Same packet format and signaling as broadcast Ethernet, but only two machines

on each ethernet.

Page 9: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

9

How to connect routers/machines?• WAN/Router Connections

– Commercial:• T1 (1.5 Mbps), T3 (44 Mbps)

• OC1 (51 Mbps), OC3 (155 Mbps)

• ISDN (64 Kbps)

• Frame Relay (1-100 Mbps, usually 1.5 Mbps)

• ATM (some Gbps)

– To your home:• DSL

• Cable

• Local Area:– Ethernet: IEEE 802.3 (10 Mbps, 100 Mbps, 1 Gbps)– Wireless: IEEE 802.11 b/g/a (11 Mbps, 22 Mbps, 54 Mbps)

Page 10: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

10

Link level Issues• Encoding: map bits to analog signals• Framing: Group bits into frames (packets)• Arbitration: multiple senders, one resource• Addressing: multiple receivers, one wire

Page 11: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

11

Encoding• Map 1s and 0s to electric signals• Simple scheme: Non-Return to Zero (NRZ)

– 0 = low voltage, 1 = high voltage

• Problems:– How to tell an error? When jammed? When is bus idle?– When to sample? Clock recovery is difficult.

• Idea: Recover clock using encoding transitions

1 0 1 1 0

Page 12: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

12

Manchester Encoding• Used by Ethernet• Idea: Map 0 to low-to-high transition, 1 to high-to-low

• Plusses: can detect dead-link, can recover clock• Bad: reduce bandwidth, i.e. bit rate = ½ baud rate

– If wire can do X transition per second?

0 1 1 0

Page 13: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

13

Framing• Why send packets?

– Error control

• How do you know when to stop reading?– Sentinel approach: send start and end sequence– For example, if sentinel is 11111– 11111 00101001111100 11111 10101001 11111 010011 11111

– What if sentinel appears in the data?• map sentinel to something else, receiver maps it back

– Bit stuffing

Page 14: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

14

Example: HDLC• High-Level Data Link Control (HLDC)

– Data link layer protocol developed by the ISO

• Same sentinel for begin and end: 0111 1110• packet format:

• Bit stuffing– Sender: If 5 1s then insert a 0

– Receiver: if 5 1s followed by a 0, remove 0

• Else read next bit

• Packet size now depends on the contents

0111 1110 header data CRC 0111 1110

0111 1110 0111 1101 0

0111 1101 0 0111 1110

Page 15: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

15

Broadcast Network Arbitration• Arbitration: Act of negotiating use of shared medium

– What if two senders try to broadcast at same time?– Concurrent activity but can’t use shared memory to coordinate!

• Aloha network (70’s): packet radio within Hawaii– Blind broadcast, with checksum at end of

packet. If received correctly (not garbled), send back an acknowledgement. If not received correctly, discard.

• Need checksum anyway – in case airplane flies overhead

– Sender waits for a while, and if doesn’t get an acknowledgement, re-transmits.

– If two senders try to send at same time, both get garbled, both simply re-send later.

– Problem: Stability: what if load increases?• More collisions less gets through more resent more load… More

collisions…• Unfortunately: some sender may have started in clear, get scrambled

without finishing

Page 16: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

16

Arbitration• One medium, multiple senders

– What did we do for CPU, memory, readers/writers?

– New Problem: No centralized control

• Approaches– TDMA: Time Division Multiple Access

• Divide time into slots, round robin among senders• If you exceed the capacity do not admit more (busy signal)

– FDMA: Frequency Division Multiple Access (AMPS)• Divide spectrum into channels, give each sender a channel• If no more channels available, give a busy signal

– Good for continuous streams: fixed delay, constant data rate

– Bad for bursty Internet traffic: idle slots

Page 17: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

17

Ethernet• Developed in 1976, Metcalfe and Boggs at Xerox

• Uses CSMA/CD: – Carrier Sense Multiple Access with Collision Detection

• Easy way to connect LANs

Metcalfe’s Ethernet sketch

Page 18: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

18

CSMA/CD• Carrier Sense:

– Listen before you speak

• Multiple Access:– Multiple hosts can access the network

• Collision Detection:– Can make out if someone else started speaking

Older Ethernet Frame

Page 19: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

19

CSMA

Wait until

carrier free

Page 20: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

20

CSMA/CD

Garbled signals

If the sender detects a collision, it will stop and then retry!

What is the problem?

Page 21: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

21

CSMA/CD

Packet?

Sense Carrier

Discard Packet

Send Detect Collision

Jam channel b=CalcBackoff();

wait(b);attempts++;

No

Yes

attempts < 16

attempts == 16

Page 22: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

22

Ethernet’s CSMA/CD (more)Jam Signal: make 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

• Adaptive and Random– First time, pick random wait time with some initial mean. If collide

again, pick random value from bigger mean wait time. Etc.– Randomness is important to decouple colliding senders– Scheme figures out how many people are trying to send!

• Example– 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 ten or more collisions, choose K from {0,1,2,3,4,…,1023}

Page 23: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

23

Packet Size

If packets are too small, the collision goes unnoticed Limit packet size Limit network diameter Use CRC to check frame integrity truncated packets are filtered out

Page 24: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

24

Ethernet Problems• What if there is a malicious user?

– Might not use exponential backoff– Might listen promiscuously to packets

• Integrating Fast and Gigabit Ethernet

Page 25: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

25

Addressing & ARP

• ARP is used to discover physical addresses• ARP = Address Resolution Protocol

“What is the physical address of the host named 128.84.96.89”

128.84.96.90128.84.96.89

128.84.96.91

“I’m at 1a:34:2c:9a:de:cc”

Page 26: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

26

Addressing & RARP

• RARP is used to discover virtual addresses• RARP = Reverse Address Resolution Protocol

“I just got here. My physical address is 1a:34:2c:9a:de:cc. What’s my name ?”

128.84.96.90RARP Server

???

128.84.96.91

“Your name is 128.84.96.89”

Page 27: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

27

Repeaters and Bridges• Both connect LAN segments

• Usually do not originate data

• Repeaters (Hubs): physical layer devices– forward packets on all LAN segments– Useful for increasing range– Increases contention

• Bridges: link layer devices– Forward packets only if meant on that segment– Isolates congestion– More expensive

Page 28: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

28

Backbone Bridge

Page 29: The Link Layer. 2 Announcements No CS 415 section tomorrow, Tuesday Project 4 is due next Monday, April 9th Prelim II will be Thursday, April 26th, 7-9:30pm,

29

Summary• Data Link Layer

– layer two of the seven-layer OSI model • Layer two of the five-layer TCP/IP reference model as well.

– Responds to service requests from the network layer and issues service requests to the physical layer.

• Broadcast vs Point-to-point– Point-to-point is often higher performance, but traditionally higher cost as well– Switched Ethernet is common now

• Data Link Layer Issues– Encoding: map bits to analog signals

• Manchester encoding

– Framing: Group bits into frames (packets)• Bit stuffing

– Arbitration: multiple senders, one resource• Ethernet uses CSMA/CD (carrier sense multiple access/collision detection)

– Addressing: multiple receivers, one wire• ARP (address resolution protocol)