Link Layer: Computer Networking: A Top Down Approach
Link Layer: Computer Networking: A Top Down Approach
Link Layer: Computer Networking: A Top Down Approach
Computer
Networking: A Top
Down Approach
6th edition
Jim Kurose, Keith Ross
Addison-Wesley
March 2012
Link layer
our goals:
understand principles behind link layer
services:
error detection, correction
sharing a broadcast channel: multiple access
link layer addressing
local area networks: Ethernet
Link layer, LANs: outline
introduction, services a day in the life of a
error detection, web request
correction
LANs
addressing, ARP
Ethernet
switches
Link layer: introduction
terminology:
hosts and routers: nodes
communication channels that global ISP
combination of hardware,
software, firmware network adapter
card
Adaptors communicating
datagram datagram
controller controller
frame
otherwise
Redundancy
11
Vertical Redundancy Check
The most common and least expensive
mechanism for error detection is the vertical
redundancy check (VRC), often called a parity
check.
In this technique, a redundant bit called a parity
bit, is appended to every data unit so that the
total number of 1’s in the unit (including the
parity bit) becomes even.
12
Vertical Redundancy Check
Suppose we want to transmit the binary data unit
1100001. Adding together the number of 1’s gives us
three, an odd number. Before transmitting, we pass the
data unit through a parity generator.
The parity generator counts the 1’s and appends the
parity bit to the end. The total number of 1’s is now four,
an even number.
The system now transmits the entire expanded unit
across the network link. When it reaches its destination,
the receiver puts all eight bits through an even-parity
checking function.
13
Vertical Redundancy Check
If the receiver sees 11100001, it counts four 1’s,
an even number and the data unit passes. But if
the data unit has been damaged in transit, what if,
instead of 11100001, the receiver sees 11100101?
Then the parity checker counts the 1’s, it gets 5’s,
an odd number. The receiver knows that an error
has been introduced into the data somewhere
and therefore rejects the whole unit.
14
Vertical Redundancy Check
Example: Imagine the sender wants to send the
word “ world ”. In ASCII , the five characters are
coded as;
W = 1110111
O = 1101111
R = 1110010
L = 1101100
D = 1100100
15
Vertical Redundancy Check
Each of the first four characters has an even
number of 1’s, so the parity bit is a 0.
The last character (‘ d ’) has three 1’s (an odd
number), so that the parity bit is a 1 to make the
total number of 1’s even.
The following shows the actual bits sent
w = 11101110, o = 11011110, r = 11100100, l =
11011000, d = 11001001
16
VRC
17
Vertical Redundancy Check
Performance:
VRC can detect all single-bit errors.
It can also detect burst errors as long as the total
number of bits changed is odd (1, 3, 5, etc.).
Suppose, however, that two bits of the data unit are
changed, in this case the number of 1’s in the data unit
is still even. The VRC checker will add them and
return an even number although the data unit contains
two errors.
VRC cannot detect errors where the total number of
bits changed, is even.
18
Cyclic Redundancy Check
The most powerful technique for redundancy checking is
CRC.
Unlike, VRC, which is based on addition, CRC is based on
binary division.
In CRC, instead of adding bits together to achieve a
desired parity, a sequence of redundant bits, called the
CRC or the CRC remainder, is appended to the end of a
data unit so that the resulting data unit becomes exactly
divisible by a second predetermined binary number.
At its destination, the incoming data unit is divided by the
same number. If at this step, there is no remainder, means
no errors and if there is a remainder, means errors.
19
Cyclic Redundancy Check
The redundancy bits used by CRC are derived by
dividing the data unit by a predetermined divisor;
the remainder is the CRC. To be valid, a CRC
must have two qualities:
It must have exactly one less bit than the divisor, and
appending it to the end of the data string must make
the resulting bit sequence exactly divisible by the
divisor.
20
Cyclic Redundancy Check
CRC provides an outline of the three basic steps:-
First, a string of n 0’s is appended to the data unit. The
number n is one less than the number of bits in the
predetermined divisor, which is n + 1 bits.
Second, the newly elongated data unit is divided by the
divisor using a process called binary division. The
remainder resulting from this division is the CRC.
Third, the CRC of n bits derived in step 2 replaces the
appended 0’s at the end of the data unit.
21
Cyclic Redundancy Check
The data unit arrives at the receiver data first,
followed by the CRC. The receiver treats the
whole string as a unit and divides it by the same
divisor that was used to find the CRC remainder.
If the string arrives without error, the CRC
checker yields a remainder of zero and the data
unit passes. If the string has been changed in
transit, the division yields a non-zero remainder
and the data unit does not pass.
22
Cyclic Redundancy Check
CRC Generator: A CRC generator uses
modulo-2 division. (as shown in figure)
CRC Checker:A CRC checker functions exactly
like the generator. After receiving the data
appended with the CRC, it does the same
modulo-2 division. If the remainder is all 0’s, the
CRC is dropped and the data accepted;
otherwise, the received stream of bits is
discarded and data are resent.
23
CRC
24
Binary Division
25
Link layer, LANs: outline
introduction, services a day in the life of a
error detection, web request
correction
LANs
addressing, ARP
Ethernet
switches
CSMA (carrier sense multiple access)
32-bit IP address:
network-layer address for interface
used for layer 3 (network layer) forwarding
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 burned in NIC ROM
e.g.: 1A-2F-BB-76-09-AD
1A-2F-BB-76-09-AD
LAN
(wired or adapter
wireless)
71-65-F7-2B-08-53
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
LAN addresses (more)
MAC address allocation administered by IEEE
manufacturer buys portion of MAC address space
(to assure uniqueness)
analogy:
MAC address: like Identity Card Number
IP address: like postal address
MAC flat address ➜ portability
can move LAN card from one LAN to another
IP hierarchical address not portable
address depends on IP subnet to which node is
attached
ARP: address resolution protocol
Question: how to determine
interface’s MAC address,
knowing its IP address? ARP table: each IP node (host,
router) on LAN has table
137.196.7.78
IP/MAC address
mappings for some LAN
1A-2F-BB-76-09-AD
nodes:
137.196.7.23
137.196.7.14 < IP address; MAC address; TTL>
TTL (Time To Live):
LAN time after which address
71-65-F7-2B-08-53 mapping will be
forgotten (typically 20
58-23-D7-FA-20-B0
min)
0C-C4-11-6F-E3-98
137.196.7.88
ARP protocol
A wants to send datagram
to B
B’s MAC address not in A caches (saves) IP-to-
A’s ARP table. MAC address pair in its
A broadcasts ARP query ARP table until
packet, containing B's IP information becomes old
address (times out)
dest MAC address = FF-FF- soft state: information that
FF-FF-FF-FF times out (goes away)
all nodes on LAN receive unless refreshed
ARP query ARP is “plug-and-play”:
B receives ARP packet, nodes create their ARP
replies to A with its (B's) tables without intervention
from net administrator
MAC address
frame sent to A’s MAC
address (unicast)
Link layer, LANs: outline
introduction, services a day in the life of a
error detection, web request
correction
LANs
addressing, ARP
Ethernet
switches
Ethernet
“dominant” wired LAN technology:
cheap $20 for NIC
first widely used LAN technology
simpler, cheaper than token LANs and ATM
kept up with speed race: 10 Mbps – 10 Gbps
switch
star
bus: coaxial cable
Ethernet frame structure
sending adapter encapsulates IP datagram (or other
network layer protocol packet) in Ethernet frame
type
dest. source data
preamble address address (payload) CRC
preamble:
7 bytes with pattern 10101010 followed by one
byte with pattern 10101011
used to synchronize receiver, sender clock rates
Ethernet frame structure (more)
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
type: indicates higher layer protocol (mostly IP but
others possible, e.g., Novell IPX, AppleTalk)
CRC: cyclic redundancy check at receiver
error detected: frame is dropped
type
dest. source data
preamble address address (payload) CRC
Ethernet: unreliable, connectionless
connectionless: no handshaking between sending and
receiving NICs
unreliable: receiving NIC doesnt 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
802.3 Ethernet standards: link & physical layers
MAC protocol
application and frame format
transport
network 100BASE-TX 100BASE-T2 100BASE-FX
link 100BASE-T4 100BASE-SX 100BASE-BX
physical
A A A’
switch learns which hosts
can be reached through B
which interfaces C’
A A A’
frame destination, A’,
locaton unknown: flood C’ B
destination A location 6 1 2
A’
S1
S3
A S2
F
D I
B C
G H
E
S4
S1
S3
A S2
F
D I
B C
G H
E
school network
68.80.2.0/24
web page
DHCP Eth
Phy DNS server: use DHCP
DHCP