0% found this document useful (0 votes)
3 views

UNIT 4-1

The document provides an overview of the Network Layer, detailing its role in data delivery, including functions like addressing, routing, packet forwarding, and error handling. It discusses key protocols such as IP, ICMP, and ARP, and explains the differences between connection-oriented and connectionless services. Additionally, it covers the architecture of routers, including components like input ports, switching fabric, and output ports, as well as the structure of IPv4 datagrams.

Uploaded by

Purahar sathya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

UNIT 4-1

The document provides an overview of the Network Layer, detailing its role in data delivery, including functions like addressing, routing, packet forwarding, and error handling. It discusses key protocols such as IP, ICMP, and ARP, and explains the differences between connection-oriented and connectionless services. Additionally, it covers the architecture of routers, including components like input ports, switching fabric, and output ports, as well as the structure of IPv4 datagrams.

Uploaded by

Purahar sathya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 104

Unit-4

Network Layer
1.Introduction,

2.Virtual Circuit and Datagram


Networks,

3.Inside Router,

4.The Internet Protocol (IP),

5.Routing Algorithms-The Link State


(LS) Routing Algorithm, The Distance
Vector (DV) Routing Algorithm,
Hierarchical Routing
Introduction: Network Layer
The Network Layer helps in
delivering data from the sender to
the receiver.
1.On the Sending Side application
transport
1. It adds extra information network
data link
(header) to the data from the physical
network network
transport layer. network
data link
physical
data link
physical
data link
2. This creates datagrams physical network network
(packets). data link
physical
data link
physical
2.On the Receiving Side
1. It removes the extra network
data link
network
data link

information (header) and physical


network
physical
data link
sends the actual data to the physical

transport layer. network


application
transport
data link
3.Routers and Hosts network physical
network
data link
network
data link

1. Every host and router has data link


physical
physical physical

network layer protocols to


manage data transfer.
2.Routers check the headers
of passing datagrams to
decide where to send them
1.Network Layer - Introduction
The Network Layer is responsible for routing data packets from the
source to the destination across multiple networks. It determines the best
path for data transmission and ensures that packets are delivered
efficiently.
Functions of the Network Layer
1. Addressing:
•Assigns unique IP addresses to devices for identification.
•Example: 192.168.1.1 (IPv4) or 2001:db8::ff00:42:8329 (IPv6).
2. Routing:
•Determines the best path for sending data between devices.
•routing algorithms like Link State and Distance Vector.
3.Packet Forwarding:
•Moves packets from one network to another using routers.
•Uses IP-based forwarding tables.
4.Fragmentation and Reassembly
Splits large packets into smaller pieces (if needed).Reassembles them at the
destination.
5.Encryption & Decryption
•Secures data by encrypting it before sending and decrypting it at the
receiver's end.
5.Error Handling and Congestion Control:
•Detects errors in packet delivery.
Network Layer Protocols
1.IP (Internet Protocol): Gives every device a unique
address and helps send data across networks.
Example: Your phone or computer uses an IP
address to access websites or send emails.

2.ICMP (Internet Control Message Protocol):


Checks network issues and sends error messages.
Example: When you use the ping command to
check if a website is online, ICMP replies with a
response

3.ARP (Address Resolution Protocol): Finds the


physical (MAC) address of a device using its IP
address.
Example: If your computer wants to talk to another
computer in the same Wi-Fi network, ARP helps find its
4. RIP (Routing Information Protocol): Helps
small networks find the best route for data by
checking the number of hops (steps) to the
destination.
Example: Used in small office or home networks
where routers talk to each other to find the best path
for internet traffic.

5.OSPF (Open Shortest Path First): Chooses the


fastest route for data in large networks.
Example: Used in big companies and data centers to
manage internet traffic efficiently.

6.BGP (Border Gateway Protocol): Decides how


data moves between different networks across the
internet.
Example: Used by Internet Service Providers
(ISPs) to connect different parts of the internet
Network Service Model
The Network Service Model specifies how data is transferred from one
device to another over a network.
Types of Network Service Model
1. Connectionless Service (Datagram Model)
•each packet is independent and can take a different route.
•No prior connection setup is needed.
•Unreliable service (packets may arrive out of order or be lost).
•Example Protocol: IP (Internet Protocol).
Example :
Web browsing (HTTP over IP) – Independent packets are sent.
Online gaming (UDP/IP) – Speed is more important than reliability.
Streaming services (YouTube, Netflix) – Uses UDP for faster delivery.
2. Connection-Oriented Service (Virtual Circuit Model) 🔗
•a predefined route is established before sending data.
•Ensures reliable, in-order delivery of packets.
•Connection must be set up before transmission.
•Example Protocols: MPLS (Multiprotocol Label Switching), ATM
(Asynchronous Transfer Mode).
Example :
Video calls (VoIP over TCP/IP) – Requires continuous, reliable data
flow.
Banking transactions (MPLS-based networks) – Ensures security and
accuracy.
Network Layer Service models
•Internet (Best Effort): No guarantees. Sometimes
fast, sometimes slow. Data may be lost or arrive out of
order.

