You are on page 1of 54

Functions of Network Layer

IP(Internet Protocol)
• IP focuses on the job of routing data, in the form of IP packets, from the source
host to the destination host.
• IP does not concern itself with the physical transmission of data, instead relying on
the lower TCP/IP layers to do the physical transmission of the data.
• Instead, IP concerns itself with the logical details, rather than physical details, of
delivering data.
• In particular, the network layer specifies how packets travel end to end over a
TCP/IP network, even when the packet crosses many different types of LAN and
WAN links.
Network Layer Routing (Forwarding) Logic

• Routers and end-user computers (called hosts in a TCP/IP network) work together
to perform IP routing.
• The host operating system (OS) has TCP/IP software, including the software that
implements the network layer.
• Hosts use that software to choose where to send IP packets, often to a nearby
router. Those routers make choices of where to send the IP packet next.
Host Forwarding Logic: Send the Packet to the
Default Router
• In prior diagram, PC1 does some basic analysis, and then chooses to
send the IP packet to the router so that the router will forward the
packet.
• PC1 analyzes the destination address and realizes that PC2’s address
(168.1.1.1) is not on the same LAN as PC1.
• So PC1’s logic tells it to send the packet to a device whose job it is to
know where to route data: a nearby router, on the same LAN, called
PC1’s default router.
• To send the IP packet to the default router, the sender sends a data-
link frame across the medium to the nearby router; this frame
includes the IPpacket in the data portion of the frame.
• That frame uses data link layer (Layer 2) addressing in the data-link
header to ensure that the nearby router receives the frame.

• NOTE: The default router is also referred to as the default gateway.


R1 and R2’s Logic: Routing Data Across the Network

• Each router keeps an IP routing table. This table lists IP address


groupings, called IP networks and IP subnets.
• When a router receives a packet, it compares the packet’s destination
IP address to the entries in the routing table and makes a match.
• This matching entry also lists directions that tell the router where to
forward the packet next.
• In the above diagram, R1 would have matched the destination
address (168.1.1.1) to a routing table entry, which in turn told R1 to
send the packet to R2 next.
• Similarly, R2 would have matched a routing table entry that told R2 to
send the packet, over an Ethernet over MPLS (EoMPLS) link, to R3
next.
R3’s Logic: Delivering Data to the End Destination

• The final router in the path, R3, uses almost the same logic as R1 and
R2, but with one minor difference. R3 needs to forward the packet
directly to PC2, not to some other router.
How Network Layer Routing Uses LANs and WANs

• Network layer ignores physical transmission but, it has to coordinate


DL and physical layer.
• The data link layer adds the appropriate header and trailer to the
packet, creating a frame, before sending the frames over each
physical network.
• Network Layer: “Send this packet to the specified next device...,”
• Data Link Layer: “Encapsulate the IP packet in a data-link frame and
transmit it.”
To synchronize the network layer functionality with Data Link Layer, ARP
protocol is used by routers to forward frames.
• Routing as covered so far has two main concepts:
1. The process of routing forwards Layer 3 packets, also called Layer 3
protocol data units (L3 PDU), based on the destination Layer 3 address in
the packet.
2. The routing process uses the data link layer to encapsulate the Layer 3
packets into Layer 2 frames for transmission across each successive data
link.
IP Addressing and How Addressing Helps IP Routing

• IP defines network layer addresses that identify any host or router


interface that connects to a TCP/IP network.
• The idea basically works like a postal address:TCP/IP groups IP
addresses together so that IP addresses used on the same physical
network are part of the same group.
• IP calls these address groups an IP network or an IP subnet.
• IP defines specific rules about which IP address should be in the same
IP network or IP subnet.
• Numerically, the addresses in the same group have the same value in
the first part of the addresses.
• For example, the previous diagrams could have used the following
conventions:
• Hosts on the top Ethernet: Addresses start with 10
• Hosts on the R1-R2 serial link: Addresses start with 168.10
• Hosts on the R2-R3 EoMPLS link: Addresses start with 168.11
• Hosts on the bottom Ethernet: Addresses start with 168.1
• A router can list one routing table entry for each IP network or
subnet, instead of one entry for every single IP address.
• The routing process also makes use of a 20-byte IPv4 header.
• The header lists a 32-bit source IP address, as well as a 32-bit
destination IP address.
Routing Protocols

