You are on page 1of 80

The Network Layer

Layer 3
The Network Layer
• Fundamental function
• transport packet from sending to receiving hosts

• Addressing
• Uniquely identify each node in the network
• Routing
• Determine a path from source to destination and route packets along that path
Network layer functions
Protocol layering and data
• Each layer takes data from above
• Adds a header to create a new data unit
• Passes new data unit to the layer below
IP Protocol
IP connectionless
IP –Best effort delivery
IP encapsulation
IP addressing - Introduction

• IP address: an identifier for host,


router interface
• Interface: connection between
host/router and physical link
• router’s typically have multiple
interfaces
• host typically has one or two
interfaces (e.g., wired Ethernet,
wireless 802.11)
• IP addresses are associated with
each interface
IANA-Internet Assigned Numbers Authority
IP addresses
• Internet connected networks use two types of IP Addressing
– IPv4 – legacy Internet protocol
– IPv6 – new Internet protocol
• IPv4 addresses are 32 bits
• IPv6 addresses are 128 bits
• How many unique addresses in total?
IPv4
• 32-bit binary number
– 232 which is 4,294,967,296 addresses
• Conventionally represented as four dotted decimal octets

• Explain why 19 = 00010011 in binary ?


Prefixes
• A range of IP addresses is given as a prefix, e.g.192.0.2.128/27

• Prefix calculation

• Prefix length /27 -> First 27 bits are fixed


Netmask
• Netmask is just an alternative (old) way of writing the prefix
length
• A '1' for a prefix bit and '0' for a host bit
• Hence N x 1's followed by (32-N) x 0's

/27
IPv4 golden rules
1. All hosts on the same L2 network must share the same prefix
2. All hosts with the same prefix have different host part
3. Host part of all-zeros and all-ones are reserved

For the network, 192.0.2.128/27


• Lowest 192.0.2.128 = network address

• Highest 192.0.2.159 = broadcast address

• Usable: 192.0.2.129 to 192.0.2.158

• Number of usable addresses: 32 - 2 = 30


IPv4 address classes
Private address space
• Class A 10.0.0.0 to 10.255.255.255
• Class B 172.16.0.0 to 172.31.255.255
• Class C 192.168.0.0 to 192.168.255.255

Default subnet Masks


• Class A 255.0.0.0
• Class B 255.255.0.0
• Class C 255.255.255.0
IPv4 address classes
• Class A, Class B, Class C terminology and restrictions are now
of historical interest only
Obsolete since 1994
Internet routing and address management today is classless
• CIDR = Classless Inter-Domain Routing
Routing does not assume that former class A, B, C addresses imply
prefix lengths of /8, /16, /24
• VLSM = Variable-Length Subnet Masks
Routing does not assume that all subnets are the same size
Exercise

1. Network 10.10.10.0/25
• How many addresses in total?
• How many usable addresses?
• What are the lowest and highest usable addresses?

2. Network 10.10.20.0/22
• How many addresses in total?
• How many usable addresses?
• What is the lowest and highest usable addresses?
IPv6 Addresses

• 128-bit binary number


– How many unique addresses in total?
– 3.402823669209 x1038
• Conventionally represented in hexadecimal – 8 words of 16 bits,
separated by colons e.g.
2607:8400:2880:0004:0000:0000:80DF:9D13
• Leading zeros can be dropped
• The right-most contiguous run of all-zero words can be replaced
by "::“
2607:8400:2880:4::80DF:9D13
IPv6
• Larger address space
• IPv6 addresses are 128 bits, compared to IPv4’s 32 bits.
• There are enough IPv6 addresses to allocate more than the entire IPv4 Internet
address space to everyone on the planet.
• Elimination of public-to-private NAT
• End-to-end communication traceability is possible.
• Elimination of broadcast addresses
• IPv6 now includes unicast, multicast, and anycast addresses.
• Support for mobility and security
• Helps ensure compliance with mobile IP and IPsec standards.
• Simplified header for improved router efficiency
Is IPv4 obsolete?
• IPv4 is in no danger of disappearing overnight.
• It will coexist with IPv6 and then gradually be replaced.
• IPv6 provides many transition options including:
• Dual stack:
• Both IPv4 and IPv6 are configured and run simultaneously on the interface.
• IPv6-to-IPv4 (6to4) tunneling and IPv4-compatible tunneling.
• NAT protocol translation (NAT-PT) between IPv6 and IPv4.
• This is also know as translation
IPv6 header versus IPv4 header
Network Address Translation
NAT - Motivation
• Local network uses just one public IP address as far as outside world is
concerned:
• Range of addresses not needed from ISP: just one IP address for all devices.

