An IPv4 or IP Version 4 address consists of 4 bytes or 32 bits. The IP address is divided into the network part and the host part. The number of bits occupied by the network part and the host part depends on the class of the network. Networks are broadly divided into 3 classes: Class A Class B Class C When sytems want to communicate over the internet they need to have a public IP address. This public IP address is unique for each system on the Internet. This public address has to be purchased from the Network Information Center (NIC) in Stanford. Systems inside a coorporation or cahbmpus can use private IP addresses to communicate to each other. These need not be purchased from NIC.
We can identify the class of the network from the IPv4 address by examining the first bits of the IP address. For Class A first or Most Significant Bit(MSB) is 0. For Class B the first bit is 1 and second bit is 0 ie first two bits = 10 For Class C the first and second bits are 1 and the third bit 0 , first three bits =110 Each byte of the IP address is represented as a decimal integer and the 4 bytes of the IP address are separated by dots( . ) for human ease of readability. For example 10.200.20.5 is a Class A IP address because the first byte “10“ has a bit pattern 00001010. So 1 st bit is 0 making it a Class A address. Similarly 220.127.116.11 is a Class B address as 129 has bit pattern 1000 0001 So 1 st 2 bits are 10 making it Class B. Class C is similar Anything in the range 192 to 239 in the first byte is a Class C Address as the first 3 bits would be: 110
In a Class A network the network part consists of the 1 st 8 bits, the remaining 24 bits are for the host part. So each pure Class A network can support (2 24 - 2) hosts . The reduction by 2 is due to one address each being reserved for the network address(all 0s in the host part) and broadcast address for the network(all 1’s in the host part) A pure Class A network cannot be used in practice. If at all it is used the number of hosts in the Class A network would be very much less than the maximum possible. Typically 30 – 254 is the optimum number of hosts possible on any network for transmission and reception to take place without collisions. So a Class A network would have to be divided into smaller networks called subnets. This is achieved by using the first bits in the host part to represent the address of the subnet. Each subnet now can operate independently of the others. Depending on the number of bits used for subnetting or dividing the original Class A network the number of hosts per subnet would correspondingly reduce.
The first octet or digit in a Class A Network representation can vary from 0 to 127. 0 is reserved for representation of default route(0.0.0.0) 127 is reserved for loopback ( 127.0.0.1) Loopback address is the address used to loop back a packet within the ip stack without going out of the network card. Loopback is used for testing and for accessing applications locally through the ip layer. So the available addresses in Class A range from 1 to 126. Of these 10 is reserved as a private IP network prefix address to be used in organizations. For example Wipro uses 10.0.0.0 to 10.255.255.255 as the range of its local IP network, host and broadcast addresses in this range. So too do other organizations.
The range of the 1 st octet or byte of a Class B address is therefore: 128 to 191 Class B network part has 16 bits. So Class B network addresses range from: 18.104.22.168 22.214.171.124 … .. 126.96.36.199 188.8.131.52 … .. 184.108.40.206 … . 220.127.116.11 … . 18.104.22.168 Remember 0.0 in the last 2 bytes corresponds to a network address.
Since the 1 st 3 bits in the network part of a Class C address is 110, The range of Class C network adddresses is: 192.0.0.0 22.214.171.124 .. 126.96.36.199 … .. 188.8.131.52 Remember that Class C has 24 bits in the network part and 8 bits in the host part. The broadcast address for the 192.0.0.0 network is 184.108.40.206 Here all the last 8 bits, the host part, are 1s. Class C networks and Class B networks just like Class A networks can be subnetted or divided into smaller subnets. The maximum number of hosts in a Class C network is 256 -2 = 254. The Class C network 192.0.0.0 has host addresses in the range: 192.0.0.1 to 220.127.116.11 . Note 18.104.22.168 is broadcast address and 192.0.0.0 is the network address.
Class D networks are used for multicasting or group addressing for applications like audio and video conferencing over IP networks. Class D networks have the 1 st 4 bits in the network part = 1110 So the first octet or byte ranges from 224 to 239. There is no other interpretation of the remaining part. All the addresses from 22.214.171.124 to 126.96.36.199 can be used as multicast addresses. Some of the addresses in the 224 range are reserved for special purposes like OSPF multicast messages amongst routers. The process of multicasting involves registration of a client to a multicast server for joining a multicast group. The multicast server allocates a multicast group address to which the client now belongs. This multicast address can be used for communication amongst the group. Any ip packet with the multicast ip address will be delivered to al members of the group.
Multicasting can also be enabled on routers so that multicast groups can span different networks or subnetworks(subnets). The multicast IP address determines the multicast MAC address. The last 23 bits of the multicast ip address of a group a client belongs to is appended to a fixed value in the 1 st 25 bits of the MAC address. 1 st 24 bits in MAC address for multicasting is: 01:00:5e followed by the 25 th bit as 0. After this the last 23 bits of IP address is added to form the MAC multicast address. For example if Multicast IP address is : 188.8.131.52 the last 23 bits are 09:0a:0b with a 0 bit added in front( Note 10 is “0a” in hex and 11 is “0b” in hex.) The fixed part being 01:00:5e the MAC address corresponding to 184.108.40.206 multicast IP address is: 01:00:5e:09:0a:0b Suppose the multicast IP address is 220.127.116.11 the corresponding Multicast MAC address is 01:00:5e:01:02:03
These are the IP address ranges reserved for private networks within organizations. These addresses will not be allocated by NIC as public IP addresses for the Internet. The Class A private addresses are in range 10.0.0.0 to 10.255.255.255 Which means there are 2 24 addresses approximately available. Of course due to subnetting some ip addresses will be lost for subnet ip addresses and subnet broadcast addresses. All organizations be it Wipro, TCS . IBM or Microsoft use this range of addresses. There is no problem of clash because when a packet goes outside the organization the local ip adress gets translated into the public IP address purchased by the organization. In Class B a lesser number of addresses in range 172.16.0.0 to 18.104.22.168 is available. In Class C anything starting with 192.168 is a private IP address. Private IP address allocation is a good example of reusability. Service providers allocate private ip addresses to connected Home or Small Office subscribers( SOHO..SmallOffices and Homes)
This is the complete range of Reserved and Available IP addresses As mentioned 0.0.0.0 is reserved for default routing address. Anything starting with 127 is reserved for loopback. Some other addresses like 22.214.171.124, 126.96.36.199, 192.0.0.0 and 188.8.131.52 are reserved by NIC for its own use. Of course addresses stating with 10, 172.16 to 172.31 and 192.168 are reserved for private addressing. 255.255.255.255 is used for broadcasting to local subnet.
Find the Class, Network Address and the host part of each of these addresses.
172.16.0.0 is a pure Class B network address. For this network all hosts will have the same common 1 st 16 bits corresponding to 172.16 This is also represented as a subnet mask. The subnet mask for a pure Class B network also called the default subnet mask for a Class B network is 255.255.0.0. This means that the 1 st 16 bits of all hosts on the same network will be the same ie if a host in the Class B network 172.16.0.0 with IP address say 172.16.1.1 has its IP address anded bitwise with the subnet mask 255.255.0.0 ( 1 st 16 bits 1 and remaining 16 bits 0) then the result of the anding operation will be the network address 172.16.0.0 All hosts on the network 172.16.0.0 will have network part same 172.16, the host part will be different. The subnet mask is giving the information as to how many bits in the ip address is common for the hosts on a network or subnet. In other words all hosts on a pure Class A.B or C network or its subnets will have the same value in the bits corresponding to 1s in the subnet mask for the network or subnet This also logically implies that every network or subnet will have its own subnet mask which is characteristic of that network or subnet. Subnets are derived from pure ClasA, Class B or Class C networks.
This figure explains how subnet masks are converted to decimal addresses. It sometimes is useful to remember them. One possible view of logical AND is as follows: We will need to be able to perform a logical AND on the binary numbers. Just take two binary numbers and place one above the other. The ones in the bottom are like a pipe—the number above it just drops through. The zeros are like a clogged pipe, so nothing comes out in the answer.
Here default subnet mask is used for pure Class B network without subnetting
This example makes a Class B address space look like a collection of Class C address spaces. This is because we are subnetting a Class B Network 172.16.0.0 using 8 more bits for subnetting. So the subnet mask becomes 255.255.255.0 which is the same as the default subnet mask for a pure Class C network. Now the logical AND allows us to extract the subnet number as well as the assigned network number. The subnet number is from bits 17-24 counting the most significant bit as bit 1. The subnet address however will be 172.16.2.0 which includes the pure Class B network part 172.16 and the subnet number 2
Here we are splitting up the Class B network 172.16.0.0 into 1024 subnets ( 2 10 = 1024) So the subnet mask is 255.255.255.192 ( Totally 26 1s followed by 6 0s. No of 1s 10 more than in default subnet mask for Class B , which is 16 1s followed by 16 0s)
A range of addresses is needed to allocate address space. A valid range of addresses is between subnet zero and the directed broadcast. These RFCs provide more information about broadcasts: RFC 919, Broadcasting Internet Datagrams RFC 922, Broadcasting IP Datagrams in the Presence of Subnets Cisco’s support for broadcasts generally complies with these two RFCs. It does not support multisubnet broadcasts that are defined in RFC 922. Typically routers nowadays will not support broadcast to mu;tiple subnetsto prevent unnecessary wastage of bandwidth. In fact in IPv6 (Version 6) there is no broadcast at all, only multicasts and unicasts
Convert the given address address to a binary host address.
Write the subnet mask in binary.
Draw a line at the end of the ones in the subnet mask.
Fill in zeros beyond the vertical line for getting the subnet address of the subnet the given IP address is a part of.
Fill in ones beyond the vertical line for the broadcast address for this subnet.
Fill in 0s beyond the vertical line except for the last bit. Make that bit a 1. This is the first usable host address in the given subnet.
Fill in 1s beyond the vertical line except for the last bit. Make that bit a 0. This is the last usable host address in the subnet.
Alternative Method: Step 1: Take the subnet mask Here it is 255.255.255.192 Step 2: Find the first octet in subnet mask which is not 255 Here it is the last octet, 192 Step 3: Subtract this value from 256 Here 256 -192 = 64. Now 64 is the difference between successive subnet addresses in this octet. Step 4: Find between which subnet addresses the given IP address falls. then take the lower subnet address of the two as the subnet address of the subnet the IP address belongs to Here the subnet addresses in 4 th octet are: 172.16.2.0 172.16.2.64 172.16.2.128 172.16.2.192 2 bits used in 4 th octet , so 4 subnets will lie in 4 th octet.
The Network layer is concerned with getting packets from the source to the destination. That is it is in charge of routing the packets along the best possible path. The process of routing takes place at each intermediate router along the path. In this typical network topology, Subnet 192.168.88.0 has 2 hosts shown in figure connected to the Layer 2 switch. These are hosts 192.168.88.40 and 192.168.88.20. Moreover the bottom most interface of Router A is also connected to the same switch and is also on the same subnet with an IP address of 192.168.88.2 as shown in diagram. Similarly the 192.168.89.0 subnet connected through another Layer 2 switch has 2 hosts( 192.168.89.40 and 192.168.89.20) and the router A’s top interface 192.168.89.2. Router A has a 3 rd interface with IP address 192.168.90.2 on the 192.168.90.0 subnet. So Router A is the junction of 3 subnets: 192.168.88.0, 192.168.89.0 and 184.108.40.206 Similarly router B connects 2 subnets 192.168.90.0 and 192.168.91.0. Router C is connected to 192.168.91.0 subnet and another subnet on its other interface which is not specified in the diagram. As can be seen Routers are connected to each other through a common subnet.
This is the route table on the host with IP address 192.168.88.20 If you want to see the route table on a Windows machine, At the command prompt type: C:>route –print The route table will be displayed similar to shat is shown above. IF you see the botommost entry in the table this corresponds to the ip address of the same machine. So the subnet mask is all 1s ie 255.255.255.255. So first when the ip layer receives a packet from the higher layer it tries to find a match with this subnet mask. Basically matching occurs in the order of the length of 1s in the subnet mask, the longest 1s order subnet mask being processed first and so on. Note that the entry for this bottom row has Outgoing interface entry as 127.0.0.1 which coresponds to loopback interface.
This example shows how packets to other networks will be routed through the gateway Router A for host 192.168.88.40
This is the Routing Table for Router A. Router A has 3 directly connected subnets: 192.168.88.0 192.168.89.0 192.168.90.0 So there are 3 entries or rows corresponding to these 3 subnets. For these directly connected subnets, ie rows 2,3 & 4, the Gateway IP column and the Interface column will be the same, ie the ip address of the interface of Router A directly connected to the subnet. Those 3 interfaces are respectively: 192.168.88.2 on 192.168.88.0 subnet 2. 192.168.89.2 on 192.168.89.0 subnet 192.168.90.2 on 192.168.90.0 subnet
Router B has 2 subnets directly connected, 192.168.90.0 and 192.168.91.0 There are same number of rows 5 as in router A. 4 correspond to the 4 different subnets shown in the topology and 1 is for default route. Typically in the simplest scenario the number of rows or entries in the routing table of each router will be the same as the number of subnets in the whole network excluding the default route entry. In this toplolgy there will be 5 rows in each of the routers A,B & C.
Routing Protocols are used by Routers to exchange their routes with each other. There are 2 types of Routing Protocols: Interior Gateway Protocols Exterior Gateway Protocols Interior Gateway Protocols are used within the private intranet of an organization. Exterior Gateay protocols are used by one organization to communicate and find out routes to other organizations. For example Exterior Gateway protocol would be necessary for Wipro Mail Server to talk to Infosys or TCS mail server and vice versa. For communication within Wipro only Interior Gateway Protocols between the Routers in Wipro intranet is used. Interior Gateway Protocols can be of different types.
As a packet is sent down through the network layers, routing determines the protocol address of the next hop for the packet and on which piece of hardware it expects to find the station with the immediate target protocol address. In the case of the Ethernet, address resolution is needed and lower layer must consult the Address Resolution module to convert the <protocol type, target protocol address> pair to a 48.bit Ethernet address. The Address Resolution module tries to find this pair in a table. If it finds the pair, it gives the corresponding 48.bit Ethernet address back to the caller (hardware driver) which then transmits the packet.
An ARP message, which contains the Internet address of the host you want the physical address of, is broadcast to all the hosts on the network. Only the host which recognizes its own IP address will respond by sending its physical address back to the transmitting host. All the other hosts will ignore the ARP broadcast. The transmitting host can now store this information for later use.
In order to deliver a datagram to another host on the same network, the transmitting host maps the Internet address onto the physical address. Therefore, if the transmitting host only knows the Internet address of the receiving host, it must have some means of getting its physical address.
How IP address works
TCP/IP Addressing Demystified - Edited by Alien Coders Team Contributed by Souvik Official Website: http://www.aliencoders.com Facebook Page: https://www.facebook.com/aliencoders
What you will learn• How internet addressing works• Internet Addressing• Role played by Routing and addressing• ARP• TCP/UDP• IPv6 into the picture
• The Internet Protocol (IP) enables communications across a vast and heterogeneous collection of networks.• The Internet offers two basic communication services that operate on top of IP:• TCP Transmission control protocol i.e reliable stream service.• UDP User datagram Protocol.
The TCP header contains the port number of the client process and the wellknown port 80 for the HTTP server process.The IP network address are the logical address because they are defined in termsof logical topology of the routers and the end systems.Ethernet LAN frames contains physical address that identify the physicalendpoints for the sender and the receiver.
• The network interface layer is particularly concerned with the protocols that are used to access the intermediate networks.• At each gateway the network protocol is used to encapsulate the IP packet into a packet or frame of the underlying link.• The router must determine the next hop in the route to the destination and then encapsulate the IP packet or frame of the type of the next network or link
• Total Length : With 16 bits , the max packet length = 65,535• Protocol TCP =6 ; UDP =17 ; ICMP = 1• Options : Security level , Route to be taken by the packet• Padding : To make the header field a multiple of 32 bit word.
Internet Addressing Network HostAn IP address is divided into 2 parts:a) network part 2) host part .The part of a public IP address that identifies the network isinternationally controlled by the Network Information Center (NIC)located in the Stanford Research Institute in California.The part that identifies the host is controlled locally at anetwork level.
Internet AddressingAn Internet address is four octets (i.e. 32 bits) long.The first few bits in the network part of the address helps interpret theaddress.These bits indicate the class of the address.When a system wants to communicate over the internet they need to have apublic address.This public address has to be purchased from NIC in Stanford.
Address classesThere are five Internet address classes. They are : Class A / B / C / D / E .Class A addressing is used for very large networks, that is networks which willhave a large number of hosts attached to them.For class A the MSB is 0.Each pure class A network can support (224-2) hosts. One address each beingreserved for network address (all 0 ) and all one for broad cast.
Class A Host ID 24 bitsThe first bit is 0 and next 7 bits called the Net ID identifiesthe network . The next field contains the host ID, whichidentifies the particular host within the specified network.In a class A address its 24 bits long and therefore allows for almost 17 million hosts on a network.For example 10.200.20.5 is a class A address
Class BClass B addressing is used for medium-sized networks.If the first two bits in the address are 10, its a class B address. 14 bits for network Idsand 16 bits for host Ids allowing about 16,000 networks and 64,000 hosts for eachnetwork.The range of first octet of class B address is 128 –191.i.e 220.127.116.11 to 18.104.22.168
Class CThe next address class is class C, probably the most common network class.If the first 3 bits in the address are 110, the address is a class C address.The net ID is 21 bits long and the host ID is 8 bits long, allowing about 21million networks and 254 hosts per network.The range of class C Network is 192.0.0.0 – 22.214.171.124The 126.96.36.1995 is the broadcast address and 192.0.0.0 is the networkaddress.
Class DClass D addressing is used for multicasting a number of hosts for applicationslike audio and video conferencing.Class D networks have the first 4 bits in the network part = 1110.The first octet ranges from 224 – 239.All the addressees from 188.8.131.52 to 184.108.40.206 can be used as multicastaddress.
• A host ID that contains all 1s is meant to broadcast the packet to all hosts specified by the network.• If the network ID also contains all 1s the packet is broadcast on the local network.• A host ID that contains all 0s refers to the network specified by the network ID , rather than to a host.• A source may send all 0s in the source address while trying to find out the correct IP address. The machine is then identified by its MAC address.
• These are the IP address ranges reserved for private networks within organizations.• These addresses will not be allocated by NIC as public IP address for the internet.• There is no problem of clash because when a packet goes outside the organization the local IP address gets translated into into the public IP address purchased by the organizations.
Private Addressing– Class A: • 10.0.0.0 to 10.255.255.255---- 1 Class A network– Class B: • 172.16.0.0 to 172.31.255.255 ---- 16 contiguous Class B networks– Class C: • 192.168.0.0 to 192.168.255.255--- 255 contiguous Class C networks
• These are IP address ranges reserved for private networks within organizations.• These addresses will not be allocated by NIC as public IP addresses for the Internet.• There is no problem of clash because when a packet goes outside the organization the local IP address gets translated into the public IP address purchased by the organization.
Reserved and Available IP AddressesClass Address or Range StatusA 0.0.0.0 Reserved 220.127.116.11 through 18.104.22.168 Available 127.0.0.0 ReservedB 22.214.171.124 Reserved 126.96.36.199 through 188.8.131.52 Available 184.108.40.206 ReservedC 192.0.0.0 Reserved 220.127.116.11 through 223.255.254 Available 18.104.22.168 ReservedD 22.214.171.124 through Multicast group 126.96.36.199 addressesE 240.0.0.0 through Reserved 255.255.255.254 Broadcast 255.255.255.255
• Subnet Addressing : To add another hierarchical level called the subnet .• The beauty of the subnet addressing scheme is that it is oblivious to the network outside the organization.
• An organization has many LANs , each consisting of no more than 100 hosts.• 7 bits for for host identification in a sub network and other 9 bits are used for identifying the subnetwork.• Packet with destination IP 150.100. 12.176 arrives• The subnet mask used is 11111111 11111111 11111111 10000000 = 255.255.255.128• The router performs the AND between the subnet mask and the IP and the subnet number becomes 10010110 01100100 00001100 10000000 : 188.8.131.52 This number is used to forward the packet to the correct subnetwork.
IP Address Classes Exercise Address Class Network Host 10.2.1.1 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 2126.96.36.199 0
IP Address Classes Exercise AnswersAddress Class Network Host10.2.1.1 A 10.0.0.0 0.2.1.112188.8.131.52 B 184.108.40.206 0.0.2.100220.127.116.11 C 18.104.22.168 0.0.0.6422.214.171.124 C 126.96.36.199 0.0.0.2130.113.64.16 B 188.8.131.52 0.0.64.162184.108.40.206 Nonexistent0
Subnet Mask Network Host IPAddress 172 16 0 0 Network Host Default Subnet Mask 255 255 0 0 11111111 11111111 00000000 00000000 Also written as “/16” where 16 represents the number of 1s in the mask. Network Subnet Host 8-bit Subnet 255 255 255 0 Mask Also written as “/24” where 24 represents the number of 1s in the mask.
192.168.9 1.4 192.1 192 Laye 68.89 .20 .168. 90.3 r2Rout Rout er C er A Rout 192.1 192.1 er B 68.89 192 .2 68.89 .40 .168. 91.3 ARP 192 192.168. .168. 88.2 90.2 192.1 Laye 6 r 8.88. 2 20 19 2.168 .88 .40 Routing Demonstration
Routing done by HostNetwork Netmask Gateway InterfaceDestination0.0.0.0 0.0.0.0 192.168.88.2 192.168.88.40192.168.88.0 255.255.255.0 192.168.88.4 192.168.88.40 0192.168.88.40 255.255.255.25 127.0.0.1 127.0.0.1 5 Let assume IP packet received by network layer of host have destination IP 192.168.88.20 and source IP: 192.168.88.40 192.168.88.20 192.168.88.20 AND AND 255.255.255.255 255.255.255.0 192.168.88.20 192.168.88.0
Routing done by HostNetwork Netmask Gateway InterfaceDestination0.0.0.0 0.0.0.0 192.168.88.2 192.168.88.40192.168.88.0 255.255.255.0 192.168.88.4 192.168.88.40 0192.168.88.40 255.255.255.25 127.0.0.1 127.0.0.1 5 Let assume IP packet received by network layer of host have destination IP 192.168.89.4 and source IP: 192.168.88.40 192.168.89.4 192.168.89.4 192.168.89.4 AND AND AND 255.255.255.255 255.255.255.0 0.0.0.0 192.168.89.4 192.168.89.0 0.0.0.0
Routing Done Router A Network Netmask Gateway Interface Destination 0.0.0.0 0.0.0.0 192.168.90.3 192.168.90.2 192.168.88.0 255.255.255. 192.168.88.2 192.168.88.2 0 192.168.89.0 255.255.255. 192.168.89.2 192.168.89.2 0 192.168.90.0 255.255.255. 192.168.90.2 192.168.90.2Let assume IP packet received by layer 3 0have destination IP 192.168.89.4 and source IP: 192.168.88.40 192.168.91.0 255.255.255. 192.168.90.3 192.168.90.2 192.168.89.40 AND 255.255.255.0 192.168.89.0
Routing Done by Router BNetwork Netmask Gateway InterfaceDestination0.0.0.0 0.0.0.0 192.168.91.4 192.168.91.31220.127.116.11 255.255.255.0 192.168.90.2 192.168.90.3118.104.22.168 255.255.255.0 192.168.90.2 192.168.90.3122.214.171.124 255.255.255.0 192.168.90.3 192.168.90.31126.96.36.199 255.255.255.0 192.168.91.3 192.168.91.3 Let assume IP packet received by Router A have destination IP 192.168.92.5 and source IP: 192.168.88.40 192.168.92.5 192.168.92.5 AND AND 255.255.255.0 0.0.0.0 192.168.92.0 0.0.0.0
Dynamic Routing Routing Protocol Interior Gateway Protocol Exterior Gateway ProtocolOpen Shortest Path First Routing Information Protocol Border Gateway ProtocolDijkstra Algorithm Bellman Ford AlgorithmLink State Protocol Distance Vector Protocol
Address Resolution Protocol• The address resolution protocol (ARP) is used when one host wants to get the physical address of another host on the same network.