1 of 86

Module 3

2 of 86

IPV4 ADDRESSES

  • The identifier used in the IP layer of the TCP/IP protocol suite to identify the connection of each device to the Internet is called the Internet address or IP address.
  • An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a host or a router to the Internet.
  • The IP address is the address of the connection, not the host or the router, because if the device is moved to another network, the IP address may be changed.
  • If a device has two connections to the Internet, via two networks, it has two IPv4 addresses.

3 of 86

4 of 86

Address Space

  • A protocol like IPv4 that defines addresses has an address space.
  • An address space is the total number of addresses used by the protocol.
  • If a protocol uses b bits to define an address, the address space is 2^b.
  • IPv4 uses 32-bit addresses, which means that the address space is 2^32 or 4,294,967,296 (more than four billion).

5 of 86

6 of 86

Hierarchy in Addressing

  • In any communication network that involves delivery, such as a telephone network or a postal network, the addressing system is hierarchical.
  • A 32-bit IPv4 address is also hierarchical, but divided only into two parts.
  • The first part of the address, called the prefix, defines the network;
  • The second part of the address, called the suffix, defines the node (connection of a device to the Internet).

The prefix length is n bits and the suffix length is (32 − n) bits.

7 of 86

8 of 86

9 of 86

Prefix Length

  • A prefix can be fixed length or variable length.
  • Thee network identifier in the IPv4 was first designed as a fixed-length prefix. This scheme is referred to as classful addressing.
  • The new scheme, which is referred to as classless addressing, uses a variable-length network prefix.

10 of 86

Classful Addressing

  • Initially stage of internet, an IPv4 address was designed with a fixed-length prefix, but to accommodate both small and large networks, three fixed-length prefixes were designed instead of one (n = 8, n = 16, and n = 24).
  • The whole address space was divided into five classes (class A, B, C, D, and E).

11 of 86

12 of 86

  • In class A, the network length is 8 bits, in which first bit is 0, to defines the class, have only seven bits as the network identifier. 2^7 = 128 networks in the world that can have a class A address.
  • In class B, the network length is 16 bits, but since the first two bits, which are (10)2, define the class, we can have only 14 bits as the network identifier. This means there are only 2^14 = 16,384 networks in the world that can have a class B address.
  • All addresses that start with (110)2 belong to class C. In class C, the network length is 24 bits, but since three bits define the class, we can have only 21 bits as the network identifier. i.e., 2^21 = 2,097,152 networks in the world that can have a class C address.

13 of 86

4. Class D is not divided into prefix and suffix. It is used for multicast addresses.

5. All addresses that start with 1111 in binary belong to class E.

As in Class D, Class E is not divided into prefix and suffix and is used as reserve.

14 of 86

Address Depletion

Classful addressing has become obsolete is address depletion.

  • Addresses were not distributed properly, the Internet was faced with the problem of the addresses being rapidly used up, resulting in no more addresses available for organizations and individuals that needed to be connected to the Internet. Ex: class A can be assigned to only 128 organizations with 16,777,216 nodes (computers in this single network) and most of the addresses in this class were wasted (unused).
  • Class B addresses were designed for midsize organizations, but many of the addresses in this class also remained unused.
  • Class C addresses have a completely different flaw in design. The number of addresses that can be used in each network (256) was so small that most companies were not comfortable using a block in this address class.
  • Class E addresses were almost never used, wasting the whole class.

15 of 86

Subnetting and Supernetting

To alleviate address depletion, two strategies were proposed.

  • In subnetting, a class A or class B block is divided into several subnets. Each subnet has a larger prefix length than the original network.
  • For example, if a network in class A is divided into four subnets, each subnet has a prefix of nsub = 10.
  • At the same time, if all of the addresses in a network are not used, subnetting allows the addresses to be divided among several organizations. This idea did not work because most large organizations were not happy about dividing the block and giving some of the unused addresses to smaller organizations.

16 of 86

  • While subnetting was devised to divide a large block into smaller ones, supernetting was devised to combine several class C blocks into a larger block to be attractive to organizations that need more than the 256 addresses available in a class C block.
  • This idea did not work either because it makes the routing of packets more difficult.

17 of 86

Advantage of Classful Addressing

  • We can easily find the class of the address and, since the prefix length for each class is fixed.
  • We can find the prefix length immediately.
  • In other words, the prefix length in classful addressing is inherent in the address;
  • No extra information is needed to extract the prefix and the suffix.

18 of 86

