FORGE Course


Full Height |  Two columns |  Parts | 


DySIRE Piraeus University of Applied Sciences 01/10/2016 English
IP Addressing and Routing Techniques

Dynamic and Static Internet Routing Excercises (DySIRE)

Dynamic and Static Internet Routing Excercises (DySIRE) Piraeus University of Applied Sciences 13/09/2016 English
IP Addressing and Routing Techniques

IP Addressing


In any computer network, a device must be uniquely identified in order to be reached by any other network component(e.g., router, server, printer, computing equipment, sensor etc.). For this, in IP networks, a 32-bit number assigned to each device, called the IP address, is used.

An IPv4 address can be expressed both in a dotted - decimal format, but also in binary notation. In the former format, the 32 bits of the address are divided in four octets that are separated by periods,such as which can be the IP address of a device. Each octet can have values between the number 0 (00000000 in binary) and 255 (11111111 again in binary). The calculations for converting the binary value 111111112(the subscript 2 denotes that the number is in binary, like the bits that can have two values 0 or 1) to the corresponding decimal, can be seen below:

111111112 = 1*27 + 1*26+ 1*25 + 1*24 + 1*23 + 1*22 + 1*21+ 1*20

= 128 + 64 + 32+ 16 + 8 + 4 + 2 + 1 = 255

One more example is given here for better understanding of the process:

100010102 = 1*27 + 0*26+ 0*25 + 0*24 + 1*23 + 0*22 + 1*21+ 0*20

                                                 = 128 + 8 + 2 =138 (which is thesecond decimal number in the given IP)

The above calculations are very trivial in Computer Networks and the interested readers must get quickly familiarized with these.

The same IP address described above, also, be written in binary with 32 bits like: 11000000 10001010 0000001000000011 using the same technique that was described above.

All the above analysis, along with the one that follows in this course considers IPv4 addresses, meaning addresses that follow the IPv4 protocol of addressing by using 32-bit numbers. Lately, due to the extinction of the 232 possible addresses that could be assigned in IPv4, there is a global effort to assign addresses in the new, updated addressing scheme called IPv6. IPv6 uses 128-bit for the addresses in an effort to create a large number of addresses (2128) that will not be extinct rapidly, but will be able to handle the proliferation of devices that demand access to the Web. Further discussion about IPv6 addressing will be covered in a future version of this course.


A little help (Subnet Mask)

Each packet that travels inside a IP based computer network searches to find its destination by knowing, only, its unique IP address. This means that decisions regarding the route of packets in the network are taken using only the destination address. Keeping in mind the enormous size of the web, it is easy to understand that no router or device is aware of the full network topology of the modern web. Instead, using the IP address each device can forward the packet(s) towards the right direction in order to be able to find other devices with better knowledge, as it is closing the destination. In fact, the same mechanism takes place, also, in real life.Imagine you want to visit your best friend in the University campus where he/she studies. Having no idea where the campus lies, first you want to reach the town where the campus is and then to ask the locals about the exact location of the campus. This mechanism, where the decision about the forwarding of a packet takes place based on its IP address and the knowledge of the device that will decide, is called routing.

From the above, it is easy to understand that addressing plays a significant role for routing, as well. But in order to be able to handle addressing, IP address is not the only information that someone needs. In fact, an IP address is divided in two smaller parts: the network part that denotes the network where the source of the packet belongs and the host part that specifically and uniquely identifies the source. These two parts are expressed inside an IP address and there is a need for another piece of information in order to be able to identify them inside the IP address. This is the role of the subnet mask, another 32-bit number (same size as the IP address) that reports on the network and the host part of the IP address. The subnet mask, always, consists of a series of 1s that are followed by some 0s. The number of 1s on the subnet mask denotes the network part (in terms of bits) of the IP address while the number of 0s denotes the host part. The following example clarifies this notion.

Let’s consider theIP address that we have seen earlier and the subnet mask255.255.255.0. If we write these numbers on binary, then we have:         =             11000000 10001010 00000010 00000011     =             1111111111111111 11111111 00000000


                                                           Network part (n)              Host part(h)

From the above figure we can see that the first 3 octets of bits (24 bits) identify the network that the device belongs to, while the final octet identifies the device itself in that network. Since the subnet mask has 24 1s followed by 8 0s, apart from the dotted decimal format that we have seen: it can also be written as a prefix /24, showing the number of 1s that is consisted. Remember that a subnet mask always starts with a series of 1s (that is the number following the “/”) and is filled in with 0s up to 32 digits/bits.