•ATM CBR(Constant Bit Rate): Sends data at a fixed


speed, ensuring no loss and correct order.

•ATM VBR(Variable bit Rate): Sends data at a


flexible speed but still guarantees order and timing.

•ATM ABR(Available Bit Rate): Ensures a minimum


speed and correct order but may experience some
data loss.

•ATM UBR(Unspecified Bit Rate): No guarantees


except that the data arrives in order, but it may be
slow or lost.
2.Virtual-Circuit Network (Connection
Service)
A Virtual Circuit (VC) is a connection-oriented
method in networking where a fixed path is set
before sending data. It ensures reliable
communication between sender and receiver.

Key Components
1.Fixed Path – A dedicated route is set before data
transfer.
2.VC Numbers – Each link in the path gets a unique
number to identify the connection.
3.Forwarding Table – Routers store VC numbers to
forward packets properly.

How It Works?
4.Each packet carries a VC number in its header.
Routing and Forwarding

routing algorithm routing algorithm determines


end-end-path through network

local forwarding table forwarding table determines


header value output link local forwarding at this router
0100 3
0101 2
0111 2
1001 1

value in arriving
packet’s header
0111 1

3 2
Virtual Circuit Setup

application
6. receive data application
transport 5. data flow begins transport
network 4. call connected 3. accept call
network
data link 1. initiate call 2. incoming call
data link
physical physical
Virtual Circuit Setup
 Found in ATM, Frame Relay, and X.25 networks.

 Not used in today’s Internet (which relies on


datagram switching).

 Three phases in a virtual circuit:

1. VC setup
2. Data transfer
3. VC teardown
1. VC setup:
Connection Request: Sender asks the network to create a
path to the receiver.
Path Selection: The network decides the best route for all
packets.
VC Number Assignment: Each link in the path gets a unique
number to track packets.
Router Configuration: Routers update their tables to forward
packets correctly.
Connection Confirmation: The network informs the sender
that the VC is ready for data transfer.
2. Data Transfer
Once the VC is set up, packets follow the fixed path to reach
their destination.
3. VC Teardown (Closing the Connection)
The sender or receiver requests to close the connection.
The network informs the other side and removes VC
information from routers.
The network layer updates all routers to delete the VC,
meaning it no longer exists.
VC Forwarding Table
3.Datagram Network
• In connectionless service, each packet is sent
individually and can take a different route to
reach the destination.
✔ No setup is needed before sending packets.
✔ These packets are called datagrams, and the
network is a datagram subnet.

application application
transport transport
network 1. send datagrams 2. receive datagrams network
data link data link
physical physical
Datagram forwarding table

routing algorithm 4 billion IP


addresses, so rather
local forwarding table than list individual
destination address
dest address output
list range of
address-range 1 3 link
address-range 2 2 addresses
address-range 3 2 (aggregate table
address-range 4 1
entries)

IP destination address in
arriving packet’s header

1
3 2

Network Layer
Datagram forwarding table
Destination Address Range Link Interface

11001000 00010111 00010000 00000000


through 0
11001000 00010111 00010111 11111111

11001000 00010111 00011000 00000000


through 1
11001000 00010111 00011000 11111111

11001000 00010111 00011001 00000000


through 2
11001000 00010111 00011111 11111111

otherwise 3
From above table,

200.23.16.0 to 200.23.23.255 → Link Interface


0
200.23.24.0 to 200.23.24.255 → Link Interface
1
200.23.25.0 to 200.23.31.255 → Link Interface
2
All other IPs → Link Interface 3

It choose longest prefix matching

First Range (Link Interface: 0) calculation


Start: 11001000 00010111 00010000
00000000
Binary to Decimal: 200.23.16.0
End: 11001000 00010111 00010111 11111111
Longest prefix matching
longest prefix matching
when looking for forwarding table entry
for given destination address, use longest
address prefix that matches destination
address.
Destination Address Range Link interface
11001000 00010111 00010*** ********* 0
11001000 00010111 00011000 ********* 1
11001000 00010111 00011*** ********* 2
otherwise 3

examples:
which interface?
DA: 11001000 00010111 00010110 10100001
DA: 11001000 00010111 00011000 10101010which interface?
4. ROUTER

A router is a networking device that connects


multiple networks and directs data packets between
them.
Functions of a Router
1.Find the Best Route (Using Routing Protocols)
•Uses protocols like RIP, (Routing Information Protocol) OSPF(Open
Shortest Path First), or BGP(Border Gateway Protocol) to determine the
best path for data.
•Creates a routing table to decide where to send packets.
2. Forward Packet
•Reads the destination address of incoming packets.
•Chooses the best outgoing link and sends the packet
forward.

Components of a Router
1. Input Ports – Receive incoming data packets.
2. Switching Fabric – Moves packets inside the router.
Inside Router
 Routers have four components:
1. Input ports
2. Switching fabric
3. Output ports
4. Routing processor
Input port functions
lookup,
link forwarding
line layer switch
termination protocol fabric
(receive)
queueing