Classless Addressing

  • The address depletion issue was not fully resolved by classful addressing's subnetting and supernetting techniques.
  • As the Internet expanded, it became obvious that a bigger address space was required as a long-term fix.
  • However, the expanded address space necessitates that IP addresses should be longer as well, necessitating a change in IP packet syntax.
  • The short-term solution, which uses the same address space but modifies the distribution of addresses to deliver a fair amount to each business, was developed despite the fact that the long-term solution, known as IPv6, has already been developed.

19 of 86

  • Classless addressing is the temporary fix, which nevertheless makes use of IPv4 addresses.
  • In order to make up for address depletion, the class privilege was taken out of the distribution.

20 of 86

Classless Address Variable Length Technique

  • The entire address space is partitioned into blocks of varying lengths with classless addressing.
  • An address’s prefix designates the block (network); its suffix designates the node (device).
  • We are capable of having a block of 20, 21, 22,…, 232 addresses, theoretically.
  • Limitations of the block addresses is, must have a power of two (20) addresses.

21 of 86

Classless Address Variable Length Technique

  • One address block may be given to an organization.

  • The non-overlapping block segmentation of the entire address space.

22 of 86

Classless Address Variable Length Technique

  • Classless addressing allows for varying prefix lengths.
  • Prefix lengths that vary from 0 to 32 are possible.
  • The length of the prefix has an inverse relationship with network size.
  • A smaller network has a large prefix; a larger one has a small prefix.

Note: Classless addressing is a specific instance of classful addressing.

23 of 86

Prefix Length - Slash Notation

The address is inserted in this scenario, followed by a slash, and the prefix length

24 of 86

Prefix Length - Slash Notation

  • Slash notation is the colloquial name for the notation, while classless interdomain routing, or CIDR method.
  • Also provide the prefix length in classless addressing because an address does not automatically define the block or network to which it belongs.

25 of 86

Extracting Information from an Address

  • With respect to any given address in the block, we typically like to know three things,
  • The number of addresses in the block,
  • The start address in the block, and
  • The last address.

26 of 86

Extracting Information from an Address

27 of 86

Extracting Information from an Address

  • The number of addresses in the block is found as N = 232-n
  • To find the first address, we keep the n leftmost bits and set the (32 − n) rightmost bits all to 0s.
  • To find the last address, we keep the n leftmost bits and set the (32 − n) rightmost bits all to 1s.

28 of 86

Example

  • The address 167.199.170.82/27 is a classless address.
  • The number of addresses in the network is 232 − n =232-27= 25 = 32 addresses.

29 of 86

Address Mask

  • Another way to find the first and last addresses in the block is to use the address mask.
  • The address mask is a 32-bit number in which the n leftmost bits are set to 1s and the rest of the bits (32 − n) are set to 0s.
  • A computer can easily find the address mask because it is the complement of (232 − n − 1).
  • Computer program to extract the information in a block, using the three bit-wise operations NOT, AND, and OR.

30 of 86

