Chapter 4 Modified
Chapter 4 Modified
2
Internet Protocol (IP)
• Network protocol for the Internet
• Operates on all hosts and routers (routers connect
distinct networks into the Internet)
FTP HTTP NV TFTP
TCP UDP
IP
5
Datagram Switching / Forwarding
• No connection setup phase
(connectionless model)
• Analogy:
– Postal system: each packet contains
complete address for its destination
– Following signs (provided by
switches) to reach destination
6
Datagram Switching
• Managing tables in large, complex networks with
dynamically changing topologies is a real
challenge for the routing protocol
Host E
At switch 1: Host D
A 2 3
Switch 1
B 1 0
1
0
C 3 3
1
D 0 Host C 2
E 1
… … 0
Switch 3
Host A Host G Host B
1
3
2
7
Host H
Datagram Switching
• What happens if the destination is unknown ?
• Network discards packet
– Possibly notifying the sender (“no route to host”)
Host E
EC C data
Host D
Host F
2 Switch 2
BA A data
Switch 1 3
0
1
CF F data 3 0
1
Host C 2
DB B data
Switch 3
Host A 0
Host G Host B
AK?? K data 1
3
2
8
Host H
Datagram Model
• No round trip time delay waiting for connection setup
– Host can send data anywhere, anytime as soon as it is ready
– Source has no way of knowing if the network is capable of
delivering a packet or if the destination host is even up
• Packets are treated independently
– Possible to route around link and node failures dynamically
9
Datagram Model
• Every packet carries full address of
the destination
– Overhead per packet is higher than for
the connection-oriented model
– Global address to path translation
requires storage
– Might not be possible to deliver packet
(dest unknown)
10
Virtual Circuit Switching
11
Virtual Circuit Switching
• Each switch maintains a VC table
(connection state) per-link or per-switch
• Analogy
– Phone call: each packet follows an
established path
– Following a known route to reach the
destination
12
VC Tables in VC Switching
• VC table contains information for
each connection
– incoming / outgoing interface (port)
– incoming / outgoing VCI (virtual
circuit identifier)
• Permanent (PVC) or switched
(signaled) virtual circuit (SVC)
13
VC Tables in VC Switching
• Setup message in signaling process (to
create VC table) is forwarded like a
datagram
• Acknowledgment of connection setup
to downstream neighbors to complete
signaling
– Data transfer phase can start after ACK
is received
14
Signaling in VC Switching
I/F VCI I/F VCI
• Setup message is I/F VCI I/F VCI
in in out out
3 9 0
forwarded from in in out out
2 5 1
Host A to Host B 2
Switch 2
0 Switch 1 3 1
• On connection
0
3 1
setup B
request, each 2
setup B
entry in VC table 2
Switch 3
setup B
in in out out
2 7 3
15
Signaling in VC Switching
I/F VCI I/F VCI
• Host B accepts I/F VCI I/F VCI
in in out out
3 9 0 7
connection from in in out out
2 5 1 9
Host A, and sends 2
Switch 2
• In ACK, everyone 2
ACK 5
communicates its ACK 7
choice of VCI to 2
Switch 3
ACK 4
in in out out
2 7 3 4
16
Data Transfer in VC Switching
I/F VCI I/F VCI
• Host A knows that I/F VCI I/F VCI
in in out out
3 9 0 7
everything is in in in out out
2 5 1 9
place all the way 2
Switch 2
to Host B 0 Switch 1 3 1
0
3 1
data 7
• In data packets, 2
data 9
data 4
in in out out
2 7 3 4
17
Virtual Circuit Model
of discarding
Data Transfer in Source Routing
• Analogous to
2 Switch 2
following
directions 0 Switch 1 3 1
0
3 1
data 1 3 0
2 data 0 1 3
data 3 0 1
Switch 3
2
Host A Host B
data 1 0 3
1
3
data 2 3 0 1
0
data 3 0 1
22
Source Routing Model
• Source host needs to know the
correct and complete topology of
the network
– Changes must propagate to all hosts
• Packet headers may be large and
variable in size: the length is
unpredictable
23
Source Routing Model
24
Internetwork
• Concatenation of networks
H6 H7
H1 R3
Network R1 Network 2
Network11 Network
Network33 Network
Network44
Ethernet
Ethernet FDDI
FDDI Ethernet
Ethernet
Point
-to- R2
H5
point H8
H2 H3 H4
• Protocol stack
H1 H8
TCP R1 R2 R3 TCP
IP IP IP IP IP
25
Service Model
• Host to host delivery of packets (datagrams)
• Addressing- Globally unique IP address per `host`
• Un-reliable but simple
• Connection-less forwarding and hence datagram
Design choices
1. Simple and un-reliable (best effort): leads to simple
routers implementation
2. Complex but reliable: leads to complex routers
implementations
Keeping the routers as simple as possible was one of the
original design goals of IP
26
Datagram Format
0 4 8 16 19 31
Version HLen TOS Length
DestinationAddr
DestinationAddr
• Fragmentation support
– 16-bit packet ID (identifies packet fragments)
– 3-bit flags; one bit marks last fragment
– 13-bit fragment offset into packet (in 8-byte words)
• 8-bit “time-to-live” (TTL); a hop count until
forced destruction of packet
28
Datagram Format
• 16-bit IP checksum on header
• 32-bit source IP address
• 32-bit destination IP address
• Options and padding (variable length)
– Source-based routing (typically disabled)
– Record route 0 4 8 16 19 31
Version HLen TOS Length
– Several others Ident Flags Offset
TTL Protocol Checksum
SourceAddr
DestinationAddr
29
Datagram Format
30
Fragmentation and Reassembly
• Goal of IP: Providing a uniform host-to-host service model
over a heterogeneous collection of networks
• Problem with heterogeneity: Each network technology tends
to have its own idea of how large a packet/frame can be!!
• Every underlying network technology has got its own upper
limit on the packet size
– Ethernet frame size up to 1500 bytes long
– FDDI frames may be 4500 bytes long.
• What are the choices for the IP service model
– Send small enough packets
– Send datagram equal to the smallest frame size in the path
– Fragmentation and reassembly
31
Fragmentation and Reassembly
• Every network type has a maximum transmission unit
(MTU)
– the largest IP datagram that it can carry in a frame
• A reasonable choice for the IP datagram size is the MTU of
the network to which the host is directly attached.
• Fragmentation will only be necessary, if the path to the
destination includes a network with a smaller MTU
• Fragmentation typically occurs in a router when it receives
a datagram that it wants to forward over a network that has
an MTU that is smaller than the received datagram.
32
Fragmentation and Reassembly
For reassembly at the receiving host, all fragments carry the
same identifier in the Ident field.
Ident is chosen by the “sending host” and is intended to be
unique among all the datagrams that might arrive at the
destination from this source over some reasonable time
period.
Reassembly is performed at the receiving host
Fragmentation is performed at the intermediate routers
0 4 8 16 19 31
V ersion HLen TOS Length
Ident Flags Offset
TTL Protocol Checksum
SourceAddr
DestinationAddr
Options (variable) Pad
(variable)
Data
33
Fragmentation and Reassembly Example
•1420-byte datagram (20-byte IP header plus 1400 bytes of data) sent from H1
•H1 set Ident to X. Will it perform the fragmentation?
•NO, why ?
•Note the connection between R2 and R3
•MTU of ppp is 532 bytes. What will be the max payload size ?
•Look at the M bit in all the three fragments, 1, 1 and zero.
•Offset in the first fragment = 0, meaning that it is the first fragment
•Offset of the second fragment=64= data in the first fragment/8
•Offset in the second fragment=128=data in the first+second/8
Start of header
Ident= x 1 Offset= 0
Rest of header
H1 R1 R2 R3 H8
Start of header
Ident= x 1 Offset= 64
Rest of header
35
IP Addresses
7 bits (126 nets) 24 bits (16 million hosts)
Class A: 0 Network Host
37
Are You the Host or the Network?
40
IP Address Classes (Cont.)
• The 32 bits of the IP address are divided into
Network & Host portions, with the octets assigned
as a part of one or the other.
Network & Host Representation
By IP Address Class
41
Class A Addresses
• Class A IP addresses use the 1st 8 bits (1st Octet) to
designate the Network address.
• The 1st bit which is always a 0, is used to indicate
the address as a Class A address & the remaining
7 bits are used to designate the Network.
• The other 3 octets contain the Host address.
42
Class A Addresses (Cont.)
• Class A Network combinations
– 27 = 128.
– 00000000 to 01111111
• Since addresses with all zeros aren’t used &
address 127 is a special purpose address
– 27 -2=126 Class A Networks are available.
43
Class A Addresses (Cont.)
• There are 16,777,214 Host addresses available in a
Class A address.
• Rather than remembering this number exactly, you
can use the following formula to compute the
number of hosts available in any of the class
addresses, where “n” represents the number of bits
in the host portion:
(2n – 2) = Number of available hosts
44
Class A Addresses (Cont.)
• For a Class A network, there are:
224 – 2 or 16,777,214 hosts.
• Half of all IP addresses are Class A addresses.
• You can use the same formula to determine the
number of Networks in an address class.
• Eg., a Class A address uses 7 bits to designate
the network, so (27 – 2) = 126 or there can be
126 Class A Networks.
45
Class B IP Addresses
• Class B addresses use the 1st 16 bits (two octets)
for the Network address.
• The last 2 octets are used for the Host address.
• The 1st 2 bit, which are always 10, designate the
address as a Class B address & 14 bits are used to
designate the Network. This leaves 16 bits (two
octets) to designate the Hosts.
46
Class B IP Addresses (Cont.)
• So how many Class B Networks can be there?
• Using the formula, (214 – 2), there can be 16,382
Class B Networks & each Network can have (216 –
2) Hosts, or 65,534 Hosts.
47
Class C IP Addresses
• Class C addresses use the 1st 24 bits (three octets)
for the Network address & only the last octet for
Host addresses. The 1st 3 bits of all class C
addresses are set to 110, leaving 21 bits for the
Network address, which means there can be
2,097,150 (221 – 2) Class C Networks, but only
254 (28 – 2) Hosts per Network.
48
Classes of IP Addresses
49
Special Addresses
• A few addresses are set aside for specific
purposes.
• Network addresses that are all binary zeros, all
binary ones & Network addresses beginning with
127 are special Network addresses.
50
Special Addresses (Cont.)
51
Special Addresses (Cont.)
• Within each address class is a set of addresses that
are set aside for use in local networks sitting
behind a firewall or NAT (Network Address
Translation) device or Networks not connected to
the Internet.
52
Special Addresses (Cont.)
53
Datagram Forwarding
■ Every IP datagram contains the IP address of the destination host.
■ All hosts and routers that share the same network part of their
address are connected to the same physical network and can thus
communicate with each other by sending frames over that network.
■ Every physical network that is part of the Internet has at least one
router that, by definition, is also connected to at least one other
physical network; this router can exchange packets with hosts or
routers on either network.
54
Datagram Forwarding
• A datagram is sent from a source host to a destination
host
– What are the possibilities for the destination host location?
• Any node, first tries to find out whether it is connected
to the same physical network as the destination node.
– How a node/host knows this ?
• If source and destination are on the same physical
network then,
– Send the datagram directly to the destination
• Otherwise,
– Send it to the router.
55
Datagram Forwarding Algorithm
For Router or Host with more
For Host with one interface
than one interface
if (NetworkNum of destination =
if (NetworkNum of destination =
my NetworkNum)
NetworkNum of one of my
then interfaces)
then
deliver packet to destination
deliver packet to destination over that
directly
interface
else elseif (NetworkNum of destination is
deliver packet to default router in my forwarding table)
then
deliver packet to NextHop router
else
deliver packet to default router
56
Datagram Forwarding- Example
• H1 wants to send a datagram to H2
•H1 and H2 have the same network number in
their IP addresses
•H1deduces that it can deliver the datagram
directly to H2 over the Ethernet.
•Issue -How H1 finds out the correct Ethernet
address for H2?
•H1 wants to send a datagram to H8
•H1 and H8 have different network number in
their IP addresses
•What action will H1 take ?
•Send it to R1
Forwarding
•What action R1 will take ?
table at R2
•Send it to R2
•And so on.....
57
Datagram Forwarding
Network # Netmask Next
Hop/Port
18.0.0.0 255.0.0.0 1
128.32.0.0 255.255.0.0 2
0.0.0.0 0.0.0.0 3
59
ARP Packet Format
0 8 16 31
SourceHardwareAddr (bytes 0 – 3)
TargetHardwareAddr (bytes 2 – 5)
TargetProtocolAddr (bytes 0 – 3)
60
Dynamic Host Configuration
Protocol- DHCP
• DHCP server is required to provide configuration
information to each host
– Each host retrieve this information on bootup
• DHCP server can be configured manually, or it may
allocate addresses on-demand
– Addresses are “leased” for some period of time
• Each host is not configured for DHCP server, it
performs a DHCP server discovery
– A broadcast discovery message is sent by the host and a
unicast reply is sent by the server
61
DHCP Server
Unicast to server
DHCP DHCP
Other networks
Broadcast relay server
Host
62
ICMP Message
• Sent to the source when a node is unable to process
IP datagram successfully
• Error messages
– Destination unreachable (protocol, port, or host)
– Reassembly failed
– IP Checksum failed; or invalid header
– TTL exceeded (so datagrams don’t cycle forever)
– Cannot fragment
• Control messages
– Echo (ping) request and reply
– Redirect (from router to source host, to change route)
63
Forwarding vs Routing
• Routers and switches have enough knowledge to
decide the output port for a packet packet
forwarding
– In case of Virtual Circuits, each packet follows the same
pre-determined path.
– In case of IP datagram forwarding, each packet
destination address is matched with the FORWARDING
TABLE entries to decide the appropriate output.
– In case of source routing, each packet carries the full
path in its header.
• The Question is, how do the routers build their
forwarding tables ?
64
Routing
• Routing is the process by which forwarding tables are
built.
• While forwarding is performed locally within a node,
routing is gathering the information at a larger scale for
forwarding decisions
– Simple vs Complex
– FT optimized for local forwarding, RT optimized for topology
changes
Forwarding Table Routing Table
65
Routing
Malakand Chowk
Charsada Chowk
Pakistan
Dosehra Chowk Chowk
Meezan Chowk
College Chowk
69
Distance Vector Routing Example
node A B C D E F G A
C
A 0 1 1 x 1 1 x D
B 1 0 1 x x x x E
C 1 1 0 1 x x x
D x x 1 0 x x 1 F G
E 1 x x x 0 x x
F 1 x x x x 0 1
G x x x 1 x 1 0
Distance Vector Routing Example
D 2 2 1 0 x 2 1
E 1 2 2 x 0 2 x F G
F 1 2 2 2 2 0 1
G 2 x 2 1 x 1 0
Distance Vector Routing Example
Information in routing table of each node:
Iteration 3: This continues, till the routing converges….
D 2 2 1 0 3 2 1
E 1 2 2 3 0 2 3 F G
F 1 2 2 2 2 0 1
G 2 3 2 1 3 1 0
Distance Vector Routing Table
74
Routing Updates
• Scheduled and periodic
– If nothing has changed, why do we need it ?
– Serves two purposes
• To let neighbours know that “I am alive”.
• To help neighbours if some of their routes have failed.
• Triggered
– Side by side with periodic updates
– Triggered when there is “any changes” in the routing table of
any node.
– Node failures, link failures etc.
• How do I know that a link/node in my neighbourhood has
failed ?
75
Count to Infinity Problem
• Link from A to E fails
• Consider the scenario that in an iteration:
– A advertises, to its neighbors, a distance of
infinity to reach E.
– At the same time C advertises a distance of 2
to its neighbors(A, B, D) to reach E.
– B updated its routing table showing that it B
D
– Let say A recieves B’s update prior to C E
update regarding reaching to E and update its
table. Now decides it can reach E in 4 hops; F G
78
Routing Information Protocol (RIP)
Iteration 1:
•Router C would advertise to routers A and D
that:
• It can reach networks 2 and 3 (to which it is
directly connected) at a cost of 0
•It can reach networks 5 and 6 at cost of
INF(16).
•It can reach network 4 at cost INF(16).
79
Distance Vector vs. Link State
Routing-The Difference
• In distance vector, each node talks only to its
directly connected neighbors, but it tells them
everything it has learned (i.e., distance to all nodes
in the network).
• In link state, each node talks to all other nodes,
but it tells them only what it knows for sure (i.e.,
only the state of its directly connected links).
Operation of a Link State Routing
protocol
*LSA=
81 Link State
Reliable Flooding
• The process of making sure that all the nodes
participating in the routing protocol get a copy of the
link-state information from all the other nodes.
• The basic idea is for a node to send its link-state
information out on all of its directly connected links,
with each node that receives this information
forwarding it out on all of its links.
• This process continues until the information has
reached all the nodes in the network.
Link State Packet
• Each router creates a link state packet (LSP) which
contains the following information:
– The ID of the node that created the LSP
– A list of directly connected neighbors of that node, with the enable route
calculation
cost of the link to each one
– A sequence number Flooding
reliability
– A time to live for this packet
• The LSP is transmitted to all other routers, who each update
their own records
• When a routers receives LSPs from all routers, it can use
(collectively) that information to make topology-level
decisions
Link State Triggers
• LSPs are generated and distributed when:
– A time period passes
– New neighbours connect to the router
– The link cost of a neighbour has changed
– A link to a neighbour has failed (link failure)
– A neighbour has failed (node failure)
Reliable flooding
Link State Packets Dissemination
87
At node D
B
5 3
A 10 C
11 2
D