• For routing logic to work on both hosts and routers, each needs to
know something about the TCP/IP internetwork.
• Hosts need to know the IP address of their default router so that
hosts can send packets to remote destinations.
• Routers, however, need to know routes so that routers know how to
forward packets to each and every IP network and IP subnet.
• Although a network engineer could configure (type) all the required
routes, on every router, most network engineers instead simply
enable a routing protocol on all routers.
• If you enable the same routing protocol on all the routers in a TCP/IP
internetwork, with the correct settings, the routers will send routing
protocol messages to each other.
• As a result, all the routers will learn routes for all the IP networks and
subnets in the TCP/IP internetwork.
Examples of Routing Protocols
• OSPF
• RIP
• BGP
IPv4 Addressing
• Rules for IP Addresses
• If a device wants to communicate using TCP/IP, it needs an IP
address.
• When the device has an IP address and the appropriate software
and hardware, it can send and receive IP packets.
• Any device that has at least one interface with an IP address can
send and receive IP packets and is called an IP host.
• IP addresses consist of a 32-bit number, usually written in dotted-
decimal notation (DDN).
• For example, 168.1.1.1 is an IP address written in dotted-decimal
form; the actual binary version is
10101000.00000001.00000001.00000001
• Each DDN has four decimal octets, separated by periods
• Because each octet represents an 8-bit binary number, the range of
decimal numbers in each octet is between 0 and 255, inclusive.
• For example, the IP address of 168.1.1.1 has a first octet of 168, the
second octet of 1, and so on.
• Each device can have multiple IP addreses
• Ex: Laptop with wired NIC and wireless NICs and routers have
different ports have separate IP addresses
Rules for Grouping IP Addresses
• IP networks/subnet has consecutive addresses.
• The addresses in a single IP network have the same numeric value in
the first part of all addresses in the network.
Two important facts about how IPv4 groups IP addresses:
• All IP addresses in the same group must not be separated from each
other by a router.
• IP addresses separated from each other by a router must be in
different groups. (go back to fig)
Class A, B, and C IP Networks
• The IPv4 address space includes all possible combinations of numbers
for a 32-bit IPv4 address.
• Literally 232 different values exist with a 32-bit number, for more than
4 billion different numbers.
• With DDN values, these numbers include all combinations of the
values 0 through 255 in all four octets: 0.0.0.0, 0.0.0.1, 0.0.0.2, and all
the way up to 255.255.255.255.
• IP standards first subdivide the entire address space into classes, as
identified by the value of the first octet.
1. Class A gets roughly half of the IPv4 address space, with all DDN
numbers that begin with first octet 1–126.
2. 127.0.0.0-127.0.255.255 is assigned as Localhost address(loopback)
3. Class B gets one-fourth of the address space, with all DDN numbers
that begin with first octet 128–191 inclusive.
4. Class C gets one-eighth of the address space, with all numbers that
begin with first octet 192–223.
IPV4 address space
The Actual Class A, B, and C IP Networks
Actual IP
Bit patterns for Class A,B,C
Sample Class A Address
Sample Class B Address
Sample Class C Address
Default Subnet mask
• Default subnet mask address says which part of ip address is host part and
network part.
• Class A-255.0.0.0
• Class B-255.255.0.0
• Class C-255.255.255.0

• 255 says it’s a network id, 0 says it’s a host id


IP Subnetting
• Subnetting defines methods of further subdividing the IPv4
address space into groups that are smaller than a single IP
network.
• Need of subnetting:
• Consider Class C Ip addressing in a company network total 254
hosts assigned with Ip address.
• But configuring those devices are degrade performance and router
maintaining devices.
• So subnet make network secure, reliable and efficient.
Subnetting Example
• Consider a office has 150 computers in Class C ip address space with
192.168.1.0. It has 12 depts namely manufacturing,sales,operations
etc. How much subnets to create?
• Total no hosts =254 so set of ip address would 192.168.1.1 to
192.168.1.254
• However only 150 computers are there.
• So we divide the network as 16 subnets But why?
• Rule: Total no of subnets=power of 2= 24 =16 i.e 4 is the no of bits
represent subnet mask value in hostid part.
• What is Subnet Mask?
• It is the total no of bits in ip address to represent subnet address.

• Lets say 192.168.1.0 network divided into 16 subnets. So in last


octet first four bits represent subnet address so let it be as
0000,0001,0010 etc upto 1111.
• 11000000. 10101000.00000001.00000000

• So the subnets have ip addresses as subnet address


• 192.168.1.0/28 192.168.1.16/28 192.168.1.32/28 etc till
192.168.1.240/28 are assigned address of routers of subnets.
• /28 represent total 28 bits are used to represent Subnet address in ip
address.
• Example : in Class C ip address first 3 octets represent network part
but now along with network address its also essential to know subnet
part so in our example first four bits represent subnet part. So total
no of bits to identify a host require both network part and subnet
part so 24+4=28 bits .
So What are IP addresses of subnet
192.168.1.0/28 ?
• 192.168.1.0
• 192.168.1.1
• 192.168.1.2 and so on….
• Last ip address in this subnet?
So What are IP addresses of subnet
192.168.1.16/28 ?
Classless Inter-Domain Routing(CIDR)
• Classful IP address assignment has disadvantage of wastage of ip
address.
• Previous example 254-150=96 address are unused/wasted.
• Classless Inter-Domain Routing is a method for allocating IP addresses
and for IP routing does not follow Classful IP addresses.
• Flexible to allocate ip addresses.
Example
• Consider a network of 32 hosts In classful Ip address class C ip
address can be used so 256 hosts are allocated. Default 24 bits
represent network address 8 bits represent hosts.
• But, only 32 hosts
• So,In CIDR 5 bits are enough to address hosts because 25 =32 hosts.
• So 27 bits are representing network address (default subnet mask). So
hosts has an ip address 192.168.1.1/27 to 192.168.1.32/27
from 192.168.1.33 onwards ip address could be assigned to other hosts
depending on network size.
What about network has 50 hosts?
Difference b/w Classful address and CIDR
• In classful ip 192.168.1.0/27, 192.168.1.32/27 are subnets.
• In CIDR ip 192.168.1.0/27, 192.168.1.32/27 are separate networks.
Variable Length Subnet Mask(VLSM)
• In Classful ip address subnets are created as per power of 2
• But assume Class C ip address with 150 hosts if you divide 16 subnets
each subnet has 16 hosts only but assume if one of subnet has 64
hosts then in this case VLSM is used.
• Let Ip address be 192.168.1.0 when divided into 16 subnets total 28
bits represent network address .
• But, in one subnet 64 hosts are there in that case 6 bits for host, 2
bits for subnet address so here total 26 bits represent network
address.
• So subnets are 192.168.1.0/26 , now rest 86 hosts are subnetted
using previous conventions so the next subnets are 192.168.1.64/28
and so on…

You might also like