physical layer:
bit-level reception
data link layer: decentralized switching:
e.g., Ethernet • given datagram dest., lookup output port
using forwarding table in input port memory
(“match plus action”)
• goal: complete input port processing at ‘line
speed’
• queuing: if datagrams arrive faster than
forwarding rate into switch fabric
Input Port
The input port in a router receives incoming data and prepares
it for forwarding.

Main Functions:

1.Line Termination – Receives data from the network.


2.Link Layer Processing – Reads data frames (e.g., Ethernet)
and extracts packets.
3.Lookup & Forwarding – Decides where to send the packet
using a table.
4.Queueing – Holds packets temporarily if traffic is high before
sending them forward.

Key Concept: Decentralized Switching

•The input port itself decides where to send packets (no


central processor needed).
•Goal: Fast processing to prevent delays.
•If too many packets arrive at once, they wait in a queue until
forwarded.
Switching fabric in a router is the internal system
that moves packets from input ports to output ports.
It acts like a high-speed highway inside the router.
Switching rate: A rate at which packets can be
transfer from inputs to outputs.

Functions:

1.Receives packets from the input port.


2.Transfers packets to the correct output port.
3.Ensures fast and efficient data movement inside
the router.
Types of Switching Fabrics:

4.Crossbar Switching – Uses a grid of switches to


connect input and output directly.
5.Bus Switching – All packets use a shared
communication line.
Three Types of Switching Fabrics
A switching fabric is the system inside a router that
moves data from input ports to output ports.

1. Memory-Based Switching
•Uses router memory to store and send packets.
•The processor decides where to forward packets.
•Slowest because packets pass through memory.

2. Bus-Based Switching
•Uses one shared communication bus for all
packets.
•Only one packet moves at a time (limits speed).
•Faster than memory-based switching but still
slow.

3. Crossbar Switching
•Uses a grid of switches to connect ports directly.
Output Port
datagram
buffer line
switch link termination
fabric layer
queueing protocol
(send)

Output Port
The output port is responsible for sending packets from the
router to the next destination.
• Functions of an Output Port:
1.Buffering – Temporarily stores packets before sending.
2.Packet Transmission – Sends packets to the next device.
3.Congestion Handling – If the buffer is full, some packets may
be lost.
Bidirectional Links:
• Data can flow in both directions using input and output
ports together.
Routing Processor
The Routing Processor is like the brain of a
router. It decides where to send data packets.

Functions:

1.Stores Routing Information – Keeps track


of different network paths.
2.Finds the Best Path – Uses algorithms to
select the best route.
3.Manages Network Traffic – Ensures
smooth data flow.
4.Controls Packet Forwarding – Sends
packets through the correct ports.
5.Internet Network Layer

transport layer: TCP, UDP

routing protocols IP protocol


• path selection • addressing conventions
• RIP, OSPF, BGP • datagram format
network • packet handling conventions
layer forwarding
table
ICMP protocol
• error reporting
• router “signaling”

link layer

physical layer
Internet Network Layer
The Network Layer is responsible for moving data
between devices across different networks.

Key Components:

1.Routing Protocols (RIP, OSPF, BGP) – Decide the


best path for data.
2.Forwarding Table – Helps route data to the
correct destination.
3.IP Protocol – Defines addressing rules and
packet format.
4.ICMP Protocol – Handles error reporting and
network diagnostics.
6.IPv4 Datagram
format
IPv4 Datagram Format
An IPv4 datagram is a packet of data sent over a network. It has
a header (important information) and data (the actual message).

Main Parts of the Header:

1.Version (4 bits) – Tells if it's IPv4 or another version.


2.Header Length (4 bits) – Size of the header.
3.Type of Service (8 bits) – Defines priority of the packet.
4.Total Length (16 bits) – Total size of the packet (header +
data).
5.Identification (16 bits) – Helps in reassembling fragmented
packets.
6.Flags (DF, MF) & Fragment Offset (13 bits) – Used for
breaking large packets into smaller ones.
7.Time to Live (8 bits) – Limits the packet's lifespan to avoid
endless looping.
8.Protocol (8 bits) – Identifies the transport protocol (e.g., TCP,
UDP).
9.Header Checksum (16 bits) – Ensures data integrity.
10.Source IP Address (32 bits) – Address of the sender.
11.Destination IP Address (32 bits) – Address of the receiver.
IP fragmentation
Why is fragmentation
needed?
• Network links have a size
limit (MTU – Maximum
Transfer Unit).
• If a data packet is too big, it fragmentation:


must be broken into in: one large datagram
smaller parts. out: 3 smaller datagrams
How does it work?
1.A large IP packet is split
into smaller packets
(fragments). reassembly
2.These fragments travel
separately through the
network.
3.At the final destination, …
the fragments are
reassembled into the
original packet.
4.Special header bits help to
identify and order the
fragments correctly.
IP fragmentation Example

length ID fragflag offset


example: =4000 =x =0 =0
 4000 byte
datagram one large datagram becomes
several smaller datagrams
 MTU = 1500
bytes
1480 bytes in length ID fragflag offset
data field =1500 =x =1 =0

offset = length ID fragflag offset


1480/8 =1500 =x =1 =185

length ID fragflag offset


=1040 =x =0 =370
Why does fragmentation happen?

