CS计算机代考程序代写 scheme dns DHCP cache algorithm 10.Link_Layer

10.Link_Layer

Link Layer

COMP 3331/9331:
Computer Networks and

Applications
Week 9

Data link Layer

Reading Guide: Chapter 6, Sections 6.2 – 6.4, 6.7

Complete your myExperience and shape
the future of education at UNSW.

Click the link in Moodle

or login to myExperience.unsw.edu.au

(use .edu.au to login)

The survey is confidential, your identity will never be released

Survey results are not released to teaching staff until after your results are published

Link layer, LANs: outline

6.1 introduction, services
6.2 error detection,

correction
6.3 multiple access

protocols
6.4 Switched LANs

§ addressing, ARP
§ Ethernet
§ switches

6.7 a day in the life of a
web request

4

Error detection
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 if the protocol is robust
• larger EDC field yields better detection and correction

otherwise

5

Error Detection
Ø Error coding
Ø Add check bits to the message bits to let some

errors be detected and some be corrected
Ø How to structure the code to detect many errors

with few check bits and modest computation?
Ø A simple code

• Send two copies of the same message : 101101
• Error if the copies are different : 101100
• How many errors can it correct? 0
• How many errors can it detect? At most 3
• How many errors will make it fail? Specific 2-bit errors
• What is the overhead? 100% (wrt original message)

6

Simple Parity – Sender

7

Simple Parity – Sender

• Suppose you want to send the message:
– 001011011011000110010

• For every d bits (e.g., d = 7), add a parity bit:
– 1 if the number of one’s is odd
– 0 if the number of one’s is even

– 001011011101100001100101

Message chunk Parity bit
0010110 1
1101100 0
0110010 1

Example uses even parity

Simple Parity – Receiver

8

Simple Parity – Receiver

• For each block of size d:
– Count the number of 1’s and compare with

following parity bit.

• If an odd number of bits get flipped, we’ll
detect it (can’t do much to correct it).

• Cost: One extra bit for every d
– In this example, 21 -> 24 bits.

Two-Dimensional Parity

9

Two-Dimensional Parity

• Suppose you want to send the same message:
– 001011011011000110010

• Add an extra parity byte, compute parity on
“columns” too.

• Can detect 1, 2, 3-bit (and some 4-bit) errors
Message chunk Parity bit

0010110 1
1101100 0
0110010 1

Parity byte: 1001000 0

Example uses even parity

Forward Error Correction

10

Forward Error Correction

• With two-dimensional parity, we can even
correct single-bit errors.

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

Parity
bits

Parity byte

Exactly one bit has been flipped. Which is it?

Example uses even parity

In practice

11

In practice…

• Bit errors occur in bursts.

• We’re willing to trade computational
complexity for space efficiency.
– Make the detection routine more complex, to

detect error bursts, without tons of extra data

• Insight: We need hardware to interface with
the network, do the computation there!

Error Detection and Correction
Ø Checksum

• Sum up data in N-bit words
• Internet Checksum uses 16-bit words

Ø How well checksum works?
• How many errors can it detect/correct?

Ø What have we gained as compared to parity
bit?
• Can now detect all burst errors up to 16

12

Cyclic redundancy check
Ø more powerful error-detection coding
Ø view data bits, D, as a binary number
Ø choose r+1 bit pattern (generator), G known to both endpoints
Ø goal: choose r CRC bits, R, such that

§ exactly divisible by G (modulo 2)
§ receiver knows G, divides by G. If non-zero remainder: error

detected!
§ can detect all burst errors less than r+1 bits

Ø widely used in practice (Ethernet, 802.11 WiFi)

13

Cyclic redundancy check
Ø Sender operation

• Extend D data bits with R zeros
• Divide by generator G
• Keep remainder, ignore quotient
• Adjust R check bits by the remainder

Ø Receiver Procedure
• Divide received frame by G and check for zero

remainder

14

A Note on Modulo-2 Arithmetic
• All calculations are modulo-2 arithmetic

• No carries or borrows in subtraction

• Addition and subtraction are identical and both are equivalent to XOR
• 1011 XOR 0101 = 1110

• 1011 – 0101 = 1110

• 1011 + 0101 = 1110

• Multiplication by 2k is essentially a left shift by k bits
• 1011 x 22 = 101100

15

CRC example

want:
D.2r XOR R = nG

equivalently:
D.2r = nG XOR R

equivalently:
if we divide D.2r by
G, want remainder R
to satisfy:

R = remainder[ ]D
.2r
G

