Transcript Slide 1

Lecture 2
TCP/IP Link Layer
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Outline
• understand principles
behind data link layer
services:
– error detection, correction
– sharing a broadcast
channel: multiple access
• instantiation and
implementation of various
link layer technologies:
– Ethernet
– SLIP
– PPP
• link layer addressing
– ARP
– RARP
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Link Layer: Introduction
Some terminology:
“link”
• hosts and routers are nodes
• communication channels that
connect adjacent nodes along
communication path are links
– wired links
– wireless links
– LANs
• layer-2 packet is a frame,
encapsulates datagram
• data-link layer has responsibility of
transferring datagram from one
node to adjacent node over a link
• Involves device driver in OS and
network interface card
• There are various standards
(protocols) to realize link layer
services, e.g. Ethernet, token rings,
etc.
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
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
Khaled Mahbub, IICT, BUET, 2008
transportation analogy
• trip from your home to Cox’s Bazar
– car: home to train station
– train: Dhaka to Chittagong
– plane: Chittagong to Cox’s Bazar
• tourist = datagram
• transport segment = communication
link, e.g. Dhaka to Chittagong
• transportation mode = link layer
protocol, e.g. train, plane
• travel agent = routing algorithm
ICT 6621 : Advanced Networking
Link Layer Services
• Framing, link access:
– encapsulate datagram into frame, adding header, trailer
– implement channel access if shared medium,
– ‘physical addresses’ used in frame headers to identify source,
destination (different from IP address!)
• Flow Control:
– pacing between sender and receivers
• 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
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Outline
• understand principles
behind data link layer
services:
– error detection, correction
– sharing a broadcast
channel: multiple access
• instantiation and
implementation of various
link layer technologies:
– Ethernet
– SLIP
– PPP
• link layer addressing
– ARP
– RARP
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
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
– larger EDC field yields better detection and correction
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Error Detection: Parity Checking
Single Bit Parity:
Detect single bit errors
Two Dimensional Bit Parity:
Detect and correct single bit errors
0
Khaled Mahbub, IICT, BUET, 2008
0
ICT 6621 : Advanced Networking
Error Detection: 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)
– 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, HDLC)
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Outline
• understand principles
behind data link layer
services:
– error detection, correction
– sharing a broadcast
channel: multiple access
• instantiation and
implementation of various
link layer technologies:
– Ethernet
– SLIP
– PPP
• link layer addressing
– ARP
– RARP
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
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 HFC
– 802.11 wireless LAN
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Multiple Access protocols
• single shared communication channel
• two or more simultaneous transmissions by
nodes: interference
– only one node can send successfully at a time
• multiple access protocol:
– distributed algorithm that determines how stations
share channel, i.e., determine when station can
transmit
– what to look for in multiple access protocols:
•
•
•
•
synchronous or asynchronous
information needed about other stations
robustness (e.g., to channel errors)
performance
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Ideal Multiple Access Protocol
Broadcast channel of rate R bps
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
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
MAC Protocols: a taxonomy
Three broad classes:
• Channel Partitioning
– divide channel into smaller “pieces” (time slots,
frequency, code)
– allocate piece to node for exclusive use
– example TDMA, FDMA
• Random Access
– channel not divided, allow collisions
– “recover” from collisions
– example CSMA, CSMA/CD
• “Taking turns”
– Nodes take turns, but nodes with more to send can
take longer turns
– example polling, token ring
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Outline
• understand principles
behind data link layer
services:
– error detection, correction
– sharing a broadcast
channel: multiple access
• instantiation and
implementation of various
link layer technologies:
– Ethernet
– SLIP
– PPP
• link layer addressing
– ARP
– RARP
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Ethernet
• Dominant widely used wired LAN technology
• First published in 1982 by Digital Equipment Corp., Intel
Corp., and Xerox Corp.
• Simpler and cheaper.
• 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
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Ethernet Frame Structure
• Sending adapter encapsulates IP datagram (or other
network layer protocol packet) in Ethernet frame
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Ethernet Frame Structure
• Preamble:
– Most often preamble is used before a frame to synchronize
receiver, sender clock rates
– 7 bytes with pattern 10101010 followed by one byte with pattern
10101011
• 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 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). Also type field is
used to distinguish ARP/RARP request (reply) frames from
datagram frames.
• CRC:
– checked at receiver, if error is detected, the frame is simply
dropped
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Outline
• understand principles
behind data link layer
services:
– error detection, correction
– sharing a broadcast
channel: multiple access
• instantiation and
implementation of various
link layer technologies:
– Ethernet
– SLIP
– PPP
• link layer addressing
– ARP
– RARP
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
SLIP
• Serial Line IP (SLIP) is a simple form of encapsulation for IP
datagram on serial lines, and it has become popular through RS232 serial port and high-speed modems
• The rules specify the framing used by SLIP:
• Special character called END (0xc0) is used at the beginning and end of
the datagram.
• If the END character appears inside the datagram, the 2 byte sequence
0xdb 0xdc is transmitted. 0xdb is called the SLIP ESC character.
• If SLIP ESC character appears inside datagram, the 2 byte sequence
0xdb 0xdd is transmitted instead.
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
SLIP
• Deficiencies of SLIP
– Each end must know the other’s IP address
– There is no type field, it can’t be used for some other
protocol at same time
– There is no checksum added by SLIP. This makes it
essential that the upper layers provide some form of
CRC
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Outline
• understand principles
behind data link layer
services:
– error detection, correction
– sharing a broadcast
channel: multiple access
• instantiation and
implementation of various
link layer technologies:
– Ethernet
– SLIP
– PPP
• link layer addressing
– ARP
– RARP
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
PPP
• Point to point protocol (PPP) is a way to encapsulate IP datagram on a
serial link and it addresses all the deficiencies of SLIP. PPP supports
either an asynchronous link with 8 bits of data and no parity or bitoriented synchronous links.
• A link control protocol (LCP) to establish, configure, and test the datalink connection
• A family of network control protocols (NCPs) specific to different
network layer protocols
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
PPP
• Flag: delimiter (framing), 0x7E (i.e. 01111110)
• Address: does nothing, constant value 0xFF, reserved for future use.
• Control: does nothing; constant value 0x03. In the future possible
multiple control fields
• Protocol: upper layer protocol to which frame delivered, e.g.
– PPP-LCP value C021,
– IP value 0021
– IPCP value 8021
• info: upper layer data being carried
• check: cyclic redundancy check for error detection
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
PPP
• How to escape flag byte?
– On a synchronous link: done by the hardware using a
technique called bit stuffing
– On asynchronous link: use 0x7d as an escape
character, the next character of 0x7d had its sixth bit
complemented as follows:
• 0x7e is transmitted => 0x7d 0x5e
• 0x7d is transmitted => 0x7d 0x5d
• ASCII control character (less than 0x20), for example, the
byte 0x01 is transmitted => 0x7d 0x21
• PPP using the link control protocol
– omit the constant flag and address fields and to
reduce the size of the protocol field from 2 bytes to 1
byte
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Loopback Interface
• A loopback interface allow a client and server on the same host to
communicate with each other using TCP/IP
• most system assign the IP address of 127.0.0.1, named localhost
• in brief, it is just doing a test job
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Outline
• understand principles
behind data link layer
services:
– error detection, correction
– sharing a broadcast
channel: multiple access
• instantiation and
implementation of various
link layer technologies:
– Ethernet
– SLIP
– PPP
• link layer addressing
– ARP
– RARP
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Link Layer Addressing (LAN Addressing)
• 32-bit IP address:
– network-layer address
– used to get datagram to destination IP subnet
• LAN 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
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
LAN Addresses
Each adapter on LAN has unique LAN address
1A-2F-BB-76-09-AD
71-65-F7-2B-08-53
LAN
(wired or
wireless)
Broadcast address =
FF-FF-FF-FF-FF-FF
= adapter
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
LAN Address
• MAC address allocation administered by IEEE
• manufacturer buys portion of MAC address space (to
assure uniqueness)
• Analogy:
(a) MAC address: like Social Security Number
(b) IP address: like postal address
•
MAC flat address ➜ portability
– can move LAN card from one LAN to another
• IP hierarchical address NOT portable
– depends on IP subnet to which node is attached
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
ARP: Address Resolution Protocol
Question: how to determine
MAC address of B
knowing B’s IP address?
237.196.7.23
A
71-65-F7-2B-08-53
237.196.7.88
• Each IP node (Host, Router)
on LAN has ARP table (ARP
Cache)
• ARP Table: IP/MAC address
mappings for some LAN
237.196.7.78
nodes
1A-2F-BB-76-09-AD
• <IP address; MAC address;
TTL>
237.196.7.14
– TTL (Time To Live): time
B
after which address
LAN
mapping will be forgotten
58-23-D7-FA-20-B0
(typically 20 min) (also
known as ARP Cache
0C-C4-11-6F-E3-98
Timeout)
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
ARP protocol: Same LAN (network)
• A wants to send datagram to
B, and B’s MAC address not
in A’s ARP table.
• A broadcasts ARP query
packet, containing B's IP
address
– Dest MAC address = FFFF-FF-FF-FF-FF
– 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)
Khaled Mahbub, IICT, BUET, 2008
• 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 net
administrator
ICT 6621 : Advanced Networking
Routing to another LAN
• walkthrough: send datagram from A to B via R, assume A knows
B’s IP address
A
R
B
• Two ARP tables in router R, one for each IP network (LAN)
• In routing table at source Host, find router 111.111.111.110
• In ARP table at source, find MAC address E6-E9-00-17-BB-4B, etc
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Routing to another LAN
• 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 dest, frame
contains A-to-B IP datagram
• A’s adapter sends frame
• R’s adapter receives frame
• R removes IP datagram from Ethernet frame, sees its destined to B
• R uses ARP to get B’s MAC address
• R creates frame containing A-to-B IP datagram sends to B
A
R
Khaled Mahbub, IICT, BUET, 2008
B
ICT 6621 : Advanced Networking
ARP Packet Format
• The first two fields in the Ethernet header are the source and
destination Ethernet addresses.
• frame type specifies the type of data that follows. For an ARP request or
an ARP reply, this field is 0x0806, for IP datagram it is 0x0800.
• hard type field specifies the type of hardware address (i.e. hardware
used in the LAN). E.g. for Ethernet it is 1, for Frame relay it is 15, for
fiber channel it is 18
• Prot type specifies the type of network protocol address being mapped.
Its value is 0×0800 for IP addresses
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
ARP Packet Format
• hard size and prot size, specify the sizes in bytes of the hardware
addresses and the protocol addresses. For an ARP request or reply for
an IP address on an Ethernet they are 6 and 4, respectively.
• The op field specifies whether the operation is an ARP request (a value
of 1), ARP reply (2), RARP request (3), or RARP reply (4).
• The next four fields that follow are the sender's hardware, the sender's
protocol address, the target hardware address, and the target protocol
address
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
More on ARP
• Proxy ARP:
Proxy ARP lets a router answer ARP requests on one of its networks
for a host on another of its networks. The router that is configured for
Proxy ARP can respond to the ARP and map the router's MAC
address with the destination IP address and fool the sending station
that it has found its destination. The router acts as a proxy as the
name suggests, and forwards the packets to the correct destination
since it has the relevant information.
• Gratuitous ARP is an ARP request sent by a host for its own IP
address. This is usually done when the interface is configured at
bootstrap time, to initialize its IP stack. It helps to check for a
duplicate IP address.
• Arp command – try out yourself in windows/unix.
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
RARP
• Reverse Address Resolution Protocol (RARP) is a network layer
protocol used to obtain an IP address for a given hardware address.
• When a system with a local disk is bootstrapped it normally obtains
its IP address from a configuration file that's read from a disk file.
But a system without a disk, such as an X terminal or a diskless
workstation, RARP is used to obtain its IP address.
• The format of an RARP packet is almost identical to an ARP packet
(Figure 4.3). The only differences are that the frame type is 0×8035
for an RARP request or reply, and the op field has a value of 3 for an
RARP request and 4 for an RARP reply.
• As with ARP, the RARP request is broadcast and the RARP reply is
normally unicast.
• It has been rendered obsolete by BOOTP, DHCP (will be discussed
later)
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking
Reading Material
• Chapter 2, 4 – text1 (Stevens)
• Chapter 5 – text3 (Kurose)
Khaled Mahbub, IICT, BUET, 2008
ICT 6621 : Advanced Networking