•The original data packet is too large (4000


bytes).
•The network can only handle 1500 bytes at a
time.

✔ What happens?

1.The large 4000-byte packet is split into smaller


packets.
2. Each small packet carries 1480 bytes of data
(rest is the header).
3.Packets are labeled with ID, flag, and offset to
help reassemble them.
4.The last packet is smaller (1040 bytes) since it
carries the remaining data.
The receiver puts them back together to form the
IP Address
✔ What is an IP Address?
• An IP address helps identify devices in a network.
• It is a 32-bit number divided into 4 parts (octets).
✔ How does it work?
• Each octet is 8 bits long and is written in decimal format.
• Example: 172.16.254.1 (from binary to decimal).

10101100 00010000 11111110 00000001

172 16 254 1
• ✔ IP Address Structure
Divided into 2 parts:
1. Network ID (NID) → Identifies the network.
2.Host ID (HID) → Identifies the device in that network.
IP Address = Network ID + Host ID
IP Addressing - Example
• IP address: It is 32-bit 223.1.1.1
identifier for host, router
interface 223.1.1.2
223.1.2.1

223.1.1.4 223.1.2.9

• Interface: It is a connection
between host/router and 223.1.3.27
physical link. 223.1.1.3
223.1.2.2

• A router’s typically have multiple


interfaces
• A host typically has one or two
223.1.3.1 223.1.3.2
interfaces

• IP addresses associated with


each interface.
223.1.1.1 = 11011111 00000001 00000001 00000001

223 1 1 1
Interface Example
223.1.1.1
Q: how are interfaces actually
connected? 223.1.2.1

223.1.1.2
223.1.1.4 223.1.2.9

223.1.3.27
223.1.1.3
223.1.2.2

A: wired Ethernet interfaces


connected by Ethernet switches
223.1.3.1 223.1.3.2

A: wireless WiFi interfaces


connected by WiFi base station
Classification of IP Addresses (Classful
Addressing)
Class: A
0

7 Bit 24 Bit
Fix Network ID Host ID
Class: B
1 0

Fix 14 Bit 16 Bit


Network ID Host ID
Class: C
1 1 0

Fix 21 Bit 8 Bit


Network ID Host ID
Class: D
1 1 1 0

Fix
Class: E Multicast address
1 1 1 1

Fix Reserved address


Subnet
• Subnet: high order bits defines 223.1.1.0/24
subnet 223.1.2.0/24
223.1.1.1
• Host: low order bits defines host
223.1.1.2 223.1.2.1
• Subnet : 223.1.1.4 223.1.2.9
• device interfaces with same subnet part
of IP address 223.1.2.2
223.1.1.3 223.1.3.27
• can physically reach each other without
intervening router subnet
• https://www.youtube.com/
watch?v=OqsXzkXfwRw 223.1.3.1 223.1.3.2

223.1.3.0/24

Network consisting of 3 subnets


To determine the subnets,
detach each interface from 223.1.1.0/24
its host or router, creating 223.1.2.0/24
223.1.1.1
islands of isolated networks
223.1.1.2 223.1.2.1
each isolated network is 223.1.1.4 223.1.2.9

called a subnet 223.1.2.2


223.1.1.3 223.1.3.27

subnet

223.1.3.1 223.1.3.2

223.1.3.0/24
Type of addresses in IPv4 Network
• Network address - The address by which we refer to the network.
• E.g.: 10.0.0.0

• Broadcast address - A special address used to send data to all


hosts in the network.
• The broadcast address uses the highest address in the network range.
• E.g.: 10.0.0.255

• Host addresses - The addresses assigned to the end devices in the


network.
• E.g.: 10.0.0.1
Type of addresses
IP addressing: CIDR

CIDR: Classless InterDomain Routing


 subnet portion of address of arbitrary length

 address format: a.b.c.d/x, where x is # bits in subnet portion of address

subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23
Classless Inter-Domain Routing(CIDR)
• CIDR is a slash notation of subnet mask. CIDR tells us number of
on bits in a network address.

subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23
• A single IP address can be used to designate many unique IP
addresses with CIDR.

• A CIDR IP address looks like a normal IP address except that it


ends with a slash followed by a number, called the IP network
prefix.

• CIDR addresses reduce the size of routing tables and make more IP
addresses available within organizations.
Subnetting
• Subnetting take places when we extend the default subnet mask.

• We cannot perform subnetting with default subnet mask and every


classes have default subnet mask.

• Now find the host bits borrowed to create subnets and convert them
in decimal.

• For example find the subnet mask of address 188.25.45.48/20 ?


1. Class B, Default Subnet mask: 255.255.0.0
2. Borrowed 4 bit from host part so mask is now:
11111111 11111111 11110000 00000000
255 255 240 0
How many subnets from given subnet mask?
• To calculate the number of subnets provided by given subnet mask
we use 2N , where N = number of bits borrowed from host bits to
create subnets.

• For example in 192.168.1.0/27, N is 3.

• By looking at address we can determined that this address is belong


to class C and default subnet mask 255.255.255.0 [/24 in CIDR].

• In given address we borrowed 27 - 24 = 3 host bits to create