• Can change addresses of devices in local network without notifying


outside world
• Can change ISP without changing addresses of devices in local network
• Devices inside a local network are not explicitly addressable, visible by
outside world (a security plus)
Subnetting
• You might want to take one big network and create different
smaller networks from it.

• To achieve this, you have to perform subnetting.

• Since each L2 network needs its own prefix, then if you route
more than one network you need to divide your allocation

• Ensure each prefix has enough IPs for the number of hosts on
that network
Subnetting example

• You have been given 192.0.2.128/27


• However you want to build two Layer 2 networks and route
between them
• The Golden Rules demand a different prefix for each network
• Let's split this address space into two equal sized pieces
Check correctness
• Expand each new prefix into lowest and highest
• Ranges should not overlap
– 192.0.2.128/28
• Lowest (network) = 192.0.2.128
• Highest (broadcast) = 192.0.2.143
– 192.0.2.144/28
• Lowest (network) = 192.0.2.144
• Highest (broadcast) = 192.0.2.159
– How many usable addresses now?
Subnet Design Consideration
• How many total subnets does the organization need today?
• How many subnets will the organization need in future?
• How many hosts are on the organization’s largest subnet
today?
• How many hosts will be on the organization’s largest subnet in
future?
Design Steps
• Take largest number of subnets and round up to the nearest power
of 2
– e.g. 9 subnets 8 (2^3)is small 16 (2^4)is best
• Allow adequate room for growth
• Ensure that there are enough host addresses for the
organizations subnet.
• e.g. 50 hosts (2^5)//(2^6)
• Address allocation
Example
• An organization is assigned the network number 193.1.1.0/24
and it needs to define six subnets. The largest subnet is
required to support 25 hosts.
Defining the Subnet Mask/Extended
Prefix Length
• Determine the number of bits required to define the six subnets.

• Since a network address can only be subnetted along binary


boundaries, subnets must be created in blocks of powers of two
[2(2^1), 4 (2^2), 8 (2^3), 16 (2^4), and so on].

• We can not define exactly 6 subnets.

• Hence we use 8 and reserve the excess 2 subnets for future use.
Cont’d
• Since 8 = 2^3 hence 3 bits are required to enumerate the 8
subnets.
• Hence from the /24 bits it will need /27bits
• 27 bits can be denoted as 255.255.255.224
Defining the subnet
• A /27 bit network prefix leaves 5 bits to define the hosts

• This means that each subnetwork with a 27 bit prefix represents


a contiguous block of 25(32) individual IP addresses.

• However, since the all addresses all 0’s and all 1’s cannot be
allocated, there are 30

• (32‐2) assignable host addresses on each subnet.


