NETWORK LAYER
DISCUSSION ON:
Addressing: IP addressing, Subnetting, NAT, Routing: techniques, static vs. dynamic routing, Unicast
Routing Protocols: RIP, OSPF, BGP; Other Protocols: ARP, RARP, IP, ICMP, IPv6; VPN.
First Address of Address Block
The first address in the block can be found by setting the rightmost 32 − n bits to 0s.
EXAMPLE
A block of addresses is granted to a small organization. We know that one of the addresses is 205.16.37.39/28. What is the first address in the block?
The binary representation of the given address is 11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 0, we get 11001101 00010000 00100101 0010000 or 205.16.37.32.
Last Address of Address Block
The last address in the block can be found by setting the rightmost 32 − n bits to 1s.
EXAMPLE
A block of addresses is granted to a small organization. We know that one of the addresses is 205.16.37.39/28. What is the last address in the block?
The binary representation of the given address is 11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 1, we get 11001101 00010000 00100101 00101111 or 205.16.37.47.
Number of Addresses of Address Block
The number of addresses in the block can be found by using the formula 2^(32-n)
EXAMPLE
A block of addresses is granted to a small organization. We know that one of the addresses is 205.16.37.39/28. What is the number of addresses of address block?
The value of n is 28, which means that number of addresses is 2^(32-28) or 16.
First Address
The first address can be found by ANDing the given addresses with the mask. ANDing here is done bit by bit. The result of ANDing 2 bits is 1 if both bits are 1s; the result is 0 otherwise.
Address: 11001101 00010000 00100101 00100111
Mask : 11111111 11111111 11111111 11110000
First Address: 11001101 00010000 00100101 00100000
Last Address
The last address can be found by ORing the given addresses with the complement of the mask. ORing here is done bit by bit. The result of ORing 2 bits is 0 if both bits are 0s; the result is 1 otherwise. The complement of a number is found by changing each 1 to 0 and each 0 to 1.
Address: 11001101 00010000 00100101 00100111
Mask Complement: 00000000 00000000 00000000 00001111
Last Address: 11001101 00010000 00100101 00101111
Number of Addresses
The number of addresses can be found by complementing the mask, interpreting it as a decimal number, and adding 1 to it.
Mask Complement: 00000000 00000000 00000000 00001111
Number of addresses: 15 + 1 = 16
****************************************************************************************************
ADDRESS MAPPING, ERROR REPORTING, AND MULTICASTING
ADDRESS MAPPING
Topics discussed in this section:
Mapping Logical to Physical Address
Mapping Physical to Logical Address
ARP OPERATION