1001 101110000
1001

1

101

01011

000
1010
1001

110
000
1100
1001
1010
1001
011

DG

R

r = 3

16

At the sender

Sender sends into the channel

CRC example

1001 101110011
1001

1

101

01011

000
1010
1001

110
000
1101
1001
1001
1001
000

DG r = 3

17

At the receiver

R

Remainder is zero, so no errors

Receiver divides the received frame and
divides by G and checks if the remainder is
zero.

In this example, there are no errors, so the
receiver receives (from previous slide)

Quiz: Error Detection/Correction

v Can these schemes respectively correct any
bit errors: Internet checksums, two-dimensional
parity, cyclic redundancy check (CRC)

a) Yes, No, No
b) No, Yes, Yes
c) No, Yes, No
d) No, No, Yes
e) No, No, No

18

ANSWER: C

Link layer, LANs: outline

6.1 introduction, services
6.2 error detection,

correction
6.3 multiple access

protocols
6.4 Switched LANs

§ addressing, ARP
§ Ethernet
§ switches

6.7 a day in the life of a
web request

19

Multiple access links, protocols
two types of “links”:
v point-to-point

§ PPP for dial-up access
§ point-to-point link between Ethernet switch, host

v broadcast (shared wire or medium)
§ old-fashioned Ethernet
§ upstream HFC
§ 802.11 wireless LAN

shared wire (e.g.,
cabled Ethernet)

shared RF
(e.g., 802.11 WiFi)

shared RF
(satellite)

humans at a
cocktail party

(shared air, acoustical)

20

Multiple access protocols
v single shared broadcast channel
v two or more simultaneous transmissions by nodes:

interference
§ collision if node receives two or more signals at the same

time

multiple access protocol
v distributed algorithm that determines how nodes share

channel, i.e., determine when node can transmit
v communication about channel sharing must use channel itself!

§ no out-of-band channel for coordination

21

An ideal multiple access protocol

given: broadcast channel of rate R bps
requirements:

1. 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/M
3. fully decentralized:

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

4. simple

22

MAC protocols: taxonomy

three broad classes:
v channel partitioning

§ divide channel into smaller “pieces” (time slots, frequency, code)
§ allocate piece to node for exclusive use

v random access
§ channel not divided, allow collisions
§ “recover” from collisions

v “taking turns”
§ nodes take turns, but nodes with more to send can take longer

turns

23

Channel partitioning MAC protocols: TDMA

TDMA: time division multiple access
v access to channel in “rounds”
v each station gets fixed length slot (length = pkt

trans time) in each round
v unused slots go idle
v example: 6-station LAN, 1,3,4 have pkt, slots

2,5,6 idle

1 3 4 1 3 4

6-slot
frame

6-slot
frame

24

FDMA: frequency division multiple access
v channel spectrum divided into frequency bands
v each station assigned fixed frequency band
v unused transmission time in frequency bands go idle
v example: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6

idle

fr
eq

ue
nc

y
ba

nd
s

time

FDM cable

Channel partitioning MAC protocols: FDMA

25

Quiz: Does channel partitioning satisfy ideal properties ?How many of our ideal properties does
channel partitioning give us?

1. if only 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/M (fairness)
3. fully decentralized:

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

4. simple

A. 0
B. 1
C. 2
D. 3
E. 4

(Which ones?)

26