Defining the subnets
• The 8 subnets will be numbered 0 through to 7.
• Using 3 bit binary representation the subnets would be represented
by 0 (000 ), 1 (001 ), 2 (010), 3 (011 ), 4 (100 ), 5 (101 ), 6 (110 ), and
7 (111 )
Question
• An organization is assigned the network number 140.25.0.0/16
and it must create a set of subnets that supports up to 60 hosts
on each subnet.
• What are the subnets that will be created from the network?
Communication Between Subnets
• A router is necessary for devices on different networks and subnets to
communicate.
• Each router interface must have an IPv4 host address that belongs to
the network or subnet to that the router interface is connected.
• Devices on a network and subnet use the router interface attached to
their LAN as their default gateway.
• Devices on a network and subnet use the router interface attached to
their LAN as their default gateway.
• Devices on a network and subnet use the router interface attached to
their LAN as their default gateway.
Homework
• In an IPv4 network, the hosts can communicate one of three
different ways:
• Unicast
• Broadcast
• Multicast

• Read about each of these and how they work.


Routing and Forwarding
• Routing is not the same as Forwarding
• Routing is the building of maps and giving directions
• Each routing protocol usually has its own routing database
• Routing protocols populate the forwarding table
• Forwarding is passing the packet to the next hop device
• Forwarding table contains the best path to the next hop for each prefix
• There is only ONE forwarding table
Routing
• Routing is done based on destination IP address.

• Without routing, an interface can only reach destinations that


are on it’s local network segment.

• A device with at least 2 interfaces can route


Forwarding is Hop by Hop

• Each router makes an independent decision, based on its own


forwarding table.

• Different routers have different forwarding tables and make


different decisions.

• Routers talk routing protocols to each other, to help update


routing information and forwarding tables.
Hop by Hop Forwarding
Forwarding
• The best way to reach a given prefix is stored in the
Forwarding Table
• Each packet's destination address is looked up to decide where
to send it next (the next hop)
Longest Prefix Rule
• If the destination matches multiple prefixes, the longest
prefix wins.
• Example: packet destination 10.10.1.1
Longest match- example
Router Functions
• Determine optimum routing paths through a network
• Lowest delay means shortest path
• Highest reliability
• Move packets through the network
• Determine destination address in packet
• Makes a decision on which port to forward the packet through
• Decision is based on the Routing Table
• Interconnected Routers exchange routing tables in order to
maintain a clear picture/map of the network
• In a large network, the routing table updates can consume a lot
of resources (CPU, memory, bandwidth)
• a protocol for route updates is required
Routing
• Static Routing
• This is the process of an administrator manually adding routes in each
router’s routing table. There are benefits and disadvantages to all
routing Processes
• Dynamic routing
• This is the process of routing protocols running on the router
communicating with neighbor routers. The routers then update each
other about all the networks they know about. If a change occurs in the
network, the dynamic routing protocols automatically inform all routers
about the change.
• Default routing
• This is used to send packets with a remote destination network not in
the routing table to the next hop router.
• You can only use default routing on stub networks, which means that
they have only one exit port out of the network.
Routes
• Static route
• Specifically instructs router on which route to take to a particular
destination network.
• This will almost always override anything else that the router knows.
• Dynamic route
• Learnt via routing protocols implemented on routers
• Default route
• Usually referred to as gateway of last resort
• Destination 0.0.0.0/0 or ::/0
• Matches every IP address
• But only when there is no better match (longer prefix) for that destination
Static routes
• Static routes are manually configured
• They define an explicit path between two networking devices.
• Static routes must be manually updated if the topology
changes.
• Their benefits include improved security and control of
resources.
• A default static route is used when the routing table does not
contain a path for a destination network.
Static Routing
Static Routing
Advantages
• No overhead on the router CPU
• Secure as only defined routes can be accessed
• Bandwidth is not used for sending routing updates

Disadvantages
• The administrator must really understand the internetwork and
how each router is connected to configure the routes correctly.
• Explicit addition of routes for all networks
• If one network is added to the internetwork, the administrator must add a route to
it on all routers.
• It’s not feasible in large networks because it would be a full-time
job.
Dynamic routing
• Dynamic routing is used by routers to share information about
the reachability and status of remote networks.
• It performs network discovery and maintains routing tables

• Advantages of dynamic routing include:


• Automatically share information about remote networks- suitable in
topologies where multiple networks are required.
• Determine the best path to each network and add this information to
their routing tables
• Requires less administrative overhead
• Disadvantages of dynamic routing include:
• Part of a router’s resources are dedicated for protocol operation,
including CPU time and network link bandwidth
• Less secure – additional configuration settings are required to secure.
• Route depends on current topology
Classifying Routing protocols
Interior and Exterior routing protocols

• An autonomous system is a collection of networks under one


administrative domain
• IGPs operate within the same autonomous system
• EGPs connect different autonomous systems
IGP Versus EGP

• Interior Gateway
Protocols (IGP) -
• Used for routing within an AS
• Include RIP, EIGRP, OSPF,
and IS-IS
• Exterior Gateway
Protocols (EGP) -
• Used for routing between AS
• Official routing protocol used
by the Internet
Routing Protocols
• Routing protocols are used between routers to determine and
paths and maintain routing tables.

• After a path is determined, a router can route a routed protocol.


Interior Gateway Protocols
Distance vector
• Each time a packet goes
through a router, it’s called a
hop.
• The route with the least number
of hops to the network is
determined to be the best
route.
• Examples of distance-vector
routing protocols are RIP and
IGRP
• Distance vector IPv4 IGPs:
 RIPv1 - First generation
legacy protocol • For R1, 172.16.3.0/24 is one
hop away (distance). It can be
 RIPv2 - Simple distance reached through R2 (vector).
vector routing protocol
Link state routing protocols
• Typically called shortest path first.

• Link-state routers know more about the internetwork than any distance-
vector routing protocol.

• Link state protocols forward updates when the state of a link changes

• Link-state IPv4 IGPs:


• Open Shortest Path First (OSPF) most popular
• began in 1987
• two current versions
• OSPFv2 - OSPF for IPv4 networks
• OSPFv3 - OSPF for IPv6 networks

• IS-IS was designed by International Organization for Standardization (ISO )


Link State Algorithm
• Each router contains a database containing a map of the whole
topology
• Links
• Their state (including cost)
• All routers have the same information
• All routers calculate the best path to every destination
• Any link state changes are flooded across the network
• “Global spread of local knowledge
Link State Routing
• Automatic neighbor discovery
• Neighbors are physically connected routers
• Each router constructs a Link State Packet (LSP)
• Distributes the LSP to neighbors…
• …using an LSA (Link State Announcement)
• Each router computes its best path to every destination
• On network failure
• New LSPs are flooded
• All routers recompute routing table
Link state routing process
• Each router learns about each of it’s own directly connected
routes.
• Each router is responsible for “saying hello” to it’s neighbors on
directly connected routes.
• Each router builds a link state packet (LSP) containing the state
of each directly connected link.
• Each router floods the LSP to all it’s neighbors who then store
the received LSP in a database
• Each router uses the database to construct a complete map of
the topology and computes the best path to each destination
networks.
Interior Gateway Protocols
• Most Common examples
• RIP
• OSPF
RIP
• Included in BSD-UNIX distribution in 1982
• Distance vector algorithm
• distance metric: # hops (max = 15 hops), each link has cost 1
• DVs exchanged with neighbors every 30 sec in response message (aka
advertisement)
• each advertisement: list of up to 25 destination subnets (in IP addressing sense)