Mapping IP Address to Data-Link Address
How does a machine map an IP address to its Data- Link layer (hardware or MAC) address? This is needed by the source host A who needs to send an IP packet to another host B
if B is on same IP network as A, address frame to B. Thus, DL-Address of B is needed.
if B on a separate network, address frame to a router. Thus, DL-Address of router is needed.
ARP is also used by routers (See next image)
Address Resolution
Some protocol suites adopt one of the following: Keep mapping tables in each machine
Hardware (physical) addresses are encoded in the high level addresses
Both are ad-hoc, awkward solutions
Resolution Through Dynamic Binding
Ethernet uses 48-bit physical addresses Addresses assigned by manufacturers
Replacing a faulty interface card meant a change to the machine physical address
Can’t encode 48-bit long address into a 32-bit long IP address
TCP/IP solution: Address Resolution Protocol (ARP)
ARP
Exploits broadcast capability of Ethernet Allows a host to find the Ethernet address of a target host on the same network, given the target’s IP address
Allows machines to be added or removed with no code recompilation
Builds and maintains dynamically a table to translate IP addresses into Ethernet physical addresses
ARP (contd.)
ARP (contd.)
ARP Implementation (contd.)
ARP Implementation (contd.)
Two types of incoming ARP packets A Request
IF this machine is the target of ARP Request THEN Generate ARP Reply and send it to requester
A Reply
Determine if we need to create a cache entry or update existing entry
Match Reply with initial Request
ARP Packet Format (contd.)
ARP Packet Format
To allow ARP to be used with a variety of network technologies, header of ARP messages does not have a fixed format First fields in the header specify the length of succeeding fields
On Ethernet, 28-octet ARP message format is used
Example
A host with IP address 130.23.43.20 and physical address B2:34:55:10:22:10 has a packet to send to another host with IP address 130.23.43.25 and physical address A4:6E:F4:59:83:AB. The two hosts are on the same Ethernet network. Show the ARP request and reply packets encapsulated in Ethernet frames.Solution
Figure shows the ARP request and reply packets. Note that the ARP data field in this case is 28 bytes, and that the individual addresses do not fit in the 4-byte boundary. That is why we do not show the regular 4-byte boundaries for these addresses.an ARP request and reply
Additional Notes about ARP
Proxy ARP
Proxy ARP is a technique by which a proxy server on a given network answers the Address Resolution Protocol (ARP) queries for an IP address that is not on that network. The proxy is aware of the location of the traffic's destination and offers its own MAC address as the (ostensibly final) destination.[1] The traffic directed to the proxy address is then typically routed by the proxy to the intended destination via another interface or via a tunnel.
The process, which results in the proxy server responding with its own MAC address to an ARP request for a different IP address for proxying purposes, is sometimes referred to as publishing.
Determining an IP Address at Startup
Diskless machines use IP addresses to communicate with the file server Also, many diskless machines use TCP/IP FTP protocols to obtain their initial boot image, thus requiring that they obtain and use IP addresses
Designers keep both the bootstrap code and initial OS images free from specific IP addresses for portability
Determining IP Address at Startup (contd.)
How does a diskless machine determine its IP address? When bootstrap code starts execution on a diskless machine, it must use the network to contact a server to obtain the machine’s IP address
Usually, a machine’s IP address is kept on disk where OS finds it at startup
Reverse Address Resolution Protocol (RARP)
RARP is the protocol used to solve the reverse problem solved by ARP Given a physical address, get the corresponding IP address
RARP uses the same message format as ARP
RARP messages are sent encapsulated in Ethernet frames
These days, DHCP (Dynamic Host Configuration Protocol) is a newer protocol that is used as a replacement for RARP. Thus, we can say that DHCP has rendered RARP (but not ARP) obsolete
RARP (contd.)
DHCP HANDSHAKE
ICMP
General format of ICMP messages
Note :
Error-reporting messages
Note :
Redirection concept
Query messages
Encapsulation of ICMP query messages
Example
Example of checksum calculation
Example
The traceroute program operation
EXAMPLE
Example
IGMP
The IP protocol can be involved in two types of' communication: unicasting and multicasting. The Internet Group Management Protocol (IGMP) is one of the necessary, but not sufficient, protocols that is involved in multicasting. IGMP is a companion to the IPprotoc01. Topics discussed in this section: Group Management IGMP Messages and IGMP Operation Encapsulation Netstat UtilityIGMP message types
IGMP message format
IGMP type field
IGMP operation
Note
Note
Example
Solution
Note:
The IP packet that carries an IGMP packet has a value of 1 in its TTL field.Note:
An Ethernet multicast physical address is in the range 01 to 01Example
Change the multicast IP address 230,43.14.7 to an Ethernet multicast physical address.Solution
We can do this in two steps:a. We write the rightmost 23 bits of the IP address in hexadecimal. This can be done by changing the rightmost 3 bytes to hexadecimal and then subtracting 8 from the leftmost digit if it is greater than or equal to 8. In our example, the result is 2B:0E:07
b. We add the result of part a to the starting Ethernet multicast address, which is The result is 01:00:5E:2B:0E:07
Example
Change the multicast IP address 238.212.24.9 to an Ethernet multicast address.Solution
a. The rightmost 3 bytes in hexadecimal is D4:18:09. We need to subtract 8 from the leftmost digit, resulting in 54:18:09.b. We add the result of part a to the Ethernet multicast starting address. The result is 01:00:5E:54:18:09
Tunneling
Example
We use netstat (see next slide) with three options: -n, -r, and -a, The -n option gives the numeric versions of IP addresses, the -r option gives the routing table, and the -a option gives all addresses (unicast and multicast). Note that we show only the fields relative to our discussion. "Gateway" defines the router, "Iface" defines the interface.Note that the multicast address is shown in color. Any packet with a multicast address from 224.0.0.0 to 239.255.255.255 is masked and delivered to the Ethernet interface.
ICMPv6
We discussed IPv6 in Chapter 20. Another protocol that has been modified in version 6 of the TCP/IP protocol suite is ICMP (ICMPv6). This new version follows the same strategy and purposes of version 4.Topics discussed in this section:
Error Reporting
Query
Comparison of network layers in version 4 and version 6
SUBNETTING
In the above diagram, there are two Subnets.
Note: It is a class C IP so, there are 24 bits in the network id part and 8 bits in the host id part.
• For Subnet-1:
The first bit which is chosen from the host id part is zero and the range will be from (193.1.2.00000000 till you get all 1’s in the host ID part i.e, 193.1.2.01111111) except for the first bit which is chosen zero for subnet id part.
Thus, the range of subnet-1:
193.1.2.0 to 193.1.2.127
• For Subnet-2:
The first bit chosen from the host id part is one and the range will be from (193.1.2.10000000 till you get all 1’s in the host ID part i.e, 193.1.2.11111111).
Thus, the range of subnet-2:
193.1.2.128 to 193.1.2.255
Note:
1. To divide a network into four (2^2) parts you need to choose two bits from host id part for each subnet i.e, (00, 01, 10, 11).
2. To divide a network into eight (2^3) parts you need to choose three bits from host id part for each subnet i.e, (000, 001, 010, 011, 100, 101, 110, 111) and so on.
Advantages and Disadvantages of Subnetting
Dividing a network into many small Networks is known as Subnetting.
Subnetting is useful in many ways like:
1. It provides security to one network from another network. eg) In an Organisation, code of the Developer department must not be accessed by another department.
2. It may be possible that a particular subnet might need higher network priority than others. For example, a Sales department need to host webcasts or video conferences.
3. In the case of Small networks, maintenance is easy.
Along with these advantages, Subnetting also has some disadvantages:
1. In case of the single network, only three steps are required in order to reacha Process i.e Source Host to Destination Network, Destination Network to Destination Host and then Destination Host to Process.
But in the case of Subnetting four steps are required for Inter-Network Communication. i.e Source Host to Destination Network, Destination Network to proper Subnet, then Subnet to Host and finally Host to Process.
Hence, it increases Time complexity. In the case of Subnet, more time is required for communication or data transfer.