ANSWER: C
2 and 4 from above are satisfied
Assuming M=N (no of nodes on the network)
if M < N, then 2 is not satisfied) Random access protocols v when node has packet to send § transmit at full channel data rate R. § no a priori coordination among nodes v two or more transmitting nodes ➜ “collision”, v random access MAC protocol specifies: § how to detect collisions § how to recover from collisions (e.g., via delayed retransmissions) v examples of random access MAC protocols: § slotted ALOHA § ALOHA § CSMA, CSMA/CD, CSMA/CA 27 Where it all Started: AlohaNet v Norm Abramson left Stanford in 1970 (so he could surf!) v Set up first data communication system for Hawaiian islands v Central hub at U. Hawaii, Oahu 28 Slotted ALOHA assumptions: v all frames same size v time divided into equal size slots (time to transmit 1 frame) v nodes start to transmit only at the beginning of a slot v nodes are synchronized v if 2 or more nodes transmit in slot, all nodes detect collision operation: v when node obtains fresh frame, transmits in next slot § if no collision: node can send new frame in next slot § if collision: node retransmits frame in each subsequent slot with prob. p until success 29 Pros: v single active node can continuously transmit at full rate of channel v highly decentralized: only slots in nodes need to be in sync v simple Cons: v collisions, wasting slots v idle slots v nodes may be able to detect collision in less than time to transmit packet v clock synchronization Slotted ALOHA 1 1 1 1 2 3 2 2 3 3 node 1 node 2 node 3 C C CS S SE E E 30 v suppose: N nodes with many frames to send, each transmits in slot with probability p v prob that given node has success in a slot = p(1- p)N-1 v prob that any node has a success = Np(1-p)N-1 v max efficiency: find p* that maximizes Np(1-p)N-1 v for many nodes, take limit of Np*(1-p*)N-1 as N goes to infinity, gives: max efficiency = 1/e = .37 efficiency: long-run fraction of successful slots (many nodes, all with many frames to send) at best: channel used for useful transmissions 37% of time! ! Slotted ALOHA: efficiency 31 Pure (unslotted) ALOHA v unslotted Aloha: simpler, no synchronization v when frame first arrives § transmit immediately v collision probability increases: § frame sent at t0 collides with other frames sent in [t0- 1,t0+1] 32 Pure ALOHA efficiency P(success by given node) = P(node transmits) . P(no other node transmits in [t0-1,t0] . P(no other node transmits in [t0,t0+1] = p . (1-p)N-1 . (1-p)N-1 = p . (1-p)2(N-1) … choosing optimum p and then letting n = 1/(2e) = .18 even worse than slotted Aloha! 33 CSMA (carrier sense multiple access) CSMA: listen before transmit: if channel sensed idle: transmit entire frame v if channel sensed busy, defer transmission v human analogy: don’t interrupt others! v Does this eliminate all collisions? § No, because of nonzero propagation delay 34 CSMA collisions v collisions can still occur: propagation delay means two nodes may not hear each other’s transmission v collision: entire packet transmission time wasted § distance & propagation delay play role in determining collision probability spatial layout of nodes CSMA reduces but does not eliminate collisions Biggest remaining problem? Collisions can be detected earlier! 35 CSMA/CD (collision detection) CSMA/CD: carrier sensing, deferral as in CSMA § collisions detected within short time § colliding transmissions aborted, reducing channel wastage v collision detection: § easy in wired LANs: measure signal strengths, compare transmitted, received signals § difficult in wireless LANs: received signal strength overwhelmed by local transmission strength v human analogy: the polite conversationalist 36 CSMA/CD (collision detection) spatial layout of nodes http://media.pearsoncmg.com/aw/aw_kurose_network_2/applets/csmacd/csmacd.html Note: for this to work, need restrictions on minimum frame size and maximum distance. Why? 37 Minimum Packet Size v Why enforce a minimum packet size? v Give a host enough time to detect collisions v In Ethernet, minimum packet size = 64 bytes (two 6-byte addresses, 2-byte type, 4-byte CRC, and 46 bytes of data) v If host has less than 46 bytes to send, the adaptor pads (adds) bytes to make it 46 bytes v What is the relationship between minimum packet size and the length of the LAN? 38 propagation delay (d)a) Time = t; Host 1 starts to send frame Host 1 Host 2 propagation delay (d) Host 1 Host 2 b) Time = t + d; Host 2 starts to send a frame, just before it hears from host 1’s frame propagation delay (d) Host 1 Host 2c) Time = t + 2*d; Host 1 hears Host 2’s frame à detects collision For 10 Mbps LAN, LAN length = (min_frame_size)*(propagation_speed)/(2*bandwidth) = = (8*64B)*(2*108mps)/(2*107 bps) = 5120m approx What about 100 mbps? 1 gbps? 10 gbps? Limits on CSMA/CD Network Length 39 min_frame_size/bandwidth = 2*LAN length/propagation_speed Ethernet CSMA/CD algorithm 1. NIC receives datagram from network layer, creates frame 2. If NIC senses channel idle, starts frame transmission. If NIC senses channel busy, waits until channel idle, then transmits. 3. If NIC transmits entire frame without detecting another transmission, NIC is done with frame ! 4. If NIC detects another transmission while transmitting, aborts and sends jam signal 5. After aborting, NIC enters binary (exponential) backoff: § after mth collision, NIC chooses K at random from {0,1,2, …, 2m-1}. NIC waits K·512 bit times, returns to Step 2 § longer backoff interval with more collisions 40NIC = Network Interface Card Quiz: Does CSMA/CD satisfy ideal properties ?How many of our ideal properties does channel partitioning give us? 1. if only 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/M (fairness) 3. fully decentralized: • no synchronization of clocks, slots • no special node to coordinate transmissions 4. simple A. 0 B. 1 C. 2 D. 3 E. 4 (Which ones?) 41 www.zeetings.com/salil Answer: D 1, 3 and 4 are satisfied 2 is not satisfied as bandwidth is wasted due to collisions when multiple nodes are transmitting (neglect the overheads for channel sensing) “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 “taking turns” protocols look for best of both worlds! 42 polling: v master node “invites” slave nodes to transmit in turn v typically used with “dumb” slave devices v concerns: § polling overhead § latency § single point of failure (master) master slaves poll data data “Taking turns” MAC protocols 43 token passing: v control token passed from one node to next sequentially. v token message v concerns: § token overhead § latency § single point of failure (token) T data (nothing to send) T “Taking turns” MAC protocols 44 Quiz: Does taking turns satisfy ideal properties ?How many of our ideal properties does channel partitioning give us? 1. if only 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/M (fairness) 3. fully decentralized: • no synchronization of clocks, slots • no special node to coordinate transmissions 4. simple A. 0 B. 1 C. 2 D. 3 E. 4 (Which ones?) 45 www.zeetings.com/salil Answer: D 1, 2 and 4 are satisfied (neglect the overheads for polling and token passing) Summary of MAC protocols v channel partitioning, by time, frequency or code § Time Division, Frequency Division v random access (dynamic), § ALOHA, S-ALOHA, CSMA, CSMA/CD § carrier sensing: easy in some technologies (wire), hard in others (wireless) § CSMA/CD used in Ethernet § CSMA/CA used in 802.11 v taking turns § polling from central site, token passing § bluetooth, FDDI, token ring 46 Link layer, LANs: outline 6.1 introduction, services 6.2 error detection, correction 6.3 multiple access protocols 6.4 Switched LANs § addressing, ARP § Ethernet § switches 6.7 a day in the life of a web request 47 MAC addresses and ARP v 32-bit IP address: § network-layer address for interface § used for layer 3 (network layer) forwarding v MAC (or LAN or physical or Ethernet) address: § function: used ‘locally” to get frame from one interface to another physically-connected interface (same network, in IP- addressing sense) § 48-bit MAC address (for most LANs) burned in NIC ROM, also sometimes software settable § e.g.: 1A-2F-BB-76-09-AD hexadecimal (base 16) notation (each “number” represents 4 bits) 48 LAN addresses and ARP each adapter on LAN has unique LAN address adapter 1A-2F-BB-76-09-AD 58-23-D7-FA-20-B0 0C-C4-11-6F-E3-98 71-65-F7-2B-08-53 LAN (wired or wireless) 49 LAN addresses (more) v MAC address allocation administered by IEEE v manufacturer buys portion of MAC address space (to assure uniqueness) v MAC flat address ➜ portability § can move LAN card from one LAN to another v IP hierarchical address not portable § address depends on IP subnet to which node is attached 50 MAC Address vs. IP Address v MAC addresses (used in link-layer) § Hard-coded in read-only memory when adapter is built § Flat name space of 48 bits (e.g., 00-0E-9B-6E-49-76) § Portable, and can stay the same as the host moves § Used to get packet between interfaces on same network v IP addresses § Configured, or learned dynamically § Hierarchical name space of 32 bits (e.g., 12.178.66.9) § Not portable, and depends on where the host is attached § Used to get a packet to destination IP subnet 51 Taking Stock: Naming Layer Examples Structure Configuration Resolution Service App. Layer www.cse.unsw.edu.au organizational hierarchy ~ manual Network Layer 129.94.242.51 topological hierarchy DHCP Link layer 45-CC-4E-12-F0-97 vendor (flat) hard-coded DNS ARP 52 ARP: address resolution protocol ARP table: each IP node (host, router) on LAN has 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 determine
interface’s MAC address,
knowing its IP address?

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137.196.7.23

137.196.7.78

137.196.7.14

137.196.7.88

53

ARP protocol: same LAN
v A wants to send datagram

to B
§ B’s MAC address not in

A’s ARP table.
v A broadcasts ARP query

packet, containing B’s IP
address
§ dest MAC address = FF-FF-

FF-FF-FF-FF
§ all nodes on LAN receive

ARP query
v B receives ARP packet,

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

address (unicast)

v 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

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

without intervention from net
administrator

v Only the node that responds to an
ARP query caches the IP-MAC
address mapping in its ARP table for
the source of the query
§ In above example, B will add an

ARP entry for A, but other nodes
on the LAN will NOT

54

walkthrough: send datagram from A to B via R
§ focus on addressing – at IP (datagram) and MAC layer (frame)
§ assume A knows B’s IP address (how?)

• How does A know B is not local (i.e., connected to the same LAN as A) ?
– Subnet Mask (discovered via DHCP)

§ assume A knows IP address of first hop router, R (how?)
– Default router (discovered via DHCP)

§ assume A knows R’s MAC address (how?)
– ARP

Addressing: routing to another LAN

R

1A-23-F9-CD-06-9B
222.222.222.220

111.111.111.110
E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D

111.111.111.112

111.111.111.111
74-29-9C-E8-FF-55

A

222.222.222.222
49-BD-D2-C7-56-2A

222.222.222.221
88-B2-2F-54-1A-0F

B

55

R

1A-23-F9-CD-06-9B
222.222.222.220

111.111.111.110
E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D

111.111.111.112

111.111.111.111
74-29-9C-E8-FF-55

A

222.222.222.222
49-BD-D2-C7-56-2A

222.222.222.221
88-B2-2F-54-1A-0F

B

Addressing: routing to another LAN

IP
Eth
Phy

IP src: 111.111.111.111
IP dest: 222.222.222.222

v A creates IP datagram with IP source A, destination B
v A creates link-layer frame with R’s MAC address as dest, frame

contains A-to-B IP datagram

MAC src: 74-29-9C-E8-FF-55
MAC dest: E6-E9-00-17-BB-4B

56

R

1A-23-F9-CD-06-9B
222.222.222.220

111.111.111.110
E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D

111.111.111.112

111.111.111.111
74-29-9C-E8-FF-55

A

222.222.222.222
49-BD-D2-C7-56-2A

222.222.222.221
88-B2-2F-54-1A-0F

B

Addressing: routing to another LAN

IP
Eth
Phy

v frame sent from A to R

IP
Eth
Phy

v frame received at R, datagram removed, passed up to IP

MAC src: 74-29-9C-E8-FF-55
MAC dest: E6-E9-00-17-BB-4B

IP src: 111.111.111.111
IP dest: 222.222.222.222

IP src: 111.111.111.111
IP dest: 222.222.222.222

57

R

1A-23-F9-CD-06-9B
222.222.222.220

111.111.111.110
E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D

111.111.111.112

111.111.111.111
74-29-9C-E8-FF-55

A

222.222.222.222
49-BD-D2-C7-56-2A

222.222.222.221
88-B2-2F-54-1A-0F

B

Addressing: routing to another LAN

IP src: 111.111.111.111
IP dest: 222.222.222.222

v R forwards datagram with IP source A, destination B (forwarding table)
v R creates link-layer frame with B’s MAC address as dest, frame

contains A-to-B IP datagram

MAC src: 1A-23-F9-CD-06-9B
MAC dest: 49-BD-D2-C7-56-2A

IP
Eth
Phy

IP
Eth
Phy

58

R

1A-23-F9-CD-06-9B
222.222.222.220

111.111.111.110
E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D

111.111.111.112

111.111.111.111
74-29-9C-E8-FF-55

A

222.222.222.222
49-BD-D2-C7-56-2A

222.222.222.221
88-B2-2F-54-1A-0F

B

Addressing: routing to another LAN
v R forwards datagram with IP source A, destination B
v R creates link-layer frame with B’s MAC address as dest, frame

contains A-to-B IP datagram

IP src: 111.111.111.111
IP dest: 222.222.222.222

MAC src: 1A-23-F9-CD-06-9B
MAC dest: 49-BD-D2-C7-56-2A

IP
Eth
Phy

IP
Eth
Phy

59

R

1A-23-F9-CD-06-9B
222.222.222.220

111.111.111.110
E6-E9-00-17-BB-4BCC-49-DE-D0-AB-7D

111.111.111.112

111.111.111.111
74-29-9C-E8-FF-55

A

222.222.222.222
49-BD-D2-C7-56-2A

222.222.222.221
88-B2-2F-54-1A-0F

B

Addressing: routing to another LAN
v R forwards datagram with IP source A, destination B
v R creates link-layer frame with B’s MAC address as dest, frame

contains A-to-B IP datagram

IP src: 111.111.111.111
IP dest: 222.222.222.222

MAC src: 1A-23-F9-CD-06-9B
MAC dest: 49-BD-D2-C7-56-2A

IP
Eth
Phy

60

Example ARP Table

61

Security Issues: ARP Cache Poisoning
v Denial of Service – Hacker replies back to an ARP query for a router

NIC with a fake MAC address
v Man-in-the-middle attack – Hacker can insert his/her machine along

the path between victim machine and gateway router
v Such attacks are generally hard to launch as hacker needs physical

access to the network

Solutions –
• Use Switched Ethernet with port
security enabled (i.e., one host
MAC address per switch port)
• Adopt static ARP configuration for
small size networks
• Use ARP monitoring tools such as
ARPWatch

http://www.watchguard.com/infocenter/editorial/135324.asp

62

Link layer, LANs: outline

6.1 introduction, services
6.2 error detection,

correction
6.3 multiple access

protocols
6.4 LANs

§ addressing, ARP
§ Ethernet
§ switches

6.7 a day in the life of a
web request

63

Ethernet

“dominant” wired LAN technology:
v first widely used LAN technology
v simpler, cheaper than token LANs and ATM
v kept up with speed race: 10 Mbps – 10 Gbps

Metcalfe’s Ethernet sketch

Bob Metcalfe, Xerox PARC, visits Hawaii and gets an idea!

64

Ethernet: physical topology
v bus: popular through mid 90s

§ all nodes in same collision domain (can collide with each other)
§ CSMA/CD for media access control

v star: prevails today
§ active switch in center
§ each “spoke” runs a (separate) Ethernet protocol (nodes do not collide with

each other)
§ No sharing, no CSMA/CD

switch

bus: coaxial cable
star

65

Ethernet frame structure
Sending adapter encapsulates IP datagram (or other

network layer protocol packet) in Ethernet frame

preamble:
v Start of frame is recognized by

• Preamble : Seven bytes with pattern 10101010
• Start of Frame Delimiter (SFD) : 10101011

v used to synchronize receiver, sender clock rates
Ø Inter Frame Gap is 12 Bytes (96 bits) of idle state

• 0.96 microsec for 100 Mbit/s Ethernet
• 0.096 microsec for Gigabit/s Ethernet

Preamble
7 Bytes

SFD
1 Byte

Dest
MAC
6 Bytes

Source
MAC

6 Bytes

Type/Le
ngth

2 Bytes

Payload
46-1500
Bytes

FCS/C
RC
4

Bytes

Inter
Frame
Gap

66

Ethernet frame structure (more)
v addresses: 6 byte source, destination MAC addresses

§ 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
v type: indicates higher layer protocol (mostly IP but

others possible, e.g., ARP, Novell IPX, AppleTalk)
v CRC: cyclic redundancy check at receiver

§ error detected: frame is dropped

dest.
address

source
address

data (payload) CRCpreamble Type

67

Ethernet: unreliable, connectionless

v connectionless: no handshaking between sending and
receiving NICs

v unreliable: receiving NIC does not send acks or nacks
to sending NIC
§ data in dropped frames recovered only if initial

sender uses higher layer rdt (e.g., TCP), otherwise
dropped data lost

v Ethernet’s MAC protocol: unslotted CSMA/CD with
binary backoff

68

Link layer, LANs: outline

6.1 introduction, services
6.2 error detection,

correction
6.3 multiple access

protocols
6.4 LANs

§ addressing, ARP
§ Ethernet
§ switches

6.7 a day in the life of a
web request

69

Ethernet switch
v link-layer device: takes an active role

§ store, forward Ethernet frames
§ examine incoming frame’s MAC address,

selectively forward frame to one-or-more
outgoing links when frame is to be forwarded on
segment

v transparent
§ hosts are unaware of presence of switches

v plug-and-play, self-learning
§ switches do not need to be configured

70

Switch: multiple simultaneous transmissions

v hosts have dedicated, direct
connection to switch

v switches buffer packets
v Ethernet protocol used on each

incoming link, but no collisions;
full duplex
§ each link is its own collision

domain
v switching: A-to-A’ and B-to-B’

can transmit simultaneously,
without collisions switch with six interfaces

(1,2,3,4,5,6)

A

A’

B

B’ C

C’

1 2

345

6

71

Switch forwarding table

Q: how does switch know A’
reachable via interface 4, B’
reachable via interface 5?

switch with six interfaces
(1,2,3,4,5,6)

A

A’

B

B’ C

C’

1 2

345

6v A: each switch has a switch
table, each entry:
§ (MAC address of host, interface to

reach host, time stamp)
§ looks like a routing table!

Q: how are entries created,
maintained in switch table?

§ something like a routing protocol?

72

A

A’

B

B’ C

C’

1 2

345

6

Switch: self-learning
v 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

A A’

Source: A
Dest: A’

MAC addr interface TTL
Switch table

(initially empty)
A 1 60

73

Switch: frame filtering/forwarding

when frame received at switch:

1. record incoming link, MAC address of sending host
2. index switch table using MAC destination address
3. if entry found for destination

then {
if destination on segment from which frame arrived

then drop frame
else forward frame on interface indicated by entry

}
else flood /* forward on all interfaces except arriving

interface */

74

A

A’

B

B’ C

C’

1 2

345

6

Self-learning, forwarding: example
A A’

Source: A
Dest: A’

MAC addr interface TTL
switch table

(initially empty)
A 1 60

A A’A A’A A’A A’A A’

v frame destination, A’,
locaton unknown: flood

A’ A

v destination A location
known:

A’ 4 60

selectively send
on just one link

75

Interconnecting switches

v switches can be connected together

Q: sending from A to G – how does S1 know to
forward frame destined to G via S4 and S3?
v A: self learning! (works exactly the same as in

single-switch case!)

A

B

S1

C D

E

F
S2

S4

S3

H
I

G

76

Switches vs. routers

both are store-and-forward:
§routers: network-layer
devices (examine network-
layer headers)
§switches: link-layer devices
(examine link-layer headers)

both have forwarding tables:
§routers: compute tables using
routing algorithms, IP
addresses
§switches: learn forwarding
table using flooding, learning,
MAC addresses

application
transport
network

link
physical

network
link

physical

link
physical

switch

datagram

application
transport
network

link
physical

frame

frame

frame
datagram

77

Security Issues

v In a switched LAN once the switch table entries are
established frames are not broadcast
§ Sniffing frames is harder than pure broadcast LANs
§ Note: attacker can still sniff broadcast frames and frames for

which there are no entries (as they are broadcast)

v Switch Poisoning: Attacker fills up switch table with
bogus entries by sending large # of frames with bogus
source MAC addresses

v Since switch table is full, genuine packets frequently
need to be broadcast as previous entries have been
wiped out

78

Quiz

v A switch can

A. Filter a frame

B. Forward a frame

C. Extend a LAN

D. All of the above

79

www.zeetings.com/salil

Answer: D

Quiz

v The _______ will typically change from hop to
hop, but the __________ will typically remain
the same

A. Source MAC address, destination MAC address

B. Source IP address, destination IP address

C. Source & destination IP addresses, source &
destination MAC addresses

D. Source & destination MAC addresses, source &
destination IP addresses

80www.zeetings.com/salil

Answer: D
See Slides 67-72

Answer: D

Link layer, LANs: outline

6.1 introduction, services
6.2 error detection,

correction
6.3 multiple access

protocols
6.4 LANs

§ addressing, ARP
§ Ethernet
§ switches

6.7 a day in the life of a
web request

81

Synthesis: a day in the life of a web request

v journey down protocol stack complete!
§ application, transport, network, link

v putting-it-all-together: synthesis!
§ goal: identify, review, understand protocols (at all

layers) involved in seemingly simple scenario:
requesting www page

§ scenario: student attaches laptop to campus network,
requests/receives www.google.com

82

A day in the life: scenario

Comcast network
68.80.0.0/13

Google’s network
64.233.160.0/19 64.233.169.105

web server

DNS server

school network
68.80.2.0/24

web page

browser

83

router
(runs DHCP)

A day in the life… connecting to the Internet

v connecting laptop needs to
get its own IP address, addr
of first-hop router, addr of
DNS server: use DHCP

DHCP
UDP

IP
Eth
Phy

DHCP

DHCP

DHCP

DHCP

DHCP

DHCP
UDP

IP
Eth
Phy

DHCP

DHCP

DHCP

DHCPDHCP

v DHCP Discover Message
encapsulated in UDP,
encapsulated in IP,
encapsulated in 802.3
Ethernet

v Ethernet frame broadcast
(dest: FFFFFFFFFFFF) on LAN,
received at router running
DHCP server

v Ethernet demuxed to IP
demuxed, UDP demuxed to
DHCP

84

router
(runs DHCP)

v DHCP server formulates
DHCP Offer message
containing client’s IP
address

DHCP
UDP

IP
Eth
Phy

DHCP

DHCP

DHCP

DHCP

DHCP
UDP

IP
Eth
Phy

DHCP

DHCP

DHCP

DHCP

DHCP

v encapsulation at DHCP
server, frame again
broadcasted on LAN

v DHCP client receives
DHCP Offer message

A day in the life… connecting to the Internet

85

router
(runs DHCP)

A day in the life… connecting to the Internet

v The client initiates DHCP
Request message

DHCP
UDP

IP
Eth
Phy

DHCP

DHCP

DHCP

DHCP

DHCP

DHCP
UDP

IP
Eth
Phy

DHCP

DHCP

DHCP

DHCPDHCP

v DHCP Request encapsulated
in UDP, encapsulated in IP,
encapsulated in 802.3
Ethernet

v Ethernet frame broadcast
(dest: FFFFFFFFFFFF) on LAN,
received at router running
DHCP server

v Ethernet demuxed to IP
demuxed, UDP demuxed to
DHCP

86

router
(runs DHCP)

v DHCP server formulates
DHCP ACK containing
client’s IP address, IP
address of first-hop router
for client, name & IP
address of DNS server

DHCP
UDP

IP
Eth
Phy

DHCP

DHCP

DHCP

DHCP

DHCP
UDP

IP
Eth
Phy

DHCP

DHCP

DHCP

DHCP

DHCP
v encapsulation at DHCP

server, frame broadcasted
through LAN,

Client now has IP address, knows name & addr of DNS
server, IP address of its first-hop router

v DHCP client receives
DHCP ACK reply

A day in the life… connecting to the Internet

87

router
(runs DHCP)

A day in the life… ARP (before DNS, before HTTP)

v before sending HTTP request, need
IP address of www.google.com:
DNS

DNS
UDP

IP
Eth
Phy

DNS

DNS

DNS

v DNS query created, encapsulated in
UDP, encapsulated in IP,
encapsulated in Eth. To send frame
to DNS server, need MAC address
of first hop router: ARP

v ARP query broadcast, received by
router, which replies with ARP
reply giving MAC address of
router interface

v client now knows MAC address
of first hop router, so can now
send frame containing DNS
query

ARP query

Eth
Phy

ARP

ARP

ARP reply

88

router
(runs DHCP)

DNS
UDP

IP
Eth
Phy

DNS

DNS

DNS

DNS

DNS

v IP datagram containing DNS
query forwarded via LAN
switch from client to first
hop router

v IP datagram forwarded from first
hop router in campus network
into comcast network, routed
(tables created by RIP, OSPF, IS-IS
and/or BGP routing protocols) to
DNS server

v demux’ed to DNS server
v DNS server replies to client

with IP address of
www.google.com

Comcast network
68.80.0.0/13

DNS server
DNS
UDP

IP
Eth
Phy

DNS

DNS

DNS

DNS

A day in the life… using DNS

89

router
(runs DHCP)

A day in the life…TCP connection carrying HTTP

HTTP
TCP
IP
Eth
Phy

HTTP

v to send HTTP request,
client first opens TCP socket
to web server

v TCP SYN segment (step 1 in 3-
way handshake) inter-domain
routed to web server

v TCP connection established!64.233.169.105
web server

SYN

SYN

SYN

SYN

TCP
IP
Eth
Phy

SYN

SYN

SYN

SYNACK

SYNACK

SYNACK

SYNACK

SYNACK

SYNACK

SYNACK

v web server responds with TCP
SYNACK (step 2 in 3-way
handshake)

90

router
(runs DHCP)

A day in the life… HTTP request/reply
HTTP
TCP
IP
Eth
Phy

HTTP

v HTTP request sent into TCP
socket

v IP datagram containing HTTP
request routed to
www.google.com

v IP datagram containing HTTP
reply routed back to client

64.233.169.105
web server

HTTP
TCP
IP
Eth
Phy

v web server responds with
HTTP reply (containing web
page)

HTTP

HTTP

HTTPHTTP

HTTP

HTTP

HTTP

HTTP

HTTP

HTTP

HTTP

HTTP

HTTP

v web page finally (!!!) displayed

91

Link Layer: Summary
v principles behind data link layer services:

§ error detection, correction
§ sharing a broadcast channel: multiple access
§ link layer addressing

v instantiation and implementation of various link
layer technologies
§ Ethernet
§ switched LANS

92

Link Layer: let’s take a breath

v journey down protocol stack complete (except
PHY)

v solid understanding of networking principles,
practice

v ….. could stop here …. but lots of interesting
topics!
§ Wireless
§ Security

93