u v subnet hops
u 1
A B w
v 2
w 2
x x 3
z C D y 3
y z 2
OSPF
• Developed by IETF – RFC1247
• Designed for Internet TCP/IP environment
• OSPF v2 described in RFC2328/STD54
• For IPv4 only
• OSPF v3 described in RFC2740
• Mainly for IPv6
• Supports the IPv4 address family also
• Link state/Shortest Path First Technology
• Dynamic Routing
• Fast Convergence
• Route authentication
OSPF
• open”: publicly available
• uses link state algorithm
• LS packet dissemination
• topology map at each node
• route computation using Dijkstra’s algorithm
• OSPF advertisement carries one entry per neighbor
• advertisements flooded to entire AS
• carried in OSPF messages directly over IP (rather than TCP or UDP
• IS-IS routing protocol: nearly identical to OSPF
OSPF Advanced features- not RIP
• Security: all OSPF messages are authenticated (to prevent
malicious intrusion)
• Multiple same-cost paths allowed (only one path in RIP)
• Integrated uni- and multicast support:
• Multicast OSPF (MOSPF) uses same topology data base as
OSPF
• Hierarchical OSPF in large domains.
OSPF: How it works
• Hello Protocol
• Responsible for establishing and maintaining neighbor relationships
• Elects Designated Router on broadcast networks
OSPF: How it works
• Hello Protocol
• Hello Packets are sent periodically on all OSPF enabled interfaces
• Adjacencies formed between some neighbors.
• Hello Packet
• Contains information like Router Priority, Hello Interval, a list of known
neighbors, Router Dead Interval, and the network mask
• Trade Information using LSAs
• LSAs are added to the OSPF database
• LSAs are passed on to OSPF neighbors
• Each router builds an identical link state database
• SPF algorithm run on the database
• Forwarding table built from the SPF tree
OSPF: How it works
• When change occurs:
• Announce the change to all OSPF neighbors

• All routers run the SPF algorithm on the revised database

• Install any change in the forwarding table


Broadcast Networks
• These are network technologies such as Ethernet and FDDI
• Introduces Designated and Backup Designated routers (DR and
BDR)
• Only DR and BDR form full adjacencies with other routers
• The remaining routers remain in a “2-way” state with each other
• If they were adjacent, we’d have n-squared scaling problem
• If DR or BDR “disappear”, re-election of missing router takes place
Designated Router
• One per multi-access network
• Generates network link advertisements for the multi-access network

• Speeds database synchronization

• All routers are adjacent to the DR


• All routers are adjacent to the BDR also

• All routers exchange routing information with DR (..)


• All routers exchange routing information with the BDR

• DR updates the database of all its neighbours


• BDR updates the database of all its neighbours

• This scales! 2n problem rather than having an n-squared problem.


Designated Router

• Adjacencies only formed with DR and BDR


• LSAs propagate along the adjacencies
Designated Router Priority
• Determined by interface priority
• Otherwise by highest router ID
• (For Cisco IOS, this is address of loopback interface, otherwise highest
IP address on router)
Equal Cost Multipath

What happens when more than one routes have the same cost?
OSPF Areas
• Group of contiguous hosts and
networks
• Per area topological database
• Invisible outside the area
• Reduction in routing traffic
• Backbone area contiguous Area 2 Area 3
• All other areas must be connected to the
backbone Area 0
Backbone Area
• Virtual Links

Area 1
Area 4
OSPF Areas
• Reduces routing traffic in area 0
• Consider subdividing network into areas
• Once area 0 is more than 30+ routers (though areas with 200+ routers in an
area are known to work fine)
• Once area 0 topology starts getting complex
• Less often today but when a group of routers is over an expensive small link
e.g vsat
• Area design often mimics typical ISP core network design
• Virtual links are used for “awkward” connectivity topologies (…) please
do not use these.
OSPF Route Types

• Intra-Area route
• All routes inside an area
• Inter-Area route
• Routes advertised from one area to
another area by an ABR
• External route
• Routes imported into OSPF from another
routing protocol by an ASBR
Exterior Gateway Protocol
• BGP (Border Gateway Protocol): the de facto inter-domain
routing protocol
• “glue that holds the Internet together”
• BGP provides each AS a means to:
• eBGP: obtain subnet reachability information from neighboring ASs.
• iBGP: propagate reachability information to all AS-internal routers.
• determine “good” routes to other networks based on reachability
information and policy.
• allows subnet to advertise its existence to rest of Internet:
“I am here”

You might also like