2. In the case of Single Network only two IP addresses are wasted to represent Network Id and Broadcast address but in case of Subnetting two IP addresses are wasted for each Subnet.
Example: If a Network has four Subnets, it means 8 IP addresses are going to waste.
Network Id for S1: 200.1.2.0
Broadcast address of S1: 200.1.2.63
Network Id for S2: 200.1.2.64
Broadcast address of S2: 200.1.2.127
Network Id for S3: 200.1.2.128
Broadcast address of S3: 200.1.2.191
Network Id for S4: 200.1.2.192
Direct Broadcast address of S4: 200.1.2.255
Hence, we can say that Network size will also decrease. We can’t use our Network completely.
3. Cost of the overall Network also increases. Subnetting requires internal routers, Switches, Hubs, Bridges etc. which are very costly.

4. Subnetting and network management require an experienced network administrator. This adds to the overall cost as well.
SUPERNETTING
Supernetting is the opposite of Subnetting. In subnetting, a single big network is divided into multiple smaller subnetworks. In Supernetting, multiple networks are combined into a bigger network termed as a Supernetwork or Supernet.
Supernetting is mainly used in Route Summarization, where routes to multiple networks with similar network prefixes are combined into a single routing entry, with the routing entry pointing to a Super network, encompassing all the networks. This in turn significantly reduces the size of routing tables and also the size of routing updates exchanged by routing protocols.
More specifically,
• When multiple networks are combined to form a bigger network, it is termed as super-netting
• Super netting is used in route aggregation to reduce the size of routing tables and routing table updates
There are some points which should be kept in mind while supernetting:
1. All the IP address should be contiguous.
2. Size of all the small networks should be equal and must be in form of 2n.
3. First IP address should be exactly divisible by whole size of supernet.
Example – Suppose 4 small networks of class C:
200.1.0.0,
200.1.1.0,
200.1.2.0,
200.1.3.0
Build a bigger network which have a single Network Id.
Explanation – Before Supernetting routing table will be look like as:
NETWORK ID SUBNET MASK INTERFACE
200.1.0.0 255.255.255.0 A
200.1.1.0 255.255.255.0 B
200.1.2.0 255.255.255.0 C
200.1.3.0 255.255.255.0 D
First, lets check whether three condition are satisfied or not:
1. Contiguous: You can easily see that all network are contiguous all having size 256 hosts.
Range of first Network from 200.1.0.0 to 200.1.0.255. If you add 1 in last IP address of first network that is 200.1.0.255 + 0.0.0.1, you will get the next network id that is 200.1.1.0. Similarly, check that all network are contiguous.
2. Equal size of all network: As all networks are of class C, so all of the have a size of 256 which in turn equal to 2^8.
3. First IP address exactly divisible by total size: When a binary number is divided by 2^n then last n bits are the remainder. Hence in order to prove that first IP address is exactly divisible by while size of Supernet Network. You can check that if last n v=bits are 0 or not.
In given example first IP is 200.1.0.0 and whole size of supernet is 4*2^8 = 2^10. If last 10 bits of first IP address are zero then IP will be divisible.

