Unit - 3
Unit - 3
1
Review Topics
• Internet Protocol, IP Packet Format, Addressing: Physical
Addresses, Logical Addresses
• Port Addresses, Specific Addresses
• IP Addresses – Network Part and Host Part
• Networks Masks, Network Addresses and
• Broadcast Addresses, Address Classes, Loop back address
• Routing: types of Routing protocol, Border Gateway Protocol
(BGP), Routing Information Protocol (RIP),Open Shortest
Path First (OSPF) Protocol
• IP Routing Concept
• Routing Tables, Stream and Packets
• TCP Does? TCP – a reliable pipe
• TCP Connection – Multiple Conversations, Port Nos.
2
Network Layer: Internet Protocol (IP)
• Need for Network Layer: To solve the problem of delivery through several
links, the network layer (or the internetwork layer) was designed. The network
layer is responsible for host-to-host delivery and for routing the packets
through the routers or switches.
3
Network Layer: Internet Protocol (IP)
• Network Layer at Source, Router and Destination:
• Network layer at the source is responsible for creating a packet from the data coming from
above layer. The header of the packet contains, other information and the IP addresses of
source and destination. Also checks its routing table to find the routing information (such
as the outgoing interface of the packet or the physical address of the next node). If the
packet is too large, the packet is fragmented.
• Network layer at the router is responsible for routing the packet. When a packet arrives, the
router consults its routing table and finds the interface from which the packet must be sent.
The packet, after some changes in the header, with the routing information is passed to the
data link layer again.
• Network layer at the destination is responsible for address verification; it makes sure that
the destination address on the packet is the same as the address of the host. If the packet is a
fragment, the network layer waits until all fragme nts have arrived, and then reassembles
them and delivers to the transport layer.
4
Network Layer: Internet Protocol (IP)
• Internet as a Datagram Network
• Switching at the network layer in the Internet uses the datagram
approach for packet switching.
• In connectionless / datagram service, the network layer protocol treats each
packet independently, with each packet having no relationship to any other
packet.
• The packets of same message may or may not travel through same path
to reach at their destination.
• The reason for this decision (datagram approach) is that the Internet is
made of so many heterogeneous networks that it is almost impossible to
create a connection (logical) from the source to destination without
knowing the nature of the networks in advance.
• Hence The Internet Protocol version 4 (IPv4) is the delivery
mechanism used by the TCP/IP protocols in the Internet.
5
Network Layer: Internet Protocol (IP)
• IPv4
• IPv4 is an unreliable and connectionless datagram protocol – it is a best-effort
delivery service. The term best-effort means that IPv4 provides no error
control or flow control (except for error detection in the header).
• Position of IP v4 in TCP/IP protocol suite
6
Network Layer: Internet Protocol (IP)
• IPv4 Datagram / Packet format
10
Addressing
• PhysicalAddresses
• In following figure the two nodes are connected by a link (bus topology LAN). As
the figure shows, the computer with physical address 10 is the sender, and the
computer with physical address 87 is the receiver.
07:01:02:01:2C:4B
A 6-byte (12 hexadecimal digits) physical address.
11
Addressing
• LogicalAddresses
• Following figure shows a part of an internet with two routers connecting three
LANs. Each device (computer or router) has a pair of addresses (logical and
physical) for each connection.
• For example: A/10 (192.168.14.1/07:01:02:01:2C:4B) and P/95 (10.10.10.1/
06:03:5A:3C:02:4D)
12
Addressing
• Port Addresses: Following figure shows two computers communicating via an
Internet. Sending computer is running 3 processes with port addresses a, b, and c.
Receiving computer is running 2 processes with port addresses j and k.
• For example Process HHTP with port address - a (80) in the sending computer
communicating with Process HTTP with port address - j (3128) in the receiving
computer. A 16-bit port address represented as one single number.
• Note that although physical addresses change from hop to hop, logical and port
addresses remain the same from the source to destination.
13
Addressing
• SpecificAddresses:
• Some applications have user-friendly addresses that are designed for that specific
address.
• Examples include the e-mail address (for example, [email protected]) defines
the recipient of an e-mail. and
• The Universal Resource Locator (URL) (for example, www.google.com) is used
to find a document on the World Wide Web.
• Host Computers, Routers and Protocol Layers
• Host computer (or sometimes "Host")
• Any computer system that connects to an internet and runs
applications.
• Uses all layers of TCP/IP model.
• Router
• Connect networks to form internet.
• Do not use protocols from all layers of TCP/IP.
• In particular, does not use Application layer and Transport layer.
14
IP: Internet Protocol Addresses
• MAC Addresses form a flat or physical addressing system – you can not
determine the location on the internet of a host using this system.
• IP addresses form a hierarchical or logical addressing system – they
help you to find the location of a host on the internet.
• Internet is an abstraction created in software which can use addresses,
packet format and delivery techniques independent of the physical
hardware. Each host in the internet must have an Unique IPAddress.
• Users, application programs and software operating in the higher layers
of the protocol stack use these addresses.
• In IP protocol each host is assigned an unique 32 bit address (4 bytes).
• For example: 192.168.14.50.
• Any packet destined for a host on the internet will contain the Source as
well as Destination IP address.
• An IPv4 address is 32 bits long, IPv4 addresses are an unique and
universal.
• The address space of IPv4 is 232 or 4,294,967,296.
15
IP: Internet Protocol Addresses
16
IP: Internet Protocol Addresses
• IP AddressHierarchy
• Addresses are broken into a Network-ID and a Host-ID for routing efficiency.
• The Network-ID is uniquely assigned to an individual network.
• The Host-ID is uniquely assigned to a host within a given network.
1
1
Network Network 2
1 R 2
3
3
5
• IP AddressGuarantee
• The IP address hierarchy guarantees two important properties.
• Each computer has a unique address
• The full address contains both a Network-ID and a Host-ID assigned to guarantee
uniqueness.
• Although Network-ID must be assigned globally, Host-IDs can be assigned
locally without global coordination.
17
IP: Internet Protocol Addresses
• How many bits for Network-ID and a Host-ID?
• How should the 32 bit address be divided?
• In other words how many bits for Network-ID, how many for Host-ID?
• Example 1:
• 16 bits for each
• 65536 max networks and 65536 max hosts/network
• Example 2:
• 24 bits for Network-ID and 8 bits for Host-ID
• 8,388,608 max networks and 256 max hosts/network
• Other possibilities?
• Example 3:
• 8 bits for Network-ID and 24 bits for Host-ID
• 256 max network and 8,388,608 max hosts/network
• More Flexible System: Create system with different classes of address.
Each class has different size for the Network-ID and the Host-ID.
• (Up to) the first 4 bits determine the class. Five classes are defined.
18
IP: Internet Protocol Addresses
• Five classes of IP address: In classful addressing, the address space is divided
into five classes: A, B, C, D, and E.
• The original IP addressing scheme divides host addresses into three primary
classes (Unicast addresses). The class of an IP address determines the boundary
between the Network-ID and Host-ID.
• Unicast: An identifier for a single interface. A packet sent to an unicast address is
delivered to the interface identified by that address.
• Multicast: An identifier for a set of interfaces (belongs to different nodes). A
packet sent to a multicast address is delivered to all interfaces identified by that
address. Class A
0 Net-ID(7) Host-ID(24)
Class B
1 0 Net-ID(14) Host-ID(16)
Class C
110 Net-ID(21) Host-ID(8)
Class D
1110 MulticastAddress(28)
Class E
1111 Reserved for future use(28)
19
IP: Internet Protocol Addresses
• Computing the Class
First 4 bits of Address Table index (in decimal) Class of Address
0000 0 A
0001 1 A
0010 2 A
0011 3 A
0100 4 A
0101 5 A
0110 6 A
0111 7 A
1000 8 B
1001 9 B
1010 10 B
1011 11 B
1100 12 C
1101 13 C
1110 14 D
1111 15 E
20
IP: Internet Protocol Addresses
• Dotted Decimal Notation
• Conventionally 32 bit IP addresses are expressed in dotted decimalnotation.
• Each byte is expressed as a decimal number (0-255). The bytes are separated by
decimal points. Addresses range from 0.0.0.0 to 255.255.255.255.
Net-ID 192.5.48
Net-ID 10 R
23
IP: Internet Protocol Addresses
• Default Subnet Masks for Classful addressing
• Each Class IP address uses a default number of bits to represent the
Network ID.
• If 8 bits are used for the Network ID of a Class A address, what is the
default subnet mask?
• To find the default subnet mask of a Class A address, put 1’s in the first 8
bits of the subnet mask.
• Class A’s default subnet mask is 11111111.00000000.00000000.00000000
• In dotted decimal form, this is 255.0.0.0
• For class B default subnet mask is 255.255.0.0
• For class C default subnet mask is 255.255.255.0
24
IP: Internet Protocol Addresses
• Classless IP addresses
• All networks have to choose one of the three classes (depending on the
size of network).
• Many addresses are wasted or not used.
• To overcome this problem classless IP address is used.
• Consider the network consist of 9 hosts, only 4 bits of Host-ID are needed
to represent all possible host values.
• Use of class C is waste of addresses.
• Classless addressing solves the problem by allowing an ISP to assign a
Network-ID that is 28 bits long (network can have up to 14 hosts only).
• For example: Network-ID – 28 bit and Host-ID – 4 bit
• 192.168.14.240 - 255
• 241 to 254 - actual addresses used for nodes
• 192.168.14.240 – Network address
• 192.168.14.255 – Broadcast address
• 11111111. 11111111. 11111111.11110000 – Subnet Mask (255.255.255.240)
25
IP: Internet Protocol Addresses
• Special IP addresses
• Network Address
• Directed Broadcast Address
• Limited BroadcastAddress
• This Computer Address
• Loop back Address
• Berkley Broadcast Address Form
• Network Address: Useful to have an address which represents a network.
• Formed by adding a 0 in Host-ID part.
• Example:
• 128.10 128.10.0.0
• 10 10.0.0.0
• 192.5.48 192.5.48.0
• A network address should never appear as a destination in a packet.
26
IP: Internet Protocol Addresses
• Special IP addresses
• Directed Broadcast Address
• Often convenient to send a message to all hosts on a single network.
• Directed broadcast address formed by adding a Host-ID containing all 1
bits.
• Once the direct broadcast message arrives in the destination network it is
sent to all host on the network via
• The local networks hardware broadcast facility or if none present.
• Individual messages sent to each host.
• Limited Broadcast Address
• Term limited broadcast refers to a broadcast on a local physical network.
• Typically used on startup by a computer that doesn't yet know the network
number.
• Message must contain all 1 bits (Network-ID and Host-ID).
• Message remains on the local network.
27
IP: Internet Protocol Addresses
• Special IP addresses
• This Computer Address
• A computer needs to know its IP address to send or receive internet
packets.
• TCP/IP contains protocols which allow a computer to obtain its IP address
automatically when it boots.
• These startup protocols use IP to communicate.
• Sending an IP packet requires a source address.
• Address 0.0.0.0 means “this computer”.
• Loop Back Address
• During testing it is often convenient to have two applications which will
eventually communicate, run on the same computer.
• A message can travel down the stack from one application and back up the
stack to the other application.
• IP reserves class A Network-ID 127 for this purpose (the Host-ID doesn't
matter). By convention 127.0.0.1 is most often used.
28
IP: Internet Protocol Addresses
• Special IP addresses
• Berkley Broadcast AddressForm
• UC Berkley developed and distributed an early version of TCP/IP as part of BSD
UNIX.
• Instead of a directed broadcast address Host-ID of all 1 bits they used a Host-
ID of all 0 bits. This is known as a Berkley Broadcast.
• Many early computer manufacturers derived their software from the Berkley
Implementation.
• Special IP AddressSummary
Net-ID Host-ID Type of Address Purpose
All-0's All-0's This computer Used during boot-strap
Network All-0's Network Identifies a network
Network all-1's Directed broadcast Broadcast on specified net
All-1's All-1's Limited broadcast Broadcast on local net
127 Any Loop back Testing
Network All-0's Directed broadcast Berkley broadcast
29
Routers and IP Addressing
• Each host has an address but each router has two (or more) addresses!
• Why?
• A router has connections to multiple physicalnetworks.
• Each IP address contains a Network-ID that specifies a physical network.
• An IP address does not really identify a specific computer but rather a
connection between a computer and a network.
• A computer with multiple network connections (e.g. a router) must be assigned an
IP address for each connection.
• Example:
30
Network Layer: Delivery, Forwarding and Routing
• Delivery: refers to the way a packet is handled by the underlying networks under
the control of network layer.
• Forwarding: refers to the way a packet is delivered to the next station.
• Routing: refers to the way routing tables are created to help in forwarding.
• Routing protocols: these are used to continuously update the routing tables that
are used for forwarding and routing.
• Delivery:
• Direct Delivery: the final destination of the packet is a host connected to the same
physical network as the deliverer.
• It occurs when source and destination of the packet are located on the same
network.
• It occurs when the delivery between the last router and the destination host.
• Indirect Delivery: in this, the packet goes from router to router until it reaches the
one connected to the same physical network as its final destination.
• This delivery always involves one direct delivery but zero or more indirect
deliveries.
31
Network Layer: Delivery, Forwarding and Routing
• Delivery: Direct Delivery and Indirect Delivery
32
Network Layer: Delivery, Forwarding and Routing
• Forwarding means to place the packet in its route to its destination. Forwarding
requires a host or a router to have a routing table. When a host has a packet to send
or when a router has received a packet to be forwarded, it looks at this table to find
the route to the final destination.
• Forwarding: Route method versus Next Hop method
33
Network Layer: Delivery, Forwarding and Routing
• Forwarding: Host-specific versus Network-specific method
34
Network Layer: Delivery, Forwarding and Routing
• Forwarding: Default method
• You can set up a default route on a router.
• If no routing information known about a destination Network-ID, a default route
can be used to automatically send information down to a specific route.
• Hopefully, another router will know the correct route.
35
Network Layer: Delivery, Forwarding and Routing
• Routing Table
• A router has a routing table with an entry for each destination, or a combinations of
destinations, to route IP packets. It can be either static or dynamic.
• Static routing table: it consist of information entered manually. The administrator
enters the route for each destination into the table.
• It cannot be updated automatically, when there is change in the internet.
• It can be used in a small internet that does not change very often.
• Dynamic routing table: is updated periodically by using one of the dynamic
protocols such as RIP, OSPF or BGP.
• Whenever there is change in the internet (shutdown of a router or breaking of
link), dynamic routing protocols updates all the tables in the routers
automatically.
• Dynamic updates is must for efficient delivery of IPPackets.
36
Network Layer: Delivery, Forwarding and Routing
• Routing Table format
37
Network Layer: Delivery, Forwarding and Routing
• Routing Table format
• Mask: it defines the mask applied for the entry.
• Destination Address/ Network Address: it defines the network address to which
the packet is finally delivered.
• Next Hop address: it defines the address of the next hop (router) to which the
packet is delivered.
• Flags: it defines up to five flags, that signify either presence or absence.
1. U (up): it indicates the router is up and running. If this field is not present
means the router is down, packet cannot be forwarded and is discarded.
2. G (gateway): it means that the destination is in another network. The packet
is delivered to the next hop-router for delivery.
3. H (host-specific): it indicates that the entry in the network address field is a
host specific.
4. D (added by redirection): it indicates that routing information for this
destination has been added to the host routing table by redirection message
from ICMP.
5. M (modified by redirection): it indicates that routing information for this
destination has been modified by redirection message from ICMP.
38
Network Layer: Delivery, Forwarding and Routing
• Routing Table format
• Reference count: it gives the number of users of this route at the moment.
• Utilities (use): there are several utilities that can be used to find the routing
information and the content of a routing table. For example: netstat, ifconfig etc.
• Interface: it shows the name of the interface.
• Dynamic Routing Protocols: Functions
• Dynamically share information between routers.
• Automatically update routing table when topology changes.
• Determine best path to a destination.
39
Network Layer: Delivery, Forwarding and Routing
• Dynamic Routing Protocols: Purpose
• Discover remote networks.
• Maintaining up-to-date routing information.
• Choosing the best path to destination networks.
• Ability to find a new best path if the current path is no longer available.
• Dynamic Routing Protocols: Classification
40
Network Layer: Delivery, Forwarding and Routing
• Dynamic Routing Protocols: Classification
• Intra – Domain / Interior Gateway Routing Protocol (IGP)
• Today, an internet can be so large that one routing protocol cannot handle
the task of updating the routing tables of all routers. For this reason, an
internet is divided into number of autonomous systems.
• An Autonomous System (AS) is a group of networks and routers under
the authority of a single administration.
• Routing inside an autonomous system is called intra-domain routing.
• IGP used for routing inside an autonomous system & used to route within
the individual networks themselves – Examples are: RIP and OSPF.
• Inter – Domain / Exterior Gateway Routing Protocol (EGP)
• Routing between autonomous systems is called inter-domain routing.
• EGP used for routing between autonomous systems – Example: BGP.
41
Network Layer: Delivery, Forwarding and Routing
• Dynamic Routing Protocols: Classification – IGP &EGP
42
Network Layer: Delivery, Forwarding and Routing
• Dynamic Routing Protocols: Classification
• Routing Information Protocol (RIP)
• Used as an intra – domain / Interior Gateway Routing Protocol (IGP).
• It is distance vector route discovery protocol.
• Each router advertises its distance vector (list of destination networks and
their distances from the broadcasting router in terms of hops) every 30
seconds (or whenever its routing table changes) to all of its neighbors.
• Maximum hop count is 15, hence has incomplete view of network
topology, does not work well in large and complicated inter-networks.
• Uses hope count as a metric.
• Open Shortest Path First (OSPF)
• Used as an intra – domain / Interior Gateway Routing Protocol (IGP)
• It is link state route discovery protocol. Has complete view of network
topology. Updates are not periodic.
• It exhibits better performance than RIP in large inter-network.
• Uses Cost (hope count) and Bandwidth as a metric.
43
Network Layer: Delivery, Forwarding and Routing
• Dynamic Routing Protocols: Classification
• Border Gateway Protocol (BGP)
• Used as an inter – domain / Exterior Gateway Routing Protocol (EGP).
• Uses path vector routing. It first appeared in 1989 and has gone through
four versions.
• The difference between the distance vector routing and path vector
routing can be compared to the difference between a national map and
an international map. A national map can tell us the road to each city and
the distance to be traveled if we choose a particular route; an international
map can tell us which cities exist in each country and which countries
should be passed before reaching that city.
• Sharing: any AS shares its table with immediate neighbors (ASs).
• Updating: Adding the nodes that are not in its routing table i.e. adding its
own AS and the AS that sent the table.
• The routing table shows the path completely.
44
Network Layer: Delivery, Forwarding and Routing
• Dynamic Routing Protocols: Classification
• Border Gateway Protocol (BGP)
WAN
WAN
45
Network Layer: Delivery, Forwarding and Routing
• MTU and Fragmentation
• For any given network there is a Maximum Transmission Unit or MTU.
• If a datagram arrives at a network an exceeds the MTU, the protocol software will
break the Datagram up into smaller pieces called fragments.
• The format of a fragment is the same except for bits which are set to indicate a
fragment.
46
Network Layer: Delivery, Forwarding and Routing
• MTUs for some networks
• Reassembly
• Fragments are never reassembled until the final destination.
• Why?
• Reduce amount of state information in routers. When packets arrive at a
router they can simply be forwarded.
• Allows routes to change dynamically. Intermediate reassembly would be
problematic if all fragments didn't arrive.
47
Routing Protocols: Distance Vector,
Link State, Path Vector, Routing in
Internet: RIP ,OSPF, BGP.
49
10/1/2021
Routing architecture
10 171.69.245.10
55
Details on Routing 10/1/2021
56
Forwarding table
10 if0 8:0:2b:e4:b:1:2
57
Network as a Graph
1
1
1 1
1
1 1
B 1 A B C D E F G
1
1 C
1
A
A 0 1 1 ∞ 1 1 ∞
D
1
1 1
B 1 0 1 ∞ ∞ ∞ ∞
E
1
C 1 1 0 1 ∞ ∞ ∞
F G
D ∞ ∞ 1 0 ∞ ∞ 1
Table 1 shows Initial distances stored
at each node (global view). E 1 ∞ ∞ ∞ 0 ∞ ∞
F 1 ∞ ∞ ∞ ∞ 0 1
G ∞ ∞ ∞ 1 ∞ 1 0
62
Continue
Thus, A initially believes that it can reach B in one hop and that D is
unreachable.
The routing table stored at A reflects this set of beliefs and includes
the name of the next hop that A would use to reach any reachable
node.
Routing Tables
B
Cost Next
Hop
C
A
D
E B 1 B
F G C 1 C
With this information, routing D ∞ -
table at A is -->
E 1 E
F 1 F
G ∞ -
C
E 1 E
F 1 F
A
D
E
G 2 F
F G
Table 3 Final routing table at node A.
Final Distance Matrix
B A B C D E F G
C
A
A 0 1 1 2 1 1 2
D
B 1 0 1 2 2 2 3
E
C 1 1 0 1 2 2 2
F G
D 2 2 1 0 3 2 1
E 1 2 2 3 0 2 3
F 1 2 2 2 2 0 1
G 2 3 2 1 3 1 0
66
A router running RIP sends the contents of its routing table to each of its
adjacent routers every 30 seconds.
An Example of RIP
In link state routing, if each node in the domain has the entire
topology of the domain the list of nodes and links, how they are
connected including the type, cost (metric), and condition of the
links (up or down)-the node can use Dijkstra's algorithm to build a
routing table.
Concept of link state routing
Link state knowledge
Dijkstra algorithm
Example of formation of shortest path tree
Routing table for node A
Shortest Path Algorithm (1)
The first five steps used in computing the shortest path from A to D. The
arrows indicate the working node
PATH VECTOR ROUTING 83
OSPF
Features of OSPF
Continue..
Continue..
Version #: A one-octet field that defines the current version of the OSPF
protocol used.
Type: A one-octet field that defines the OSPF packet type. The five
packet types defined for OSPF are Hello, Database Description, Link
State Request, Link State Update, and Link State Ack.
Packet Length: A two-octet field defining the length of the entire OSPF
packet.
Router ID: A four-octet field defining the Router’s IP address of the
packet’s source.
92
Continue..
Area ID: A 32-bit address identifying the area (subnet) to which the
packet belongs.
When a TCP connection is created for BGP, it can last for a long
time, until something unusual happens.
95
External & Internal BGP sessions
The border gateways are the routers through which packets enter
and leave the AS.
99
Cont..
100
TCP/IP Protocol Suite
Cont..
101
102
Note:
Mobile IP
What is Mobile IP?
Mobile Node
A node/device that changes its point of attachment to the Internet
Home Agent
A router in the home network that communicates with the mobile node
Foreign Agent
A router in a foreign network that delivers information between mobile node
and its home agent
Care-of-Address
Mobile Node’s current IP address
Correspondent Node
Node/device that is communicating with the mobile node (i.e. web server)
How does Mobile IP work?
How does the mobility binding table and the visitor list get
updated?
What will happen when the mobile node wants to register with the foreign
agent?