A Quick TCP/IP Tutorial

This tutorial, which is by no means complete, will attempt to explain how the addressing scheme behind TCP/IP works. Click on the following highlighted information for further details on that topic.

1) Addressing

2) Network and Host Address

3) Subnetting

4) Subnet Mask

5) Simple Subnetting

6) Variable Subnetting

Addressing

TCP/IP uses a 4 byte addressing scheme. Each byte is comprised of 8 bits, thus each byte can have the value of 0 to 255. The address range available with TCP/IP is 0.0.0.0 through to 255.255.255.255.

e.g.

00000000 00000000 00000000 00000000 = 0.0.0.0

11111111 11111111 11111111 11111111 = 255.255.255.255

While this is what the architecture provides for, the actual address range available to IP networks is somewhat less (as you will see later in this tutorial).

A class structure is used to determine how the address is interpreted, and also, how many host id’s it can support in the network. There are five different classes of TCP/IP addresses.They are:

Class A - 1st byte Address range 1 - 126

Class B - 1st byte Address range 128 - 191

Class C - 1st byte Address range 192 - 223

Class D - 1st byte Address range 224 - 239

Class E - 1st byte Address range 240 - 255

Only class A, B and C addresses are valid for use as TCP/IP host addresses. Class D addresses are reserved for special use such as multicasting. Class E addresses are reserved for experimental use by the IETF.

The first part of the address indicates the type of TCP/IP class that this address is a part of. The second part of the address is used for the host portion of the address. Depending on the class of address, it will determine how many bits are used for the network portion of the address, and how many bits are used for the host portion of the address.

The first byte of a class "A" address is in the range of 1 to 126. The last three bytes in a class "A" address are used for the host address.

The first byte of a class "B" address is in the range of 128 to 191. The second byte is also used in the network address. The last two bytes in a class "B" address are used for the host address.

The first byte of a class "C" address is in the range of 192 to 223. The second and third byte are used in the network address. The last byte is used for the host address.

Network and Host Addressing

Within the 4 bytes, depending on the class of address (A, B, or C), a different number of bytes are associated with the network portion of the address.

For class A addresses, the first byte represents the network portion of the address. The last three bytes represent the host portion of the address. For example, a TCP/IP host with an address of 10.67.45.176 is interpreted as being in network 10 (or 10.0.0.0), with a host id of 67.45.176. Why so, well, 10 is in the range of 1 to 126, so that is a class A address. We know that the last 3 bytes of a class A address are used for host addressing.

For class B addresses, the first two bytes represent the network portion of the address. The last two bytes represent the host portion of the address. For example, a TCP/IP host with an address of 165.10.83.208 is interpreted as being in network 165.10 (or 165.10.0.0), with a host id of 83.208.

For class C addresses, the first three bytes represent the network portion of the address. The last byte is used as the host id. As an example, a TCP/IP host with an address of 195.42.98.130 is interpreted as being in network 195.42.98 (or 195.42.98.0) with a host id of 130.

As you can see in each of the above examples, depending on the class of address, there are a different number of bytes that can be used for host addressing (a host is referred to as a node in a network e.g. a server, client PC, etc.).

With Class A addresses , a maximum of 16,777,214 host id’s can be made available (i.e. 0.0.1 through to 255.255.254).

With Class B addresses, a maximum of 65,536 host addresses are available (i.e. 0.1 through to 255.254).

Class C addresses provide only 254 host id’s (1 through 254).

Subnetting

A general internetworking rule dictates that a network segment (i.e. LAN segment, WAN cloud, etc.) can only be part of one network. That means one network address has to associated with each segment. With class C addresses, this is generally not an issue, but with class A and B addresses, using the whole addressing scheme for that segment can be a waste of addresses.

Therefore in networks with class A and B addresses (and sometimes in Class C networks), to conserve addresses, we can use some of the host bits as a subnetwork identifier.

In this way, each network segment can be assigned a subnetwork address within the network addressing scheme. To do this, a number of the host id "bits" are reserved for the subnetwork address. The remaining bits are used for host addressing. The minimum number of bits that can be used for a subnet address is two, the maximum number of bits that can be used for a subnet is the total number of host bits (minus 2 bits).

The host bits reserved for a subnet id are assigned from the left of the host bit range.

Using a class A address, between 2 and 22 bits can be used for the subnetwork address, class B addresses can use between 2 and 14 bits, and class C addresses can use between 2 and 6 bits for the subnetwork address.

The major rule with subnetting is that ONLY the host portion of the address can be broken into subnetworks, NOT the network portion of the address.

Subnet Mask

The question then becomes, given a specific address, how do we determine if there is a subnetwork being used, and if so, how many of the host bits are being used for the subnetwork. This is where the subnet mask is used. The subnet mask is also comprised of 4 bytes. The default subnet masks for each class address are shown below along with its representation in binary:

Class A - 255.0.0.0

11111111 00000000 00000000 00000000

Class B - 255.255.0.0

11111111 11111111 00000000 00000000

Class C - 255.255.255.0

11111111 11111111 11111111 00000000

The host portion of the address highlighted in red is the portion of the subnet mask that you can change to incorporate a subnetwork in your network. A "0" bit represents a host bit and a "1" bit represents a subnet bit in the address. To work out the subnet in an address, you must perform a logical "AND" between the subnet mask and the address. The result will highlight the subnet value in the address.