Last 10 bits of first IP address are zero (highlighted by green color). So 3rd condition is also satisfied.
Therefore, you can join all these 4 networks and can make a Supernet. New Supernet Id will be 200.1.0.0.
Advantages of Supernetting –
1. Control and reduce network traffic2. Helpful to solve the problem of lacking IP addresses
3. Minimizes the routing table
Disadvantages of Supernetting –
• It cannot cover different area of network when combined• All the networks should be in same class and all IP should be contiguous
************************************************
ROUTING TABLES IN COMPUTER NETWORK
Routers:
A Router is a networking device that forwards data packets between computer network. This device is usually connected to two or more different networks. When a data packet comes to a router port, the router reads address information in packet to determine out which port the packet will be sent. For example, a router provides you with the internet access by connecting your LAN with the Internet.When a packet arrives at a Router, it examines destination IP address of a received packet and make routing decisions accordingly. Routers use Routing Tables to determine out which interface the packet will be sent. A routing table lists all networks for which routes are known. Each router’s routing table is unique and stored in the RAM of the device.
Routing Table:
A routing table is a set of rules, often viewed in table format, that is used to determine where data packets traveling over an Internet Protocol (IP) network will be directed. All IP-enabled devices, including routers and switches, use routing tables. See below a Routing Table:Destination Subnet mask Interface
128.75.43.0 255.255.255.0 Eth0128.75.43.0 255.255.255.128 Eth1
192.12.17.5 255.255.255.255 Eth3
default Eth2
The entry corresponding to the default gateway configuration is a network destination of 0.0.0.0 with a network mask (netmask) of 0.0.0.0. The Subnet Mask of default route is always 255.255.255.255 .
Entries of an IP Routing Table:
A routing table contains the information necessary to forward a packet along the best path toward its destination. Each packet contains information about its origin and destination. Routing Table provides the device with instructions for sending the packet to the next hop on its route across the network.Each entry in the routing table consists of the following entries:
1. Network ID:
The network ID or destination corresponding to the route.
The mask that is used to match a destination IP address to the network ID.
The IP address to which the packet is forwarded.
Outgoing interface the packet should go out to reach the destination network.
A common use of the metric is to indicate the minimum number of hops (routers crossed) to the network ID.
Routing table entries can be used to store the following types of routes:
• Directly Attached Network IDs
• Remote Network IDs
• Host Routes
• Default Route
• Destination
How are Routing Tables populated?
There are ways to maintain Routing Table:• Directly connected networks are added automatically.
• Using Static Routing.
These Routing tables can be maintained manually or dynamically. In dynamic routing, devices build and maintain their routing tables automatically by using routing protocols to exchange information about the surrounding network topology. Dynamic routing tables allow devices to “listen” to the network and respond to occurrences like device failures and network congestion. Tables for static network devices do not change unless a network administrator manually changes them.
Route Determination Process (finding Subnet ID using Routing Table):
Consider a network is subnetted into 4 subnets as shown in the above picture. The IP Address of the 4 subnets are:
200.1.2.0 (Subnet a)
200.1.2.64 (Subnet b)
200.1.2.128 (Subnet c)
200.1.2.192 (Subnet d)

Then, Routing table maintained by the internal router looks like:
DESTINATION SUBNET MASK INTERFACE
200.1.2.0 255.255.255.192 A
200.1.2.64 255.255.255.192 B
200.1.2.128 255.255.255.192 C
200.1.2.192 255.255.255.192 D
200.1.2.192 255.255.255.192 d
Default 0.0.0.0 e
To find its right subnet (subnet ID), router performs the bitwise ANDing of destination
IP Address mentioned on the data packet and all the subnet masks one by one.
• If there occurs only one match, router forwards the data packet on the corresponding interface.
• If there occurs more than one match, router forwards the data packet on the interface corresponding to the longest subnet mask.
• If there occurs no match, router forwards the data packet on the interface corresponding to the default entry.
Comments
Post a Comment