Address Mask

  • The number of addresses in the block N = NOT (mask) + 1.
  • The first address in the block = (Any address in the block) AND (mask).
  • The last address in the block = (Any address in the block) OR [(NOT (mask)].

31 of 86

Example

  • Address is 167.199.170.82/27
  • Address 10100111 . 11000111 . 10101010 . 01010010
  • Mask Address 11111111 . 11111111 . 11111111 . 11100000
  • The mask of address in dotted-decimal notation is 256.256.256.224.
  • Number of addresses in the block. :

N = NOT (mask) + 1= 0.0.0.31 + 1 = 32 addresses

First address: First = (address) AND (mask) = 167.199.170.82

Last address:. Last = (address) OR (NOT mask) = 167.199.170.255

32 of 86

Network Address

33 of 86

Network Address

  • The first address, the network address, is particularly important because it is used in routing a packet to its destination network.
  • Let us assume that an internet is made of m networks and a router with m interfaces.
  • When a packet arrives at the router from any source host, the router needs to know to which network the packet should be sent: from which interface the packet should be sent out.
  • When the packet arrives at the network,it reaches its destination host.

34 of 86

Block Allocation

  • The next issue in classless addressing is block allocation.
  • The ultimate responsibility of block allocation is given to a global authority called the Internet Corporation for Assigned Names and Numbers (ICANN).
  • However, ICANN does not normally allocate addresses to individual Internet users.
  • It assigns a large block of addresses to an ISP (or a larger organization that is considered an ISP in this case).
  • For the proper operation of the CIDR, two restrictions need to be applied to the allocated block.

35 of 86

Block Allocation

  • The number of requested addresses, N, needs to be a power of 2. The reason is that N = 232 − n or n = 32 − log2N. If N is not a power of 2, we cannot have an integer value for n.
  • The requested block needs to be allocated where there is an adequate number of contiguous addresses available in the address space. However, there is a restriction on choosing the first address in the block. The first address needs to be divisible by the number of addresses in the block. The reason is that the first address needs to be the prefix followed by (32 − n) number of 0s.

first address = (prefix in decimal) × 232 − n = (prefix in decimal) × N.

36 of 86

Convert IP address to Decimal

  • Let IP address: 18.14.12.0/22

  • 302910464/1024=295,811

18

14

12

0

3

2

1

0

2563

2562

2561

2560

16777216

65536

256

1

16777216*18

65536*14

256*12

1*0

301,989,888

917,504

3,072

0

302,910,464

37 of 86

Subnetting

  • More levels of hierarchy can be created using subnetting.

  • An organization (or an ISP) that is granted a range of addresses may divide the range into several subranges and assign each subrange to a subnetwork (or subnet).
  • Note that nothing stops the organization from creating more levels.
  • A subnetwork can be divided into several sub-subnetworks.
  • A sub-subnetwork can be divided into several sub-sub-subnetworks, and so on.

38 of 86

39 of 86

40 of 86

Designing Subnets

  • The subnetworks in a network should be carefully designed to enable the routing of packets.
  • We assume the

Total number of addresses granted to the organization is N,

The prefix length is n,

Then assigned number of addresses to each subnetwork is Nsub, and the prefix length for each subnetwork is nsub.

41 of 86

Designing Subnets

  • Then the following steps need to be carefully followed to guarantee the proper operation of the subnetworks,
  • The number of addresses in each subnetwork should be a power of 2.
  • The prefix length for each subnetwork should be found using the following formula: nsub = 32 − log2Nsub.
  • The starting address in each subnetwork should be divisible by the number of addresses in that subnetwork.

Note:This can be achieved if we first assign addresses to larger subnetworks.

42 of 86

Finding Information about Each Subnetwork

  • After designing the subnetworks, the information about each subnetwork, such as first and last address.

43 of 86

Example

  • An organization is granted a block of addresses with the beginning address 14.24.74.0/24.
  • The organization needs to have 3 subblocks of addresses to use in its three subnets: one subblock of 10 addresses, one subblock of 60 addresses, and one subblock of 120 addresses.
  • Design the subblocks.

44 of 86

Example:Solution

  • There are 232 – 24 = 256 addresses in this block.
  • The first address is 14.24.74.0/24;
  • The last address is 14.24.74.255/24.
  • To satisfy the third requirement,

we assign addresses to subblocks, starting with the largest and ending with the smallest one.

45 of 86

Example:Solution

  • The number of addresses in the largest subblock, which requires 120 addresses, is not a power of 2.
  • We allocate 128 addresses.
  • The subnet mask for this subnet is,

n1 = 32 −log2128 = 25

  • The first address in this block is 14.24.74.0/25;
  • The last address is 14.24.74.127/25.

46 of 86

Example:Solution

2. The number of addresses in the second largest subblock, which requires 60 addresses, is not a power of 2 either.

  • We allocate 64 addresses.

The subnet mask for this subnet,

n2 = 32 − log264 = 26.

  • The first address in this block is 14.24.74.128/26;
  • The Last address is 14.24.74.191/26.

47 of 86

Example:Solution

3. The number of addresses in the smallest subblock, which requires 10 addresses, is not a power of 2 either.

  • We allocate 16 addresses.
  • The subnet mask for this subnet,

n3 = 32 − log216 = 28

  • The first address in this block is 14.24.74.192/28;
  • The last address is 14.24.74.207/28.

48 of 86

Example:Solution

  • The result is, in total 256 addresses uses only 208 addresses, which means 48 addresses are left in reserve.
  • The first address in this range is 14.24.74.208.
  • The last address is 14.24.74.255.

49 of 86

Address Aggregation

  • One of the advantages of the CIDR strategy is address aggregation (sometimes called address summarization or route summarization).
  • When blocks of addresses are combined to create a larger block, routing can be done based on the prefix of the larger block.
  • ICANN assigns a large block of addresses to an ISP.
  • Each ISP in turn divides its assigned block into smaller subblocks and grants the subblocks to its customers.

50 of 86

Example

  • The ISP is assigned Four small blocks of addresses to four organizations.
  • But, ISP combines four blocks into one single block and shows the larger block to the rest of the world.
  • Any packet destined for this larger block should be sent to this ISP.
  • It is the responsibility of the ISP to forward the packet to the appropriate organization.

Note: This is similar to routing we can find in a postal network. All packages coming from outside a country are sent first to the capital and then distributed to the corresponding destination.

51 of 86

Example

52 of 86

Special Addresses

  • Five special addresses that are used for special purposes:
  • This-host address,
  • Limited-broadcast address,
  • Loopback address,
  • Private addresses, and
  • Multicast addresses.

53 of 86

This-host Address

  • The only address in the block 0.0.0.0/32 is called the this-host address.
  • It is used whenever a host needs to send an IP datagram but it does not know its own address to use as the source address.

54 of 86

Limited-broadcast Address

  • The only address in the block 255.255.255.255/32 is called the limited-broadcast address.
  • It is used whenever a router or a host needs to send a datagram to all devices in a network.
  • The routers in the network, however, block the packet having this address as the destination; the packet cannot travel outside the network.

55 of 86

Loopback Address

  • The block 127.0.0.0/8 is called the loopback address.
  • A packet with one of the addresses in this block as the destination address never leaves the host; It will remain in the host.
  • Any address in the block is used to test a piece of software in the machine.

For example,

We can write a client and a server program in which one of the addresses in the block is used as the server address.

We can test the programs using the same host to see if they work before running them on different computers.

56 of 86

Private Addresses

  • Four blocks are assigned as private addresses: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, and 169.254.0.0/16.

57 of 86

Multicast Addresses

  • The block 224.0.0.0/4 is reserved for multicast addresses.

58 of 86

Dynamic Host Configuration Protocol (DHCP)

  • Large organization or an ISP can receive a block of addresses directly from ICANN.
  • Small organization can receive a block of addresses from an ISP.
  • After a block of addresses are assigned to an organization, the network administration can manually assign addresses to the individual hosts or routers.
  • However, address assignment in an organization can be done automatically using the Dynamic Host Configuration Protocol (DHCP).

59 of 86

Dynamic Host Configuration Protocol (DHCP)

  • DHCP is an application-layer program, using the client-server paradigm, that actually helps TCP/IP at the network layer.
  • DHCP has founds in widespread use of Internet, called a plug-and-play protocol.
  • In can be used,
  • Network manager can configure DHCP to assign permanent/temporary IP addresses to the host and routers as on demand.
  • Temporary IP address to a traveller to connect laptop to the Internet while staying in the hotel.

60 of 86

Dynamic Host Configuration Protocol (DHCP)

  • In addition to its IP address, a computer also needs to know the network prefix (or address mask).
  • Most computers also need two other pieces of information, such as the address of a default router to be able to communicate with other networks and the address of a name server to be able to use names instead of addresses.
  • In other words, four pieces of information are normally needed:
  • Computer address,
  • Prefix
  • Address of a router,
  • IP address of a name server.
  • DHCP can be used to provide these pieces of information to the host.

61 of 86

DHCP Message Format

  • DHCP is a client-server protocol in which the client sends a request message and the server returns a response message.

62 of 86

DHCP Message Format

63 of 86

DHCP Message Format

  • Operation Code: Specifies the general type of message. A value of 1 indicates a request message, while a value of 2 is a reply message.

64 of 86

DHCP Message Format

65 of 86

DHCP Message Format

Hardware Address Length: Specifies how long hardware addresses are in this message. For Ethernet or other networks using IEEE 802 MAC addresses, the value is 6.

Hardware Count: Set to 0 by a client before transmitting a request and used by relay agents to control the forwarding of DHCP messages.

Transaction Identifier: A 32-bit identification field generated by the client, to allow it to match up the request with replies received from DHCP servers.

Time Elapsed: It is defined as the number of seconds elapsed since a client began an attempt to acquire or renew a lease. This may be used by a busy DHCP server to prioritize replies when multiple client requests are outstanding.

66 of 86

DHCP Message Format

The 64-byte option field has a dual purpose.

  • It can carry either additional information or some specific vendor information.
  • The server uses a number, called a magic cookie, in the format of an IP address with the value of 99.130.83.99.
  • When the client finishes reading the message, it looks for this magic cookie.
  • If present, the next 60 bytes are options.
  • An option is composed of three fields: a 1-byte tag field, a 1-byte length field, and a variable-length value field.
  • There are several tag fields that are mostly used by vendors. If the tag field is 53, the value field defines one of the 8 message types shown in Figure.

67 of 86

DHCP Message Format

68 of 86

Operation of DHCP

69 of 86

70 of 86

DHCP discover message

  • This is the first message generated in the communication process between the server and the client.
  • This message is generated by the Client host in order to discover if there is any DHCP server/servers are present in a network or not.
  • This message is broadcasted to all devices present in a network to find the DHCP server.

71 of 86

DHCP discover message

  • The source IP address is 0.0.0.0(because the PC has had no IP address till now) and the destination IP address is 255.255.255.255 (IP address used for broadcasting)
  • A DHCP client may also request an IP address in the DHCPDISCOVER, which the server may take into account when selecting an address to offer.

72 of 86

DHCP offers a message

  • The server will respond to the host in this message specifying the unleased IP address and other TCP configuration information.
  • This message is broadcasted by the server.
  • If there is more than one DHCP server present in the network then the client host will accept the first DHCP OFFER message it receives.
  • Also, a server ID is specified in the packet in order to identify the server. 

73 of 86

DHCP request message

  • The joining host receives one or more offers and selects the best of them.
  • The joining host then sends a DHCPREQUEST message to the server that has given the best offer.
  • The fields with known value are set.
  • The message is encapsulated in a user datagram with port numbers as the first message.
  • The user datagram is encapsulated in an IP datagram with the source address set to the new client address, but the destination address still is set to the broadcast address to let the other servers know that their offer was not accepted.

74 of 86

DHCP acknowledgment message

  • Finally, the selected server responds with a DHCPACK message to the client if the offered IP address is valid.
  • If the server cannot keep its offer (for example, if the address is offered to another host in between), the server sends a DHCPNACK message and the client needs to repeat the process.
  • This message is also broadcast to let other servers know that the request is accepted or rejected.

75 of 86

Two Well-Known Ports

  • DHCP uses two well-known ports (68 and 67) instead of one well-known and one ephemeral

76 of 86

Using FTP

  • The server does not send all of the information that a client may need for joining the network.
  • In the DHCPACK message, the server defines the pathname of a file in which the client can find complete information such as the address of the DNS server.
  • The client can then use a file transfer protocol to obtain the rest of the needed information.

77 of 86

Error Control

  • DHCP uses the service of UDP, which is not reliable.
  • To provide error control, DHCP uses two strategies.
  • First, DHCP requires that UDP use the checksum.
  • Second, the DHCP client uses timers and a retransmission policy if it does not receive the DHCP reply to a request.

78 of 86

Transition States

  • To provide dynamic address allocation, the DHCP client acts as a state machine that performs transitions from one state to another depending on the messages it receives or sends.

79 of 86

Network Address Resolution (NAT)

  • The distribution of addresses through ISPs has created a new problem.
  • Assume that an ISP has granted a small range of addresses to a small business or a household.
  • If the business grows or the household needs a larger range, the ISP may not be able to grant the demand because the addresses before and after the range may have already been allocated to other networks.

80 of 86

Network Address Resolution (NAT)

  • In most situations, only a portion of computers in a small network need access to the Internet simultaneously.
  • Number of allocated addresses does not have to match the number of computers in the network.

For example,

Assume, small business with 20 computers the maximum number of computers that access the Internet simultaneously is only 4.

Most of the computers are either doing some task that does not need Internet access or communicating with each other.

Small business can use the TCP/IP protocol for both internal and universal communication.

The business can use 20 (or 25) addresses from the private block addresses for internal communication; five addresses for universal communication can be assigned by the ISP.

81 of 86

Network Address Resolution (NAT)

82 of 86

Address Translation

83 of 86

Translation Table

  • There may be tens or hundreds of private IP addresses, each belonging to one specific host. The problem is solved if the NAT router has a translation table.

84 of 86

Using One IP Address

85 of 86

Using a Pool of IP Addresses

  • The NAT router can use a pool of global addresses.
  • Instead of using only one global address (200.24.5.8), the NAT router can use four addresses (200.24.5.8, 200.24.5.9, 200.24.5.10, and 200.24.5.11).
  • Four private-network hosts can communicate with the same external host at the same time because each pair of addresses defines a separate connection.
  • No more than four connections can be made to the same destination.

86 of 86

Using Both IP Addresses and Port Addresses

  • To allow a many-to-many relationship between private-network hosts and external server programs, we need more information in the translation table.