Some examples follow in the simple and complex subnetting sections.

Simple Subnetting

Simple subnetting is where the whole byte is either a subnet or host. A subnet mask with a value of 0 or 255 indicates that the corresponding byte of the host address is either part of the host or subnet address. A value of 0 in the subnet mask means that the corresponding byte in the address is recognised as part of the host address. A value of 1 in the subnet mask indicates that the corresponding address byte is recognised as part of the subnetwork address.

To calculate the network, subnetwork and host portion of the address, you must perform a logical AND between the TCP/IP address and subnet mask. Some examples follow:

Examples

1) An address of 10.11.12.13 with subnet of 255.0.0.0.The first thing we notice here is that the address is a class A address. This means that the last three bytes can be used to represent either the host or subnetwork portion of the address. The first byte (represented in red) cannot be subnetted.

0000 1010 0000 1011 0000 1100 0000 1101 = 10.11.12.13

1111 1111 0000 0000 0000 0000 0000 0000 = 255.0.0.0

0000 1010 0000 0000 0000 0000 0000 0000 Logical "AND"

10 0 0 0 Result

Network address = 10

Subnet address = None

Host address = 11.12.13

As we have not used any ‘1’bits in the host portion of the subnet mask, all three bytes of this address are deemed part of the host address.

2) An address of 10.11.12.13 with subnet of 255.255.0.0 is interpreted as

0000 1010 0000 1011 0000 1100 0000 1101 = 10.11.12.13

1111 1111 1111 1111 0000 0000 0000 0000 = 255.255.0.0

0000 1010 0000 1011 0000 0000 0000 0000 Logical "AND"

10 11 0 0

Network address = 10

Subnet address = 11

Host address = 12.13

This time, the second byte in the subnet mask has all ‘1’bits turned on. This indicates that the second byte of the address is to be used as a subnet identifier. Thus, with this mask we can have subnet values of 1 through 254, with host addresses in each subnet of 0.1 to 255.254.

3) An address of 10.11.12.13 with subnet of 255.255.255.0 is interpreted as

0000 1010 0000 1011 0000 1100 0000 1101 = 10.11.12.13

1111 1111 1111 1111 1111 1111 0000 0000 = 255.255.255.0

0000 1010 0000 1011 0000 1100 0000 0000 Logical "AND"

10 11 12 0

Network address = 10

Subnet address = 11.12

Host address = 13

So, as you can see, by changing the subnet mask against the same address results in the network, subnetwork and host portions of the address being interpreted in a slightly different way.

Simple subnet masks for each class address are shown below:

CLASS A

255.0.0.0 default subnet mask for Class A

255.255.0.0

255.255.255.0

CLASS B

255.255.0.0 default subnet mask for Class B

255.255.255.0

CLASS C

255.255.255.0 default subnet mask for Class C

Variable Subnetting

Complex variable subnetting is where the subnet does not break on a byte boundary. In the previous example, simple subnetting use a byte value of 0 or 255. With variable subnetting, a portion of the host byte(s) can be used to identify the subnet address.

When one sees a value of 128, 192, 224, 240, 248, 252 or 254 in a subnet mask, then variable subnetting is being used. To best illustrate complex subnetting in action, it becomes imperative that you become familiar with binary, as it provides a quick way to show the subnet and host portion of the address.

Some examples using variable subnetting follow:

1) The same address of 10.11.12.13 with subnet of 255.255.248.0 will be used.

We are still using a class A address. This means that the last three bytes can be used to represent either the host or subnetwork portion of the address. The first byte (represented in red) cannot be subnetted.

0000 1010 0000 1011 0000 1100 0000 1101 = 10.11.12.13

1111 1111 1111 1111 1111 1000 0000 0000 = 255.255.248.0

0000 1010 0000 1011 0000 1000 0000 0000 Logical "AND"

10 11 8 0 Subnet Result

0000 0000 0000 0000 0000 0100 0000 1101 Host result in binary

0 0 4 13 Host Result

Network address = 10

Subnet address = 11.8

Host address = 4.13

We have used a 13 bit mask for this class A address. The 13 bits are represented in blue. The remaining host bits are represented in green.

Remember, wherever a ‘1’bit is found in a subnet mask, the corresponding address bit is a subnet bit, and a ‘0’bit in the subnet mask means that the corresponding address bit is recognised as a host bit.

The TCP/IP calculator can be used to show further examples through its colour coding of the binary bits. Valid values for variable subnets are as follows

CLASS A

255.192.0.0

255.224.0.0

255.240.0.0

255.248.0.0

255.252.0.0

255.254.0.0

255.255.128.0

255.255.192.0

255.255.224.0

255.255.240.0

255.255.248.0

255.255.252.0

255.255.254.0

255.255.255.128

255.255.255.192

255.255.255.224

255.255.255.240

255.255.255.248

255.255.255.252

CLASS B

255.255.192.0

255.255.224.0

255.255.240.0

255.255.248.0

255.255.252.0

255.255.254.0

255.255.255.128

255.255.255.192

255.255.255.224

255.255.255.240

255.255.255.248

255.255.255.252

CLASS C

255.255.255.192

255.255.255.224

255.255.255.240

255.255.255.248

255.255.255.252

Last Modified 12 August 1996 - Carl Solder