subnets.

• Now 23 = 8, so our answer is 8.


What are the valid subnets?
• Calculating valid subnet is two steps process.

• First calculate total subnet by using formula 2N.

• In second step find the block size and count from zero in block until
subnet mask value.

• For example calculate the valid subnets for 192.168.1.0/26


1. Borrowed host bits are 2 [26-24]
2. Total subnets are 22 = 4
3. Subnet mask would be 255.255.255.192
4. Block size would be 256-192 = 64
5. Start counting from zero at blocks of 64, so our valid subnets would be
0,64,128,192
What are the total hosts?
• Total hosts are the hosts available per subnet

• To calculate total hosts use formula 2H = Total hosts

• H is the number of host bits

• For example in address 192.168.1.0/26

• We have 32 - 26
1. [Total bits in IP address - Bits consumed by network address] = 6
2. Total hosts per subnet would be 26 = 64
Network Prefixes
• For Class C, Default subnet mask of class C is 255.255.255.0

• CIDR notation of class C is /24, which means 24 bits from IP


address are already consumed by network portion. We have 8
host bits remain.

• Subnetting moves from left to right. So Class C subnet masks


can only be the following:
CIDR Decimal Binary
/25 128 10000000

/26 192 11000000

/27 224 11100000

/28 240 11110000

/29 248 11111000

/30 252 11111100


Dynamic Host Configuration Protocol - DHCP
• Dynamic Host Configuration Protocol is a protocol for assigning
dynamic IP addresses to devices on a network.

DHCP
223.1.1.0/24
server
223.1.1.1 223.1.2.1

223.1.1.2 arriving DHCP


223.1.1.4 223.1.2.9
client needs
address in this
223.1.3.27
223.1.2.2 network
223.1.1.3

223.1.2.0/24

223.1.3.1 223.1.3.2

223.1.3.0/24
• With dynamic addressing, a device can have a different IP address
every time it connects to the network.

• In some systems, the device's IP address can even change while it


is still connected.

• It allows reuse of addresses (only hold address while connected


“on”).

• It also support mobile users who want to join network.


DHCP Client Server Interaction

DHCP server: 223.1.2.5 DHCP discover arriving


client
src : 0.0.0.0, 68
Broadcast: is there a
dest.: 255.255.255.255,67
DHCP server
yiaddr: 0.0.0.0out
transaction
there?ID: 654

DHCP offer
src: 223.1.2.5, 67
Broadcast: I’m a DHCP
dest: 255.255.255.255, 68
server!
yiaddrr:Here’s
223.1.2.4an IP
transaction
address youID:can
654 use
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
Broadcast: OK. I’ll
yiaddrr: 223.1.2.4
take that IPID:address!
transaction 655
lifetime: 3600 secs

DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255,
Broadcast: 68
OK. You’ve
yiaddrr: 223.1.2.4
gottransaction
that IPID:address!
655
lifetime: 3600 secs
DHCP: More than IP addresses
DHCP can return more than just allocated IP address on subnet:
 address of first-hop router for client

 name and IP address of DNS sever

 network mask (indicating network versus host portion of address)


DHCP: example

DHCP DHCP connecting laptop needs


UDP
DHCP
DHCP IP
its IP address, addr of first-
DHCP Eth hop router, addr of DNS
Phy server: use DHCP
DHCP
 DHCP request

encapsulated in UDP,
DHCP DHCP 168.1.1.1 encapsulated in IP,
DHCP UDP encapsulated in 802.1
DHCP IP  Ethernet frame
DHCP Eth router with DHCP
Phy server built into broadcast (dest:
router FFFFFFFFFFFF) on LAN,
received at router
running DHCP
 Ethernet demuxedserver to
IP demuxed, UDP
demuxed to DHCP
DHCP DHCP • DCP server formulates DHCP
DHCP UDP ACK containing client’s IP
DHCP IP address, IP address of first-
DHCP Eth hop router for client, name
Phy & IP address of DNS server

 encapsulation of
DHCP DHCP DHCP server, frame
DHCP UDP forwarded to client,
DHCP IP demuxing up to
Eth router with DHCP
DHCP
DHCP at client
DHCP
Phy server built into  client now knows its
router IP address, name
and IP address of
DSN server, IP
address of its first-
hop router
Network Address Translation
• NAT is a method that is used to translate Private IP addresses to
Public IP addresses.
rest of local network
Internet (e.g., home network)
10.0.0/24 10.0.0.1

10.0.0.4
10.0.0.2
138.76.29.7

10.0.0.3

all datagrams leaving local


network have same single datagrams with source or
source NAT IP address: destination in this network
138.76.29.7,different source have 10.0.0/24 address for
port numbers source, destination (as usual)
• Local network uses just one IP address as far as outside world is
concerned.

• This means that only a single, unique IP address is required to


represent an entire group of computers.

• The technique was originally used for ease of rerouting traffic in


IP networks without readdressing every host.

• The concept of NAT as developed to solve two problems:


• Solve shortage of IPv4 IP addresses
• To Hide the Network Address
NAT Terminology
• Inside Local Address: The name of the inside source address before
translation. This would be a Private IP.

