All the hosts in a network must have the same network number. This property of IP addressing can cause problems as networks grow. For example, consider a university that started out with one class B network used by the Computer Science Dept. for the computers on its Ethernet. A year later, the Electrical Engineering Dept. wanted to get on the Internet, so they bought a repeater to extend the CS Ethernet to their building.
As time went on, many other departments acquired computers and the limit of four repeaters per Ethernet was quickly reached. A different organization was required. Getting a second network address would be hard to do since network addresses are scarce and the university already had enough addresses for over 60,000 hosts. The problem is the rule that a single class A, B, or C address refers to one network, not to a collection of LANs. As more and more organizations ran into this situation, a small change was made to the addressing system to deal with it. The solution is to allow a network to be split into several parts for internal use but still act like a single network to the outside world.
In the Internet literature, the parts of the network are called subnets. When a packet comes into the main router, how does it know which subnet (Ethernet) to give it to? One way would be to have a table with 65,536 entries in the main router telling which router to use for each host on campus. This idea would work, but it would require a very large table in the main router and a lot of manual maintenance as hosts were added, moved, or taken out of service.
Instead, a different scheme was invented. Basically, instead of having a single class B address with 14 bits for the network number and 16 bits for the host number, some bits are taken away from the host number to create a subnet number. For example, if the university has 35 departments, it could use a 6- bit subnet number and a 10-bit host number, allowing for up to 64 Ethernets, each with a maximum of 1022 hosts (0 and -1 are not available, as mentioned earlier). This split could be changed later if it turns out to be the wrong one. To implement subnetting, the main router needs a subnet mask that indicates the split between network + subnet number and host
''' ---------------------------- Assignment 2 PL-4 (192-223 Class C IP) ---------------------------- Theory: IP Address Classes: Class A: 0-126 Class B: 127-191 Class C: 192-223 Class D: 224-255 If Subnet mask is 255.0.0.0 it means Class A. That is, first 8 bits are 1. This also means that 2 raised to 8 is IP and 2 raised to 24 - 2(2 reserved always) is number of Hosts (machines that can be added). Consider Netmask as 255.255.255.0. Then we can AND 255.255.255.0 with the IP address to check if it is in the same subnet (i.e. both IP should match). So, 192.168.5.1 is different subnet than 192.168.4.1 You can use free Cisco Tracer tool to setup networks and clear doubts. Designing for this assignment will include 2 or more machines connected to a switch and the switch is connected to a router. The switch needs to be enabled by running command 'enable'. The machines need to be setup with static IP addresses. The machines on other side of router will be of different subnet. ---------------------------- First manually go to Edit Connections... Edit IPv4 settings Choose Manual Input IP address as needed (e.g. 192.168.4.1) and Netmask as: 255.255.255.0 Click on Ethernet Connection Name to reset (Disconnect & Connect) ---------------------------- ''' import os os.system("ping 192.168.4.1 -c 2") os.system("route") os.system("sudo route add -net 192.168.5.0 netmask 255.255.255.0 eth6") os.system("route") os.system("ping 192.168.5.3 -c 2")