TCP/IP Internet Layer Overview
TCP/IP Internet Layer Overview
[Link]@[Link] 1
TCP/IP Internet provides 3 layers of service
Application services
Transport Services
Connectionless packet delivery service
2
Addressing and
Delivering
[Link]@[Link] 3
Unfortunately, on a routed network, it is not possible
to deliver data by physical address.
[Link]@[Link] 6
• If the destination address is on a different segment
from the source computer, the following process
begins:
• The datagram is directed to a gateway. A gateway
is a device on the local network segment that is
capable of forwarding a datagram to other
network segments.
The gateway address is resolved to a physical
address using ARP, and the data is sent to the
gateway’s network adapter.
Addressing and • The datagram is routed through the gateway to a
Delivering higher-level network segment where the process is
repeated. If the destination address is on the new
segment, the data is delivered to its destination. If
not, the datagram is sent to another gateway.
• The datagram passes through the chain of
gateways to the destination segment, where the
destination IP address is mapped to a physical
address using ARP and the data is directed to the
destination network adapter.
[Link]@[Link] 8
• To deliver data on a complex routed network,
the Internet layer protocols must therefore be
able to:
• Identify any computer on the network
• Provide a means for determining when a
message must be sent through the gateway
• Provide a hardware-independent means of
Addressing and identifying the destination network
segment so that the datagram will pass
Delivering efficiently through the routers to the
correct segment
• Provide a means for converting the logical
IP address of the destination computer to a
physical address so that the data can be
delivered to the network adapter of the
destination computer
The Internet Protocol (IP) provides a
hierarchical, hardware-independent
addressing system and offers the
services necessary for delivering
Internet data on a complex, routed network.
Protocol
[Link]@[Link] 10
The Host
Internet
have only one network adapter.
Protocol A computer that is acting as a router or a proxy server, for instance, must have
more than one network adapter and, therefore, has more than one IP address.
The term host is often used for a network device associated with an IP address.
Under some operating systems, it is also possible to assign more than one IP
address to a single network adapter.
[Link]@[Link] 11
Internet Protocol
[Link]@[Link] 12
Internet Protocol
• The network must provide a means for determining which part of
the IP address is the network ID and which part is the host ID.
• Big networks must reserve a large number of host bits for their
large number of hosts.
• Small networks do not need many bits to give each host a unique
ID; however, the vast number of small networks means that more
bits of the IP address are necessary for the network ID.
[Link]@[Link] 13
• Original solution to this problem was to divide the IP
address space into a series of address classes.
• Class A networks used the first 8 bits of the address for
the network ID;
• Class B used the first 16 bits;
• Class C networks used the first 24 bits. This system was
extended through a feature called subnetting to provide
greater control at the local level for structuring the
network.
Internet Protocol
[Link]@[Link] 14
A more recent technique known as
classless interdomain routing
(CIDR) essentially renders the
address class system unnecessary.
Internet
Protocol CIDR, which is now quite common
on the Internet, offers a simple,
flexible, and unambiguous
notation for allocating blocks of IP
addresses.
[Link]@[Link] 15
• Every IP datagram begins with an IP header.
• The TCP/IP software on the source computer
constructs the IP header.
• The TCP/IP software at the destination uses the
information enclosed in the IP header to
IP Header process the datagram.
Fields • The IP header contains a great deal of
information, including the IP addresses of the
source and destination computers, the length of
the datagram, the IP version number, and
special instructions to routers.
[Link]@[Link] 16
• Basic transfer unit
Datagram header Datagram data area
18
IP Header Fields
• Version: This 4-bit field indicates which version of IP is being used.
The current version of IP is 4. The binary pattern for 4 is 0100.
• IHL (Internet Header Length): This 4-bit field gives the length of
the IP header in 32-bit words. The minimum header length is five
32-bit words. The binary pattern for 5 is 0101.
• Type of Service: The source IP can designate special routing
information. Some routers ignore the Type of Service field,
although this field recently has received more attention with the
emergence of quality of service (QoS) technologies. The primary
purpose of this 8-bit field is to provide a means of prioritizing
datagrams that are waiting to pass through a router. Most
implementations of IP today simply put all 0s in this field.
• Total Length: This 16-bit field identifies the length, in octets, of
the IP data- gram. This length includes the IP header and the data
payload.
[Link]@[Link] 19
Identification: This 16-bit field is an incrementing sequence
number assigned to messages sent by the source IP.
When a message is sent to the IP layer and it is too large to fit
in one datagram, IP fragments the message into multiple
datagrams, giving all datagrams the same identification
number.
This number is used on the receiving end to reassemble the
original message.
IP Header
Fields Flags: The Flags field indicates fragmentation possibilities. The
first bit is unused and should always have a value of 0. The
next bit is called the DF (Don’t Fragment) flag. The DF flag
signifies whether fragmentation is allowed (value = 0) or not
(value = 1).
The next bit is the MF (More Fragments) flag, which tells the
receiver that more fragments are on the way. When MF is set
to 0, no more fragments need to be sent or the data- gram
never was fragmented.
[Link]@[Link] 20
Fragment Offset: This 13-bit field is a numeric value
assigned to each successive fragment. IP at the destination
uses the fragment offset to reassemble the fragments into
the proper order. The offset value found here expresses
the offset as a number of 8-byte units.
[Link]@[Link] 21
Protocol Name Protocol Identifier
UDP 17
• Protocol: The 8-bit Protocol
field indicates the protocol
that will receive the data
payload. A datagram with
the protocol identifier 6
(binary 00000110) is passed
up the stack to the TCP
module, for example. The
following are some common
protocol values:
[Link]@[Link] 22
Source & destination IP
address (32 bits each):
contain IP address of sender
and intended recipient
IP Datagram
format (cont.)
Options (variable length):
Mainly used to record a
route, or timestamps, or
specify routing
23
Header Checksum: This field holds a 16-bit calculated value to verify
the validity of the header only. This field is recomputed in every
router as the TTL field decrements.
Source IP Address: This 32-bit field holds the address of the source of
the datagram.
IP Header
Fields Destination IP Address: This 32-bit field holds the destination address
of the datagram and is used by the destination IP to verify correct
delivery.
[Link]@[Link] 24
Padding: The IP Options field may vary in
length. The Padding field provides additional
0 bits so that the total header length is an
exact multiple of 32 bits. (The header must
end after a 32-bit word because the IHL field
measures the header length in 32-bit words.)
IP Header
Fields IP Data Payload: This field typically contains
data destined for delivery to TCP or UDP (in
the Transport layer), ICMP, or IGMP. The
amount of data is variable but could include
thousands of bytes.
[Link]@[Link] 25
Dotted Decimal Notation
• IP addresses are written in a so-called dotted decimal notation
• Each byte is identified by a decimal number in the range [0..255]:
•
10000000 10001111 10001001 10010000
1st Byte 2nd Byte 3rd Byte 4th Byte
= 128 = 143 = 137 = 144
[Link]
An IP address is a 32-bit binary address. This 32-bit address
is subdivided into four 8- bit segments called octets.
[Link]@[Link] 27
Network prefix and Host number
• The network prefix identifies a network and the host number
identifies a specific host (actually, interface on the network).
network prefix host number
[Link]@[Link] 29
More bits lead to more bit combinations. As you
might guess, the Class A format provides a small
number of possible network IDs and a huge
number of possible host IDs for each network.
[Link]@[Link] 30
IP Addressing
• The designers of TCP/IP wrote the address rules such that the class of an address
is obvious from the address itself. The first few bits of the binary address specify
whether the address should be interpreted as a Class A, Class B, or Class C
address.
• The rules for interpreting addresses are as follows:
• If the 32-bit binary address starts with a 0 bit, the address is a Class A address.
• If the 32-bit binary address starts with the bits 10, the address is a Class B
address.
• If the 32-bit binary address starts with the bits 110, the address is a Class C
address.
[Link]@[Link] 31
The old way: Internet Address Classes
bit # 0 1 7 8 31
Class A 0
Network Prefix Host Number
8 bits 24 bits
bit # 0 1 2 15 16 31
bit # 0 1 2 3 23 24 31
bit # 0 1 2 3 4 5 31
[Link]@[Link] 34
Classes D and E
IP Addressing Class D addresses are used for multicasting. A multicast is a single message
sent to a subset of the network, as opposed to a broadcast, which is
processed by all nodes on the local net. The four leftmost bits of a Class D
network address always start with the binary pattern 1110, which
corresponds to decimal numbers 224 through 239.
[Link]@[Link] 35
A few IP addresses have special meanings and are not assigned to
specific hosts. An all-0 host ID refers to the network itself.
Special IP
For instance, the IP address [Link] refers to the Class B network
with the network ID 129.152.
[Link]@[Link] 36
Addresses beginning with the decimal number 127 are loopback addresses.
Special IP
The loopback address [Link] is commonly used.
Addresses Because the private address ranges don’t have to be synchronized with the
rest of the world, the complete address range is available for any network.
A network administrator using these private addresses has more room for
subnetting, and many more assignable addresses.
Addresses
Problem 2. Two-layer
hierarchy is not
Fix #1:
appropriate for large Subnetting
networks with Class A and
Class B addresses.
Problem 3. The Internet is going to
Problems with outgrow the 32-bit addresses
Classful IP Addresses
• Fix #3: IP Version 6
Problem 3. The Internet is going to
Problems with outgrow the 32-bit addresses
Classful IP Addresses
• Fix #3: IP Version 6
• CIDR notation of a network address:
[Link]/18
• "18" says that the first 18 bits are
the network part of the address
(and 14 bits are available for
specific host addresses)
CIDR Example • The network part is called the prefix
• Assume that a site requires a network
address with 1000 addresses
• With CIDR, the network is assigned a
continuous block of 1024 addresses with a
22-bit long
prefix
CIDR Block Prefix # of Host Addresses
/27 32 hosts
/26 64 hosts
/20
2,048 hosts
4,096 hosts
/18
8,192 hosts
16,384 hosts
Net 1 Net 3
MTU=1500 Net 2 MTU=1500
MTU=620
48
Identification: copied into fragment, allows destination to know
which fragments belong to which datagram
49
composition
Fragment
series
Offset=0 Offset=1480 Offset=2960 Offset=3440
More frags More frags More frags Last frag
NB. If data segment contains its own header that is not replicated
50
Address Resolution Protocol
[Link]@[Link] 52
[Link]@[Link] 53
The ARP request frame contains the unresolved IP
address.
[Link]@[Link] 54
RARP stands for Reverse ARP. RARP is the opposite of ARP. ARP is used
when the IP address is known but the physical address is not known.
RARP is used when the physical address is known but the IP address is
not known.
RARP is often used in conjunction with the BOOTP protocol to boot
diskless workstations.
Reverse ARP Many network adapters contain an empty socket for insertion of an
integrated circuit known as a boot PROM.
[Link]@[Link] 55
Data sent to a remote computer often travels
through one or more routers; these routers can
encounter a number of problems in sending the
message to its ultimate destination.
Internet
Control Routers use Internet Control Message Protocol
(ICMP) messages to notify the source IP of these
Message problems.
Protocol
ICMP is also used for other diagnosis and
troubleshooting functions.
[Link]@[Link] 56
Internet Control Message Protocol
• Echo Request and Echo Reply: ICMP is often used during testing.
• A technician who uses the ping command to check connectivity with another host is
using ICMP.
• The ping command sends a datagram to an IP address and requests the destination
computer to return the data sent in a response datagram.
• The commands actually used by ping are the ICMP Echo Request and Echo Reply.
• Source Quench: If a fast computer is sending large amounts of data to a remote
computer, the volume can overwhelm the router.
• The router might use ICMP to send a Source Quench message to the source IP to ask
it to slow down the rate at which it is shipping data.
• If necessary, additional source quenches can be sent to the source IP.
[Link]@[Link] 57
Internet Control Message Protocol
• Destination Unreachable: If a router receives a datagram that cannot be
delivered, ICMP returns a Destination Unreachable message to the source IP.
• One reason that a router cannot deliver a message is a network that is down
because of equipment failure or maintenance.
• Time Exceeded: ICMP sends this message to the source IP if a datagram is
discarded because TTL reaches 0.
• This indicates that the destination is too many router hops away to reach with
the current TTL value, or it indicates router table problems that cause the
datagram to loop through the same routers continuously
[Link]@[Link] 58
• A routing loop occurs when a datagram circulates
endlessly and never reaches its destination.
• Suppose three routers are located in Los Angeles,
San Francisco, and Denver. The Los Angeles router
sends datagrams to San Francisco, which sends them
Internet to Denver, which sends them back to Los Angeles
again. The data- gram becomes trapped and will
Control circulate continuously through these three routers
until the TTL reaches 0. A routing loop should not
Message occur, but occasionally it does. Routing loops
sometimes occur when a network administrator
[Link]@[Link] 59
• A number of other protocols also inhabit the
Internet layer. Some of these other protocols, such
as Border Gateway Protocol (BGP) and Routing
Information Protocol (RIP), facilitate the routing
Other Internet process.
• The IPsec protocols, which are optional in IPv4 but
Layer are an integral part of IPv6, operate at the Internet
layer to provide secure encrypted communication.
Protocols • Other Internet layer protocols assist with tasks such
as multicasting. As mentioned earlier, the Internet
protocol layer is known in OSI shorthand as Layer 3.
• Any protocol referred to as a Layer 3 protocol is
operating at the Internet layer.
[Link]@[Link] 60
Q. What common address notation is used to simplify a 32-bit
binary address?
A. Dotted-decimal notation.
[Link]@[Link] 61
• What is the purpose of the TTL field in the IP
header?
• How big are the network and host ID fields
for a Class A address?
Quiz • What is an octet?
• What is the IP address an address of?
• What is the difference between ARP and
RARP?
[Link]@[Link] 62
Exercises
[Link]@[Link] 63
• Address Class: A classification system for IP
addresses. The network class determines how the
address is subdivided into a network ID and host
ID.
• Address Resolution Protocol (ARP): A key Internet
layer protocol used to obtain the physical address
associated with an IP address. ARP maintains a
cache of recently resolved physical address-to-IP
Key Terms address pairs.
• BOOTP: A protocol used to boot a computer or
other network device from a remote location.
• Dotted Decimal: Base 10 representation of a
binary IP address using 4 numerals representing
the 4 octets of the original address, separated by
periods ([Link]).
• Host ID: A portion of the IP address that refers to a
node on the network. Each node within a network
should have an IP address that contains a unique
host ID.
[Link]@[Link] 64
• Internet Control Message Protocol (ICMP): A key
Internet layer protocol used by routers to send messages
that inform the source IP of routing problems. ICMP is
also used by the ping command to determine the status
of other hosts on the network.
• Internet Protocol (IP): A key Internet layer protocol used
for addressing, delivering, and routing datagrams.
• Multicast: A technique that allows datagrams to be
delivered to a group of hosts simultaneously.
Key Terms • Network ID: A portion of the IP address that identifies
the network.
• Octet: An eight-digit binary number.
• Reverse Address Resolution Protocol (RARP): A TCP/IP
protocol that returns an IP address if given a physical
address. This protocol is typically used by a diskless
workstation that has a remote boot PROM installed in its
network adapter.
• Subnet: A logical division of a TCP/IP address space.
[Link]@[Link] 65
IP Addressing &
Subnetting
IP Addressing
Subnetting
VLSM
CIDR
Subnetting
• Problem: Organizations
have multiple networks
which are independently University Network
managed
• Solution 1: Allocate one or more Engineering Medical
addresses for each network School School
• Difficult to manage
• From the outside of the
organization, each network Library
must be addressable.
• Solution 2: Add another level
of hierarchy to the IP
addressing structure
Subnetting
CIDR and Routing Information
Company X :
[Link]/18
[Link]/15
[Link]/21
Internet Backbone
ISP y :
[Link]/24
Organization z1 : Organization z2 :
[Link]/26 [Link]/26
CIDR and Routing Information
Backbone routers do not know
anything about Company X, ISP
Y, or Organizations z1, z2.
Company X :
ISPISP X owns:
y sends [Link]/22
everything which matches
ISP X does not know about
Organizations z1, z2. the prefix:
[Link]/18
[Link]/26 to Organizations z1
[Link]/15
[Link]/26 to Organizations z2
[Link]/21
Internet Backbone
ISP X sends everything which
matches the prefix: ISP y :
[Link]/22 to Company X,
[Link]/24 to ISP y [Link]/24
What is it ?
Later developments, such as classless
interdomain routing and IPv6 have reduced the
need for the classical approach to subnetting,
but these later techniques borrow from the
basic subnetting principles, and no discussion of
TCP/IP is complete without a description of
subnetting.
[Link]@[Link] 70
Datagrams arrive efficiently
Dividing the Network at the gateway and pass into
the [Link] address space.
However, the picture gets
more complicated when you
consider how to deliver the
datagram after it passes into
the [Link] address space.
A Class A network has room
for over 16 million host IDs.
[Link]@[Link] 71
• With subnetting, IP addresses use a 3-
layer hierarchy:
• Network
• Subnet
Advantages of • Host
Subnetting • Reduces router complexity. Since
external routers do not know about
subnetting, the complexity of routing
tables at external routers is reduced.
An organization of ISP that is granted a range
of addresses may divide the range into
several subranges and assign each subrange
to a subnetwork(or subnet).
• A parameter called
the subnet mask
tells how much of
the address should
be used for the
subnet ID and how
much is left for the
actual host ID.
Subnet Mask
Class C [Link] -
[Link]
The number of addresses in each
subnetwork should be a power of 2.
Network
Masks Default masks:
• Class A: [Link]
• Class B: [Link]
• Class C: [Link]
Creates multiple logical networks
that exist within a single Class A, B,
or C network.
IP Subnet-Zero
For example, the Class C mask of
192 provides subnets 64 and 128,
but with the IP subnet-zero
command, you now get to use
subnets 0, 64, 128, and 192
Determine the
• One for each subnet
number of
• One for each wide area network
required connection
network IDs:
Network [Link] What’s the broadcast address for each subnet? The number right
before the value of the next subnet is all host bits turned on and
equals the broadcast address. For the zero subnet, the next subnet
is 128, so the broadcast of the 0 subnet is 127.
What are the valid hosts? These are the numbers between the
subnet and broadcast address
Logical Network Implementation
.2 .3 .130 .131
n2 =32- log2 64 = 26
Cont.
The first address is [Link]/26
Cont.
The first address The last address
is is
[Link]/28 [Link]/28
The sum of addresses in the subnets
is 208 addresses, which means 48
addresses are left in reserve. The first
address in the range is [Link]
and the last address is [Link].
Subnets? 21 = 2
Hosts? 215– 2 = 32,766 (7 bits in the third octet, and 8 in the fourth)
Valid subnets? 256 – 128 = 128. 0, 128. Remember that subnetting is performed in the third
octet, so the subnet numbers are really 0.0 and 128.0, as shown in the next table
Broadcast address for each subnet?
Valid hosts?
Practice Example #1B: [Link] (/17)
Network [Link]
The easiest way to assign the subnets is to assign the largest first. For example, you can assign in
this manner:
◦ netB: [Link]/27 host address range 1 to 30
◦ netE: [Link]/27 host address range 33 to 62
◦ netA: [Link]/28 host address range 65 to 78
◦ netD: [Link]/28 host address range 81 to 94
◦ netC: [Link]/30 host address range 97 to 98
Variable Length
Subnet
Mask(VLSM)
Subnet with
requirements
shown?
Classless Interdomain Routing
CIDR
Routing scalability in the Internet
Destination Host
[Link]
Subnet
subnet address?
Address Resolution Protocol (ARP)
• Router creates an ARP Request message to be
sent to all hosts on the subnet.
• Address resolution protocol message asks “Who has
IP address [Link]?”
• Passes ARP request to data link layer process for
delivery
Subnet
ARP Request
Address Resolution Protocol (ARP)
• Data link process of router broadcasts the ARP
Request message to all hosts on the subnet.
• On a LAN, MAC address of 48 ones tells all stations
to pay attention to the frame
Subnet
ARP Request
Address Resolution Protocol (ARP)
• Host with IP address [Link] responds
• Internet process creates an ARP response message
• Contains the destination host’s subnet address (48-
bit MAC address on a LAN)
ARP Response
Subnet
Address Resolution Protocol (ARP)
• Router delivers the IP packet to the destination
host
• Places the IP packet in the subnet frame
• Puts the destination host’s subnet address in the
destination address field of the frame
Deliver IP Packet
within a subnet frame
Subnet
Address Resolution Protocol
• ARP Requests and Responses are sent between the internet layer
processes on the router and the destination host
ARP
Router Destination Host
Request
Internet Internet
Process Process
ARP
Response
Address Resolution Protocol
• However, the data link processes deliver these
ARP packets
• Router broadcasts the ARP Request
• Destination host sends ARP response to the subnet
source address found in the broadcast frame
R
B
R
118 B
A
Host A Sends Packet • Host A learns the MAC address of R’s interface
• ARP request: broadcast request for [Link]
Through R
• ARP response: R responds with E6-E9-00-17-BB-4B
• Host A encapsulates the packet and sends to R
R
B 119
• Router R’s adaptor receives the packet
A
R Decides how to • R extracts the IP packet from the Ethernet frame
• R sees the IP packet is destined to [Link]
R
121 B
The Transmission Control
Protocol (TCP)
TCP Segment and UDP Datagram
Bit 0 TCP Segment Bit 31
Source Port Number (16 bits) Destination Port Number (16 bits)
Flag fields are one-bit fields. They include SYN, ACK, FIN,
Sequence numbers are 32 bits long.
and RST.
So are acknowledgment numbers.
TCP Segment and UDP Datagram
Source Port Number (16 bits) Destination Port Number (16 bits)
For flow control (to tell the other party to slow down),
The sender places a small value in the Window Size field.
8-125
TCP Segment and UDP Datagram
Bit 0 TCP Segment Bit 31
Data Field
SYN
SYN/ACK
ACK
FIN
ACK
FIN
ACK
Abrupt Reset
RST
Source Port Number (16 bits) Destination Port Number (16 bits)
Data Field
8-131
Port Numbers and Sockets in
TCP and UDP
TCP and UDP Port Numbers
• Computers are multitasking devices
• They run multiple applications at the same time
• On a server, a port number designates a specific application
Port 80 Port 25
Server
TCP and UDP Port Numbers
• Major Applications Have Well-Known Port Numbers
between 0 to 1023, i.e.
• HTTP is TCP Port 80
• SMTP is TCP Port 25
SMTP E-Mail
HTTP Webserver
Application
Application
Port 80 Port 25
Server
TCP and UDP Port Numbers
• Clients Use Ephemeral Port Numbers
• 1024 to 4999 for Windows Client PCs
• A client has a separate port number for each connection to a
program on a server
E-Mail
Webserver Application
Application on Mail
on Webserver Server
Client
TCP and UDP Port Numbers
[Link]:80
[Link]:25
[Link]:2849
SMTP Server
Client PC [Link]
[Link] Port 25
Port 2849
Use of TCP (and UDP) Port Numbers
Client
[Link]
Source: [Link]:2707
Destination: [Link]:80
SMTP Server
[Link]
Port 25
\Use of TCP (and UDP) Port Numbers
Client
[Link]
Source: [Link]:2707
Destination: [Link]:80
Source: [Link]:80
Destination: [Link]:2707
Webserver
[Link]
Port 80
Sockets in
two-way
transmission SMTP Server
[Link]
Port 25
Use of TCP (and UDP) Port Numbers
Client
[Link]
Source: [Link]:2707
Destination: [Link]:80
Source: [Link]:80
Destination: [Link]:2707
Webserver
[Link]
Port 80
Source: [Link]:4400
Destination: [Link]:25
SMTP Server
[Link]
Clients use a different ephemeral Port 25
port number for different connections
Dynamic Routing Protocols
Every Host Must Have a Unique IP Server hosts are given static IP addresses (unchanging)
Clients get dynamic (temporary) IP addresses that may
address be different each time they use an internet
Dynamic Host Configuration Clients get these dynamic IP addresses from Dynamic
Protocol (DHCP) Host Configuration Protocol (DHCP) servers
149
Dynamic Host Configuration Protocol (DHCP)
Pool of
IP Addresses
Client PC DHCP
A3-4E-CD-59-28-7F Server
150
Dynamic Host Configuration Protocol (DHCP)
Pool of
IP Addresses
Client PC DHCP
A3-4E-CD-59-28-7F Server
151
Why DHCP?
Versions 4 and 6
IPv4 and IPv6 Packets
Bit 0 IP Version 4 Packet Bit 31
Version Header Diff-Serv Total Length
(4 bits) Length (8 bits) (16 bits)
Value (4 bits) Length in octets
is 4
(0100)
Data The
Fieldsource and destination IP addresses
Are 32 bits long, as you would expect.