As an example, there are three numbers that are not all valid subnet masks.à 1111111111111111 11111111 10000000   VALIDà 1111111111111111 11111111 11100000   VALID    à  1111111111111111 11111111 00000011  NOTVALID

The first two numbers are valid subnet mask numbers because of the series of continuous 1s,followed by a series of continuous 0s. The third number is not a valid subnet mask because the series of 1s is not followed by a series of 0s since there are also 1s in the last bits. Therefore, this is not a valid subnet mask value.

One last remark is that number n equals with the number of network bits in an IP address, while h equals with the number of host bits. Keep in mind that, since an IP address is 32-bit long, then h + n =32.


Addresses with a … class

A very popular network architecture, that was in use since the early 80s on the Internet, suggested that the IP address space should be divided in five different classes of addresses namely class A, B, C,D or E. Those classes created networks of different sizes by having different values on the network part (n) and the host part (h). At the following figure you can see the differences between the values of n and h in the IP addresses of the aforementioned classes.

From the above figure, it is easy to understand that for Class A n= 8 and h = 24 (24 = 32-8), therefore the number of networks that can be created is small (since n = 8) but each of these networks can support many hosts (h = 8+8+8 = 24), resulting in a possible network of large size. On the other hand, in Class B the number of available networks is increased (n = 8+8 = 16) while the number of possible hosts is decreasing (h =16), therefore such an address allows for the creation of more networks but each of smaller size. The same goes for Class C where again n increases and h decreases. Addresses of Class D and E cannot be given to our networks and they exist to serve special reasons that are out of the scope of this course.

The following figure clarifies the number of host and network bit per class.


Number of Network Bits (n)

Number of Host Bits (h)

Number of Hosts Per Network








216 – 2




28 – 2


For the calculation of the number of hosts per network, we use the formula 2h-2, where h are the hots bits of each class, and decrease of the hosts number by 2 is because in each network, 2 addresses are kept for special reasons: one for designating the whole network’s address and the other for broadcasting a message in this network.

Furthermore, in order to be able to understand the class to which an IP address belongs, there are two ways of doing so. The first is with the help of the subnet mask and can be seen in the figure below.Since Class A has n = 8 them the first 8 bits of the subnet mask (e.g., those that indicate the network part as has been mentioned above) should be equal to 1 and all the rest should be equal to 0. For Class B, n = 16 therefore the 16 bits (from the left) should equal with 1 while in Class C the first 24 bits equal with 1. At the end of each line you can, also, see the dotted decimal format of the subnet mask.


Class A:                 11111111             00000000             00000000             00000000      (

Class B:                 11111111             11111111             00000000             00000000      (

Class C:                 11111111             11111111             11111111             00000000      (


The second way to find the class that an IP address belongs to, is by looking on the address itself and especially on the value of the first octet. For Class A, where the first 8 bits of the IP address point to the network part, since for designing reasons the 1stbit must always be 0 (e.g., 0xxxxxxx),then the various combinations of IP addresses that follow that rule and,therefore, belong to Class A are all the addresses whose first octet of bits are between 00000000 and 01111111. That is the decimal numbers from 0 to 127. Since some of these addresses are reserved for other reasons the correct result is from 1 to 126. For Class B addresses the 2 first bits of the first octet are fixed as 10xxxxxx creating IP addresses from 128 to 191. Finally, for Class C the 3 first bits are reserved (110xxxxx) creating IP addresses from 192 to 223. The following table shows which IP addresses belong to which class along with some useful information that can be extracted from this.


Number of fixed Bits

First Octet Range

Valid Network Numbers

Number of Networks

Number of Hosts Per Network




1 - 126 –

27 – 2 = 126





127 – 191 –

214 = 16.384

216 - 2




192 - 223 –

221 = 2.097.152

28 - 2


The available number of networks in each case is given by 2n-i where is the number of bits in the network part and i is the number of fixed bit in the first octet (see 2ndcolumn). Therefore, Class A has 28-1 = 27 networks. The minus 2 for Class A is subjected to the fact that address is used for designating the default route, while the address for loopback tests.Therefore, these two special addresses do not belong to a certain class and that’s the reason for having 27 – 2 = 126 networks in Class A. This restriction does not apply to the other 2 classes.


Subnetting Basics

Up until now, we have considered that one IP address is given to a device and from this address we have learned to identify the class that the host belongs. But what happens if we want to create more than one networks and we have been assigned with only one IP address? Subnetting shows how we can create subnetworks from one given IP address.

In order to be able to create subnets someone must consider changing the values of the bits on the host part of the IP address and consider them, from now on as subnet bits (s). The number of subnets that we can create is related to the number of subnet bits (or s) in the network in fact it is equal to 2s. Therefore, by subnetting, the number of hosts per network is reduced (since h is decreased) but the number of subnets is increasing (since number of subnets = 2s). At the following example, we consider an IP address (the same as the one we used before) and we will try to create subnets from this address.

First we should try to write it down in bits:

11000000 10001010 00000010 00000011

Using the table above we can see that this address shows that the network belongs in Class C. Therefore, the subnet mask is The subnet mask in binary is:

11111111 11111111 11111111 00000000

Remembering that subnets are created by changing the values of host bits we can see that by selecting to change the two first host bits (i.e., the two first bits of the fourth octet for Class C addresses resulting in s = 2) then we can create 4 (22) subnets. The number of hosts for each subnet will be 2h-2 but = 6, therefore 62 hosts per subnet.

As an exercise, let’s try to find the IP addresses of the 4 equal subnets we can create.The word equal that is used means that the number of hosts that each subnet can have is the same for all the 4 subnets. Also, to complete this task, we will need to remember a magic number that is 2h which for our example equals 64 (h = 6).

Now, to find the address of the first subnet we should place 0s to the bits of the host part of the IP address. That is the last octet for the example:

11000000 10001010 00000010 00000000

In decimal this IP address is Now this is the first subnet’s address. The next subnet’s address (i.e., the second subnet) can be easily found by adding the magic number to the address of the previous subnet at the same octet, that is


-------------------- of the 2nd subnet)


-------------------- of the 3rd subnet)


-------------------- of the 4th subnet)