• Inside Global Address: The name of the inside host after translation. This
would be the Public IP.

• Outside Local Address: The name of the destination host before translation.

• Outside Global Address: The name of the destination host after translation.

• Where:
• Global Addresses → Public
• Local Addresses → Private
• Inside Hosts → Within Local Network
• Outside Hosts → Outside Local Network
Implementation : NAT router must:

• outgoing datagrams: replace (source IP address, port #) of every outgoing datagram


to (NAT IP address, new port #)

. . . remote clients/servers will respond using (NAT IP address,


new port #) as destination addr
• remember (in NAT translation table) every (source IP address, port #) to (NAT IP
address, new port #) translation pair

• incoming datagrams: replace (NAT IP address, new port #) in dest fields of every
incoming datagram with corresponding (source IP address, port #) stored in NAT
table
NAT translation table 1: host 10.0.0.1
2: NAT router WAN side addr LAN side addr
changes datagram sends datagram to
source addr from 138.76.29.7, 5001 10.0.0.1, 3345 128.119.40.186, 80
10.0.0.1, 3345 to …… ……
138.76.29.7, 5001,
updates table S: 10.0.0.1, 3345
D: 128.119.40.186, 80
10.0.0.1
1
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4
10.0.0.2
138.76.29.7 S: 128.119.40.186, 80
D: 10.0.0.1, 3345
4
S: 128.119.40.186, 80
D: 138.76.29.7, 5001 3 10.0.0.3
4: NAT router
3: reply arrives changes datagram
dest. address: dest addr from
138.76.29.7, 5001 138.76.29.7, 5001 to 10.0.0.1, 3345
Internet Control Message Protocol - ICMP
• When something unexpected occurs, the event is reported by the
ICMP, which is also used to test the Internet.

• Some of the ICMP messages are defined and are listed below.
Each ICMP message type is encapsulated in an IP packet.

Message Type Description


Destination unreachable Packet could not be delivered
Time exceeded Time to live field hit 0
Parameter problem Invalid header field
Source quench Choke packet
Redirect Teach a router about geography
Echo Ask a machine if it is alive
Echo reply Yes, I am alive
Timestamp request Same as Echo request, but with timestamp
Timestamp reply Same as Echo reply, but with timestamp
IPv6: motivation
• Initial motivation: 32-bit address space soon to be completely
allocated.

• additional motivation:
• header format helps speed processing/forwarding
• header changes to facilitate QoS

IPv6 datagram format:


• fixed-length 40 byte header
• no fragmentation allowed
IPv6 Datagram Format
• Version: The size of the Version field is 4 bits. The Version field shows the
version of IP and is set to 6.

• Traffic Class:
• The size of Traffic Class field is 8 bits. Traffic Class field is similar to the IPv4 Type
of Service (ToS) field.
• The Traffic Class field indicates the IPv6 packet’s class or priority.

• Flow Label:
• The size of Flow Label field is 20 bits.
• The Flow Label field provide additional support for real-time datagram delivery and
quality of service features.
• The purpose of Flow Label field is to indicate that this packet belongs to a specific
sequence of packets between a source and destination and can be used to prioritized
delivery of packets for services like voice.
• Payload Length: The size of the Payload Length field is 16 bits. The Payload
Length field shows the length of the IPv6 payload, including the extension
headers and the upper layer protocol data

• Next Header: The size of the Next Header field is 8 bits. The Next Header
field shows either the type of the first extension (if any extension header is
available) or the protocol in the upper layer such as TCP, UDP, or ICMPv6.

• Hop Limit: The size of the Hop Limit field is 8 bits The Hop Limit field shows
the maximum number of routers the IPv6 packet can travel. This Hop Limit
field is similar to IPv4 Time to Live (TTL) field.

• Source Address: The size of the Source Address field is 128 bits. The Source
Address field shows the IPv6 address of the source of the packet.
Difference between IPv4 & IPv6
IPv4 IPv6
 32 bit length  128 bit length
 Fragmentation is done by sender  Fragmentation is done only by sender
and forwarding routers
 No packet flow identification  Packet flow identification is available within
the IPv6 header using the Flow Label field
 Checksum field in header  No checksum field in header
 Options fields are available in  No option fields, but Extension headers are
header available
 Address Resolution Protocol (ARP)is  Address Resolution Protocol (ARP) is
available to map IPv4 addresses replaced with Neighbor Discovery Protocol
to MAC addresses

 Broadcast messages are available  Broadcast messages are not available


 Static IP addresses or DHCP is  Auto-configuration of addresses is available
required to configure IP addresses
Routing Algorithms
• Routing algorithms, operating in network routers, exchange and
compute the information that is used to configure these
forwarding tables.

• The purpose of a routing algorithm is then simple: given a set of


routers, with links connecting the routers, a routing algorithm
finds a “good” path from source router to destination router.

• Typically, a good path is one that has the least cost.


Graph : Formulating Routing Problems
• Graph G = (N,E) is a set N of nodes and a collection E of edges,
where each edge is a pair of node from N.

• Wrt network-layer routing-


• the nodes in the graph represent routers—the points at which packet-forwarding
decisions are made—and
• the edges connecting these nodes represent the physical links between these routers.

• As shown in Figure , an edge also has a value representing its cost.

• Typically, an edge’s cost may reflect the physical length of the


corresponding link , the link speed, or the monetary cost associated
with a link.
Routing algorithm classification
First way
1. global:
• all routers have complete topology, link cost info
• “link state” algorithms

2. decentralized:
• router knows physically-connected neighbors, link costs to
neighbors
• iterative process of computation, exchange of info with neighbors
• “distance vector” algorithms
Second way
1. Static:
routes change slowly over time

2. Dynamic:
routes change more quickly
 periodic update
 in response to link cost changes
Third way
1. Load-sensitive algorithm
• In link costs vary dynamically to reflect the current level of
congestion in the underlying link.
• If a high cost is associated with a link that is currently congested,
a routing algorithm will tend to choose routes around such a
congested link.

2. Load-insensitive :
• Today’s Internet routing algorithms (such as RIP, OSPF, and BGP)
are load-insensitive, as a link’s cost does not explicitly reflect its
current (or recent past) level of congestion.
Link State Routing Algorithm
• Also known as Dijkstra’s Algorithm.

• It computes the least-cost path from one node (source node) to all
other nodes in the network.

• Its iterative and after the kth least-cost paths are known to k
destination nodes.

• Notation:
• c(x,y): link cost from node x to y; = ∞ if not direct neighbours
• D(v): current value of cost of path from source to destination v
• p(v): predecessor node along path from source to v
• N': set of nodes whose least cost path definitively known
Basics of Dijkstra's Algorithm
• Dijkstra's Algorithm basically starts at the node that you choose (the source
node) and it analyses the graph to find the shortest path between that node
and all the other nodes in the graph.

• The algorithm keeps track of the currently known shortest distance from each
node to the source node and it updates these values if it finds a shorter path.

• Once the algorithm has found the shortest path between the source node and
another node, that node is marked as "visited" and added to the path.

• The process continues until all the nodes in the graph have been added to the
path. This way, we have a path that connects the source node to all other
nodes following the shortest path possible to reach each node.
Dijkstra’s Algorithm

1 Initialization:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) = ∞
7
8 Loop
9 find w not in N' such that D(w) is a minimum
10 add w to N'
11 update D(v) for all v adjacent to w and not in N' :
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'
Dijkstra’s Algorithm – Example:1
D(v) D(w) D(x) D(y) D(z)
Step N' p(v) p(w) p(x) p(y) p(z)
0 u 7,u 3,u 5,u ∞ ∞
1 uw 6,w 5,u 11,w ∞
2 uwx 6,w 11,w 14,x
3 uwxv 10,v 14,x
x
4 uwxvy 12,y 9
5 uwxvyz
5 7
4
notes: 8
 construct shortest path 3
tree by tracing u w y z
2
predecessor nodes
 ties can exist (can be 3
broken arbitrarily) 7 4
v
Dijkstra’s Algorithm – Example:2

Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z)


0 u 2,u 5,u 1,u ∞ ∞
1 ux 2,u 4,x 2,x ∞
2 uxy 2,u 3,y 4,y
3 uxyv 3,y 4,y
4 uxyvw 4,y
5 uxyvwz

5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
Distance Vector Algorithm
• Distance-vector (DV) algorithm is iterative, asynchronous, and
distributed.

• It is distributed in that each node receives some information from


one or more of its directly attached neighbours, performs a
calculation, and then distributes the results of its calculation back
to its neighbours.

• It is iterative. so, process continues on until no more information is


exchanged between neighbours.

• The algorithm is asynchronous. It does not require all of the nodes


to operate with each other.
• Let dx(y) be the cost of the least-cost path from node x to node y.

• Then least costs are related by the celebrated Bellman-Ford


equation:
dx(y) = cost of least-cost path from x to y then

dx(y) = min
v
{c(x,v) + d v(y) }

cost from neighbor v to destination


cost to neighbor v

min taken over all neighbors v of x


iterative,
asynchronous: each
local iteration
caused by: each node:
 local link cost
change wait for (change in local link cost
or message from neighbor)
 DV update message
from neighbor
distributed: recompute estimates
 each node notifies
neighbors only when if DV to any destination has
its DV changes changed, notify neighbors
neighbors then
notify their
neighbors if
necessary
Distance Vector Algorithm - Example
node x cost to cost to
table x y z x y z
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
x 0 2 7 x 0 2 3
= min{2+0 , 7+1} = 2

from
from

y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0
Dx(z) = min{c(x,y) +
node y cost to
table x y z Dy(z), c(x,z) + Dz(z)}
x ∞ ∞ ∞ = min{2+1 , 7+0} = 3
y 2 0 1
from

z ∞∞ ∞
y
2 1
node z cost to
table x y z x z
7
x ∞∞ ∞
from

y ∞∞ ∞
z 7 1 0
time
Distance Vector Algorithm - Example
node x cost to cost to cost to
table x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3

from
from

y ∞∞ ∞ y 2 0 1 y 2 0 1

from
y
z ∞∞ ∞ z 7 1 0 z 3 1 0 2 1

node y cost to
x z
cost to cost to 7
table x y z x y z x y z
x ∞ ∞ ∞ x 0 2 7 x 0 2 3
from

y 2 0 1 y 2 0 1
from

y 2 0 1

from
z ∞∞ ∞ z 7 1 0 z 3 1 0

node z cost to cost to cost to


table x y z x y z x y z

x ∞∞ ∞ x 0 2 7 x 0 2 3
from

from

y 2 0 1 y 2 0 1
from

y ∞∞ ∞
z 7 1 0 z 3 1 0 z 3 1 0
time
Difference: LS and DV Routing Algorithm
Distance Vector Protocol Link State Protocol
Entire routing table is sent as an update Updates are incremental & entire routing table is
not sent as update
Distance vector protocol send periodic Updates are triggered not periodic
update at every 30 or 90 second
Update are broadcasted Updates are multicasted

Updates are sent to directly connected Update are sent to entire network & to just
neighbour only directly connected neighbour
Routers don't have end to end visibility Routers have visibility of entire network of that
of entire network. area only.
It is prone to routing loops No routing loops
Hierarchical Routing
• As networks grow in size, the router routing tables grow
proportionally.

• Router memory, CPU time and more bandwidth consumed to send


status reports about them.

• When hierarchical routing is used, the routers are divided into


what called regions.

• Each router knowing all the details about how to route packets to
destinations within its own region.

• But knowing nothing about the internal structure of other regions.


• LS and DV algorithms are viewed as the network simply as a
collection of interconnected routers.

• One router was indistinguishable from another in the sense that all
routers executed the same routing algorithm to compute routing
paths through the entire network.

• In practice, this model and its view of a homogenous set of routers


all executing the same routing algorithm is a bit simplistic for at
least two important reasons:
1. Scale :
• As the number of routers becomes large, the overhead involved in
computing, storing, and communicating routing information.

• As networks grow in size, the router routing tables grow proportionally.

• Clearly something must be done to reduce the complexity of route


computation in networks as large as the public Internet.

• Not only is router memory consumed by ever-increasing tables, but more


CPU time is needed to scan them and more bandwidth is needed to send
status reports about them.

• At a certain point the network may grow to the point where it is no longer
feasible for every router to have an entry for every other router, so the
routing will have to be done hierarchically, as it is in the telephone
network.
2. Administrative autonomy.
• Although researchers tend to ignore issues such as a company’s
desire to run its routers as it pleases (for example, to run whatever
routing algorithm it chooses) or to hide aspects of its network’s
internal organization from the outside, these are important
considerations.
• Ideally, an organization should be able to run and administer its
network as it wishes, while still being able to connect its network
to other outside networks.

Both of these problems can be solved by organizing routers into


autonomous systems (ASs), with each AS consisting of a group of
routers that are typically under the same administrative control
(e.g., operated by the same ISP or belonging to the same company
network).
• Routers within the same AS all run the same routing algorithm (for
example, an LS or DV algorithm) and have information about each
other.
• The routing algorithm running within an autonomous system is
called an intra-autonomous system routing protocol.

• It will be necessary, of course, to connect ASs to each other, and


thus one or more of the routers in an AS will have the added task of
being responsible for forwarding packets to destinations outside the
AS; these routers are called gateway routers.

• When hierarchical routing is used, the routers are divided into what
called regions, with each router knowing all the details about how
to route packets to destinations within its own region, but knowing
nothing about the internal structure of other regions.
• Both of these problems can be solved by organizing routers into
autonomous systems (ASs), with each AS consisting of a group of
routers that are typically under the same administrative control
(e.g., operated by the same ISP or belonging to the same company
network).

• Routers within the same AS all run the same routing algorithm (for
example, an LS or DV algorithm)

• The routing algorithm running within an autonomous system is


called an intra-autonomous system routing protocol.

• To connect ASs to each other, and thus one or more of the routers in
an AS will have the added task of being responsible for forwarding
packets to destinations outside the AS; these routers are called
gateway routers.
• When hierarchical routing is used, the routers are divided into what called
regions, with each router knowing all the details about how to route packets
to destinations within its own region, but knowing nothing about the
internal structure of other regions.

• Figure below provides a simple example with three ASs: AS1, AS2, and AS3.

• In figure, the heavy lines represent direct link connections between pairs of
routers.

• The thinner lines hanging from the routers represent subnets that are
directly connected to the routers.
Interconnected ASes

3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d forwarding table
configured by both intra-
and inter-AS routing
Intra-AS
Routing
Inter-AS
Routing
algorithm
algorithm algorithm  intra-AS sets entries for internal
dests
Forwarding  inter-AS & intra-AS sets entries
table
for external dests
Inter-AS tasks
suppose router in AS1 AS1 must:
receives datagram destined 1. learn which dests are
outside of AS1: reachable through AS2,
 router should forward packet to
gateway router, but which one?
which through AS3
2. propagate this
reachability info to all
routers in AS1
job of inter-AS routing!
3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Hierarchical Routing - Example
THANK YOU

You might also like