Now, we can see the IP address that belong to the 1st subnet. It would be from to, since is the first IP address of the next subnet. Now, the first address of each (sub)net is reserved to characterize the whole (sub)net and, therefore,cannot be received by any host. At the same time, the last IP address of each(sub)net is reserved as the broadcast address, an address to send a packet to all the devices in that network. Remember that these two address in each(sub)net are the reason that we have to extract 2 in order to find the number of hosts per (sub)network (2h-2). To summarize this, we can see that for the 1st subnet we have:

1st subnet network IP address:              

1st subnet first available IP address:          (

1st subnet last available IP address:      

1st subnet broadcast IP address:             (


To better understand the logic, we will continue with the related information regarding the 2nd subnet:


2nd subnet network IP address:               

2nd subnet first available IP address:       (

2nd subnet last available IP address:     

2nd subnet broadcast IP address:           (


For the 3rdsubnet:

3rd subnet network IP address:             

3rd subnet first available IP address:      (

3rd subnet last available IP address:     

3rd subnet broadcast IP address:            (


 And the 4th:

4th subnet network IP address:             

4th subnet first available IP address:      (

4th subnet last available IP address:     

4th subnet broadcast IP address:            (



Beyond the IP addressing, which is a fundamental skill of a network engineer, the routing process is also of a significant importance. The routing process defines the flow of information inside a network and can be implemented using two different techniques: the static routing or the dynamic routing. Usually the characteristics of the designed network topology determine which of those two techniques should be applied. However, it is network engineer’s responsibility to choose the proper technique in order to achieve the desired functionality.

Static routing fundamentals

In this section of the course, a closer look on the static routing technique takes place. In order to clearly understand the functionality of routing a brief analysis of the router’s operation should be made. The router is the device which determines the flow of the information in a network and the different routing techniques are applied on this device. Similarly,to post office in real life, the router checks the destination of the packet and then it forwards it to the fastest route. In order to decide which path the packet should follow, the router contains routing tables. Those tables are filled with IP addresses of the neighboring networks. So when a packet arrives to a router, the router checks its destination and uses the longest prefix matching technique in order to decide which route the packet should take. When the longest prefix matching technique takes place the router compares the destination IP address of the packet with the routing table’s addresses. This comparison is initiated digit by digit and finally the address that matches better wins and usually is the fastest route.

Table 1. Routing table and Destination IP

Network IPs

Destination IP



Table 2.Longest Prefix Matching

Network IPs

Destination IP








When a network engineer applies static routing, practically (s)he alters manually the routing tables. As a result, (s)he defines the flow of the information in the network as the routes become static.This routing method produces advantages and disadvantages that are discussed below.


Main advantages of Static routing

The implementation of static routing requires very good design of the network and advanced administration skills by the network engineer. One of the advantages provided by this technique is that it offers full network flow control to the network administrator. Furthermore, static routing can be used in small networks as it improves the security of the network, considering that the network access is always controlled by the network engineer. Also, when static route is applied, the routers are not consuming CPU resources as the routes are static and therefore routers with low CPU can be used. Finally, another advantage of this kind of routing is the fact that it does not consuming bandwidth, as it provides low overhead in the network.

Main disadvantages of Static routing

On the other hand, it can be considered as disadvantage the fact that static routing requires advanced networking skills and also very good knowledge of the network topology. Supposing that a new network administrator is hired to maintain the network of a company that is configured using static routing. The administrator should know every configuration that has taken place in every router, that is quite inefficient,especially when a network is medium or large size. Furthermore, if a network malfunction occurs, the troubleshooting time increases. Finally, the scalability of a network is restricted when static routing takes place, as every new network extension will lead to the reconfigure of all routers in the network.

In the hands on part of this course, a configuration of static routing in a network topology takes place. This process is extremely beneficial for academic purposes as the operation of routers and the construction of a fully functional network will add experience and knowledge to learners. Additionally, the operation of the router and the role of routing tables and longest prefix matching technique will be examined in practice.

Static routing implementation hands on

In this section of the course, the implementation of static routing technique takes place. Having in mind the theory of static routing and how it is applied, we proceed to the configuration of the routers in order to achieve an end to end connectivity. The network topology presented below is a scenario where static routing should be applied.The network topology is consisted of three routers, where each router has two Fast Ethernet network interfaces. 

Figure 1.Initial network topology

Based on the figure above the routers Router-1 and Router-3 use only the FastEthernet0/0 interface and only Router-2 uses both interfaces. It is worth mentioning that all the given IP addresses are of class C, therefore their subnet mask is /24. The interface of Router-1 has the IP and belongs to the network. However, the FastEthernet 0/0 interface of Router-2 has the IP address and belongs also to the network. The second interface of Router-2 has the IP address and belongs to the network similarly to the interface of Router-3, which has the IP address.

            Having in mind the information provided by the network topology, the configuration of the routers takes place.Each router should be configured via the Command Line Interface (CLI). The figure below displays how the proper configuration of a router can be accomplished. In this figure the process of configuring Router-1 is displayed.In order to access the privilege execmode the enable command is used. Then the configure terminal command is used to enter the global configuration mode where the most of our work takes place. Information related to exec mode, privilege exec mode and global configuration can be found in the Basic Network Router Configuration course.

Figure 2.Configuration of Router-1 via CLI

When the configure terminal command is applied we are able to see the config word inside the brackets (config). Now we are able to select the interface that we want to configure by using the command interface . In our case we choose FasEthernet0/0 interface. Then we are able to set the IP of the interface by executing the command ip address . In this use case we set the IP to and the subnet mask to (/24). It is worth mentioning that the default state of the interface is down, therefore the no shutdown command is used in order to enable the interface. In order to exit the global mode we may use the end command.

Similarly, we are able to configure all the routers in the network topology according to our scenario. When this basic configuration is done, the IPs of the same network will be able to communication (ping one another) but IPs of different network will not. The solution to this problem is the implementation of routing techniques and in our case the implementation of static routing.

Figure 3.Static routing configuration for Router-1

In order to apply static routing we should enter first to the global mode as it is displayed above. Then we manual change the  routing table of the router and we set routes by using the command: ip route . The above figure presents the configuration of static routing in Router-1 where we set the route. We want to reach the network with subnet mask /24 via the which belong to Router-2. When we are done with the configuration we exit the global mode. If we want to save our work we use the copy running-config startup-config.

Similarly, we perform static routing to Router-2 and Router-3 as the figures below display. It is worth mentioning that we should set all the necessary routes in order to achieve end to end connectivity. In example, if we set the routes in Router-1 and Router-2 and forget the Router-3 we will not have end to end connectivity if we try to ping from Router-1 to Router-3 because the ICMP packets of Router-1 will reach Router-3 but the reply from Router-3 will never reach Router-1.

Figure 4. Static routing configuration for Router-2

Figure 5. Static routing configuration for Router-3

When the configuration of those three routers is complete and all the interfaces are up then or final network topology will display green lights as the figure below displays.

Figure 6. Final network topology

Figure 7.Connectivity check

Finally, in order to check the end to end connectivity we try to ping the Router-1 from Router-3 and we also perform traceroute. The figure above presents the results of our test where we achieved end to end communication.

The aforementioned scenario is an example of the static routing implementation. Nevertheless, in the following interactive section students will have a hands on experience by performing static routing using the PT Anywhere tool. In the interactive part, students should create an identical topology like the one that has been presented, and perform similar actions in order to achieve end to end connectivity. 

Introduction to Dynamic routing

Beyond the static routing there is also the dynamic routing technique which is presented in this section of the course. In contrast to static routing, the dynamic technique uses routing protocols. Those routing protocols are responsible for updating the routing tables and also for network discovery and network communication, as they define the rules of communication among the routers. Some of the protocols used in dynamic routing are the RIPv1 (Routing Information Protocol version 1), the RIPv2 (Routing Information Protocol version 2), the OSPF (Open Shortest Path First) and the EIGRP (Enhanced Interior Gateway Routing Protocol). However, the choice of which protocol should be used is engineer’s responsibility. Later on, information related to certain routing protocols are displayed and examined. 

Furthermore, the dynamic routing is the preferred technique for small, medium and large size networks as it can be easily implemented (simply activate and configure the protocols). Also it provides scalability to a network considering that it automatically adapts to network topology changes (add or remove routers). Nevertheless, due to protocols usage this kind of technique requires routers with CPU, memory and bandwidth to the communication links as it introduces overhead to the network.

Focusing on the protocols operation, for the route computations algorithms are used. The algorithms used in routing protocols can be divided in two categories: the link state algorithms and the distance vector algorithms. On the one hand, when link state protocols are used, the router constructs a map with the available routers of the network in the form of a graph, where each path is calculated by the router and acquires a value (e.g Dijkstra algorithm). On the other hand, when distance vector protocols are used, the router calculates the path based on the hop count where the hop is a node (Bellman-Ford). Finally, when distance-vector protocol is used the router should inform periodically its neighboring routers for topology changes in contrast to link-state protocols where a router informs all the network nodes when topology changes.

Figure 8.Dijkstra algorithm


RIPv2 (Routing Information Protocolversion 2)

The RIPv2 is a classless distance-vector protocol,which means that it is used in networks with the same subnet mask (e.g /24).When RIPv2 is used, the router periodically transmits updates to the other routers configured with the same protocol. Usually RIPv2 is used in small size networks as the lifetime of the protocol can reach 15 hops, which means 15 routers, then the packet is dropped.

OSPF (Open Shortest Path First)

The OSPF protocol is a quite popular protocol as it is very flexible, scalable and can be used in any kinds of network(small, medium and large networks). This protocol is link-state and uses the Dijkstra algorithm and has no hop count limitation. The OSPF protocol provides the ability to divide a large network into many small networks which are called areas. This ability is very useful for administration and troubleshooting purposes. Additionally, OSPF supports VLSM/CIDR networks and it is preferred instead of RIPv1 and RIPv2 when dynamic routing as to be applied. Finally, each router informs the whole network regarding its neighbors state, so every router in a network has a complete overview of the network neighborhood. Also, OSPF can be used under specific criteria such as network traffic.

Table 3. OSPF vs RIPv1 and RIPv2





Type of protocol

Link state

Distance vector

Distance vector

Classless support




VLSM support








Manual summarization




Noncontiguous support




Route propagation

Multicast on change

Periodic multicast

Periodic broadcast

Path metric




Hop count limit








Peer authentication




Hierarchical network requirement

Yes (using areas)

No (flat only)

No (flat only)


Event triggered



Route computation




Main advantages of Dynamic routing

The dynamic routing provides lots of benefits in the design and maintenance of a network and reduces the workload of the network engineer. One of the main advantages of dynamic routing technique is that the routes are automatically created by the usage of protocols, therefore no manual configuration of routes is needed. In addition, this type of routing can be used independently of the size of the network, therefore it adds scalability to our system and automatically removes the complexity in matters of network administration and troubleshooting. Finally, the aforementioned advantages are able to justify why this type of routing is used in almost any network.

Main disadvantages of Dynamic routing

            However, the fact that routing tables are automatically updated, when dynamic routing is used in a network,has as a result increased networking traffic and overhead introduction to the network. Also, the usage of this type of routing demands routers with stronger CPU than those used in static routing, therefore the cost of those routers increases.Finally, the dynamic routing technique cannot provide the security that was presented by the static routing technique due to its nature (no manual route configuration is needed).

Concluding, a hands on part of dynamic routing follows, where the configuration of a network topology based on OSPF protocol takes place. This process is extremely beneficial for academic purposes as the operation of routers and the construction of a fully functional network will add experience and knowledge to learners. Additionally, the functionality of the dynamic routing is highlighted with the usage of OSPF.


Dynamic routing implementation hands on

In this section of the course, the implementation of dynamic routing technique takes place. Having in mind the theory of dynamic routing and the protocols functionality, we proceed to the configuration of the routers in order to achieve an end to end connectivity.The network topology presented below is a scenario where static OSPF dynamic routing protocol should be applied. The network topology is consisted of four routers, where each router has two Fast Ethernet network interfaces.