Monday, 1 April 2013


IP Routing Technology
Routing is the process by which a packet gets from one location to another. To route a packet, a router needs to know the destination address and on what interface to send the traffic out .When a packet comes into an interface (in interface) on a router, it looks up the destination IP address in the packet header and compares it with its routing table. The routing table, which is stored in RAM, tells the router which outgoing interface the packet should go out to reach the destination network. There are three ways to control routing decisions on your router:
  • Static routes
  • Default route
  • Dynamic routes

Static Routes

Use a static route when you want to manually define the path that the packet will take through your network. Static routes are useful in small networks with rarely changing routes, when you have little bandwidth and do not want the overhead of a dynamic routing protocol, or when you want to manually define all of your routes for security reasons. Static routes are created in global configuration mode. The syntax for the static route is as follows:
 ip route destination network address [subnet mask] {next-hop-address | interface] [distance] 

Defaults routers

This is the special type of static route, commonly called the gateway of last resort. If the specified destination is not listed in the routing table, the default route can be used to route the packet. A default route has an IP address of 0.0.0.0 and a subnet mask of 0.0.0.0, often represented as 0.0.0.0/0. Default routes are commonly used in small networks on a perimeter router pointing to the directly connected ISP router.

Dynamic Routes

A router learns dynamic routes by running a routing protocol. Routing protocols will learn about routes from other neighboring routers running the same routing protocol. Through this sharing process, a router will eventually learn about all of the reachable network and subnet numbers in the network.
Now be familiar with the terms routing protocol and routed protocol that have two different meanings. A routing protocol learns about routes for a routed protocol.

Routed protocol:

Any network protocol that provides enough information in its network layer address to enable a packet to be forwarded from one host to another host based on the addressing scheme, without knowing the entire path from source to destination. Packets generally are conveyed from end system to end system. IP is an example of a routed protocol.

Routing protocol:

Facilitates the exchange of routing information between networks, enabling routers to build routing tables dynamically. Traditional IP routing stays simple because it uses next-hop (next-router) routing, in which the router needs to consider only where it sends the packet and does not need to consider the subsequent path of the packet on the remaining hops (routers). Routing Information Protocol (RIP) is an example of a routing protocol.
There are two types of routing protocols:
  • Interior Gateway Protocols (IGP): These routing protocols exchange routing information within an autonomous system. Routing Information Protocol version 2 (RIPv2), Enhanced Interior Gateway Routing (EIGRP), and Open Shortest Path First (OSPF) are examples of IGPs.
  • Exterior Gateway Protocols (EGP): These routing protocols are used to route between autonomous systems. Border Gateway Protocol (BGP) is the EGP of choice in networks today.

Metrics

Metrics can be calculated based on a single characteristic of a path. More complex metrics can be calculated by combining several path characteristics. The metrics that routing protocols most commonly use are as follows:
  • Hop count: The number of times that a packet passes through the output port of one router
  • Bandwidth: The data capacity of a link; for instance, normally, a 10-Mbps Ethernet link is preferable to a 64-kbps leased line
  • Delay: The length of time that is required to move a packet from source to destination
  • Load: The amount of activity on a network resource, such as a router or link
  • Reliability:Usually refers to the bit error rate of each network link
  • Cost:A configurable value that on Cisco routers is based by default on the bandwidth of the Interface

Routing ProtocolsMetricDescription
RIPHop countHow many layer 3 hops away from the destination
OSPFCostMeasurement in the inverse of the bandwidth of the links
EIGRPBandwidthThe capacity of the links in Kbps (T1 = 1554)
EIGRPDelayTime it takes to reach the destination
EIGRPLoadThe path with the least utilization
EIGRPMTUThe path that supports the largest frame sizes
EIGRPReliabilityThe path with the least amount of errors or down time

Autonomous Systems

An autonomous system (AS) is a group of networks under a single administrative control, which could be your company, a division within your company, or a group of companies.
Not every routing protocol understands the concept of an AS. Routing protocols that understand the concept of an AS are EIGRP, OSPF, IS-IS, and BGP. RIP doesn’t understand autonomous systems, while OSPF does; but OSPF doesn’t require you to configure the AS number, whereas other protocols, such as EIGRP, do.

Administrative Distance

Administrative distance is the measure of trustworthiness that a router assigns to how a route to a network was learned. 
An administrative distance is an integer from 0 to 255. A routing protocol with a lower administrative distance is more trustworthy than one with a higher administrative distance.
Administrative DistanceRoute Type
0Connected interface route
1Static route
90Internal EIGRP route (within the same AS)
110OSPF route
120RIPv1 and v2 route
170External EIGRP (from another AS)
255Unknown route (is considered an invalid route and will not be used)
Routing protocols can be further classified into two categories:
  • Distance vector routing protocols
  • Link state routing protocols

Distance vector–based routing algorithms (also known as Bellman-Ford-Moore algorithms) pass periodic copies of a routing table from router to router and accumulate distance vectors. (Distance means how far, and vector means in which direction.) Regular updates between routers communicate topology changes.
Sometimes these protocols are referred to as routing by rumor, since the routers learn routing information from directly connected neighbors, and these neighbors might have learned these networks from other neighboring routers. RIP is an example of a routing protocol that is a distance vector.

Advertising Updates

Routers running distance vector protocols learn who their neighbors are by listening for routing broadcasts on their interfaces. No formal handshaking process or hello process occurs to discover who are the neighboring routers. Distance vector protocols assume that through the broadcast process, neighbors will be learned, and if a neighbor fails, the missed broadcasts from these neighbors will eventually be detected
Distance vector algorithms call for each router to send its entire routing table to each of its adjacent or directly connected neighbors. Distance vector routing tables include information about the total path cost (defined by its metric) and the logical address of the first router on the path to each network it knows about.
When a router receives an update from a neighboring router, it compares the update to its own routing table. The router adds the cost of reaching the neighboring router to the path cost reported by the neighbor to establish the new metric. If the router learns about a better route (smaller total metric) to a network from its neighbor, the router updates its own routing table.

Distance Vector Protocol Problems and Solutions

Problem: Convergence

The term convergence refers to the time it takes for all of the routers to understand the current topology of the network. When a router receives an update from a neighboring router, it compares the update to its own routing table. The router adds the cost of reaching the neighboring router to the path cost reported by the neighbor to establish the new metric. If the router learns about a better route (smaller total metric) to a network from its neighbor, the router updates its own routing table. It’s too time consuming process. Because in a 10 router topology last router will know about the network of first router only while all middle router will complete their periodic update. For example if interval timer is set to 60 second then last router will know about first network in 60*8 480 second or 8 minute.

Solution: Change the periodic timer interval

One solution is to change the periodic timer interval. For instance, in an example the timer was set to 60 seconds. To speed up convergence, you might want to set the interval to 10 seconds. Also, by setting the timer to 10 seconds, you are creating six times the amount of routing broadcast traffic, which is not very efficient

A second solution is to implement triggered updates

The distance vector routing protocol would still generate periodic updates; however, whenever a change takes place, the router will immediately generate an update without waiting for the periodic timer to expire. This can decrease convergence times, but it also creates a problem. If you have a flapping route, then an update will be triggered each time the route changes state, which creates a lot of unnecessary broadcast traffic in your network and could cause a broadcast storm.

Problem: Routing Loops

A routing loop is a layer-3 loop in the network. Basically, it is a disagreement about how to reach a destination network. Because distance vector routing protocols trust the next router without compiling a topology map of all networks and routers, distance vector protocols run the risk of creating loops in a network. This is analogous of driving to a location without a map. Instead, you trust what each sign tells you. Trusting the street signs might get you where you want to go, but I've been in some cities where trusting what the signs say will lead you in loops. The same is true with distance vector routing protocols. Simply trusting what the next router tells it can potentially lead the packets to loop endlessly. These loops could saturate a network and cause systems to crash. This, in turn, makes managers very upset and means that you have to work late into the evening to fix it.

Solution: Counting to Infinity Solution: Maximum Hop Count

IP packets have inherent limits via the Time-To-Live (TTL) value in the IP header. In other words, a router must reduce the TTL field by at least 1 each time it gets the packet. If the TTL value becomes 0, the router discards that packet. However, this does not stop the router from continuing to attempt to send the packet to a network that is down. To avoid this prolonged problem, distance vector protocols define infinity as some maximum number. This number refers to a routing metric, such as a hop count.

Solution: Split Horizon

Split horizon states that if a neighboring router sends a route to a router, the receiving router will not propagate this route back to the advertising router on the same interface. Split horizon prevents a router from advertising a route back out the same interface where the router originally learned the route. One way to eliminate routing loops and speed up convergence is through the technique called split horizon. The split horizon rule is that sending information about a route back in the direction from which the original update came is never useful.

Solution: Route Poisoning

Another operation complementary to split horizon is a technique called route poisoning. Route poisoning attempts to improve convergence time and eliminate routing loops caused by inconsistent updates. With this technique, when a router loses a link, the router advertises the loss of a route to its neighbor device. Route poisoning enables the receiving router to advertise a route back toward the source with a metric higher than the maximum. The advertisement back seems to violate split horizon, but it lets the router know that the update about the down network was received. The router that received the update also sets a table entry that keeps the network state consistent while other routers gradually converge correctly on the topology change. This mechanism allows the router to learn quickly of the down route and to ignore other updates that might be wrong for the hold-down period. This prevents routing loops.
A poisoned route has an infinite metric assigned to it. A poison reverse causes the router to break split horizon rule and advertise the poisoned route out all interfaces. When a router detects that one of its connected routes has failed, the router will poison the route by assigning an infinite metric to it. In IP RIP, the route is assigned a hop count of 16 (15 is the maximum), thus making it an unreachable network. When a router advertises a poised route to its neighbors, its neighbors break the rule of split horizon and send back to the originator the same poisoned route, called a poison reverse. This ensures that everyone received the original update of the poisoned route.

Solution:Hold-Down Timers

In order to give the routers enough time to propagate the poisoned route and to ensure that no routing loops occur while propagation is occurring; the routers implement a hold-down mechanism. During this period, the routers will freeze the poisoned route in their routing tables for the period of the hold-down timer, which is typically three times the interval of the routing broadcast update. When hold-down timers are used, a poisoned route will remain in the routing table until the timer expires. However, if a router with a poisoned route receives a routing update from a neighboring router with a metric that is the same or better than the original route, the router will abort the hold-down period, remove the poisoned route, and put the new route in its table. However, if a router receives a worse route from a neighboring router, the router treats this as a suspect route and assumes that this route is probably part of a routing loop, ignoring the update. One of the problems of using hold-down timers is that they cause the distance vector routing protocol to converge slowly—if the hold-down period is 180 seconds, you can’t use a valid alternative path with a worse metric until the hold-down period expires. Therefore, your users will lose their connections to this network for at least three minutes.
Hold-down timers perform route maintenance as follows:
  • When a router receives an update from a neighbor indicating that a previously accessible network is now inaccessible, the router marks the route as inaccessible and starts a hold-down timer.
  • If an update arrives from a neighboring router with a better metric than originally recorded for the network, the router marks the network as accessible and removes the hold-down timer.
  • If at any time before the hold-down timer expires, an update is received from a different neighboring router with a poorer metric, the update is ignored. Ignoring an update with a higher metric when a holddown is in effect enables more time for the knowledge of the change to propagate through the entire network.
  • During the hold-down period, routes appear in the routing table as “possibly down.”

Sunday, 31 March 2013

IP Subnetting


Method of Subnetting Benefits of Subnetting

Subnetting is the most tested topic of CCNA. In this article I would show you the method of subnetting.


Benefit of Subnetting


Reduced network traffic

One network will not access the data of other network without the use of router. Thus we can reduce the amount of data remain in one network. Less data less overhead, collision, or broadcast storm.

Optimized network performance

This is a result of reduced network traffic.

Simplified management

It's easier to identify and isolate network problems in a group of Smaller connected networks than within one gigantic network. Facilitated spanning of large geographical distances Because WAN links are significantly slower and more expensive than LAN links, a single large network that spans long distances can create problems in every area earlier listed. Connecting multiple smaller networks makes the system more efficient.

Powers of 2

Powers of 2 are important to understand and memorize for use with IP subnetting.
21229512
2242101024
2382112048
24162124096
25322138192
266421416384
2712821532768
2825621665536
Before we go further let's get familiar with subnetting components

Subnet mask

A subnet mask is a 32-bit value that allows the receiver of IP packets to distinguish the network ID portion of the IP address from the host ID portion of the IP address. Every IP address is composed of a network component and a host component. The subnet mask has a single purpose: to identify which part of an IP address is the network component and which part is the host component. Subnet mask value 0 represent host ID while subnet mask value 1 to 255 represents Network ID in ip address.

Classless Inter-Domain Routing (CIDR)

This slash notation is sometimes called CIDR (Classless Inter-Domain Routing) notation. It's basically the method that ISPs (Internet service providers) use to allocate a number of Addresses to a company, a home—a customer. The slash notation is simply the number of 1s in a row in the subnet mask. The real reason to use CIDR notation is simply that it is easier to say and especially to type.

Address Class and Default Mask

Subnetting happens when we extend the subnet mask past the default boundary for the address we are working with. So it's obvious that we first need to be sure of what the default mask is supposed to be for any given address. When faced with a subnetting question, the first thing to do is decide what class the address belongs to. And later decide what the default subnet mask is. One of the rules that Cisco devices follow is that a subnet mask must be a contiguous string of 1s followed by a contiguous string of 0s. There are no exceptions to this rule: A valid mask is always a string of 1s, followed by 0s to fill up the rest of the 32 bits. (There is no such rule in the real world, but we will stick to the Cisco rules here—it's a Cisco exam, after all.) Therefore, the only possible valid values in any given octet of a subnet mask are 0, 128, 192, 224, 240, 248, 252, 254, and 255. Any other value is invalid.

Block Size

The process of subnetting creates several smaller classless subnets out of one larger classful . The spacing between these subnets, or how many IP addresses apart they are, is called the Block Size.

Network ID and Broadcast ID

The first address in a network number is called the network address, or wire number. This address is used to uniquely identify one segment or broadcast domain from all the other segments in the network.
The Broadcast ID
The last address in the network number is called the directed broadcast address and is used to represent all hosts on this network segment. it is the common address of all hosts on that Network ID. This should not be confused with a full IP broadcast to the address of 255.255.255.255, which hits every IP host that can hear it; the Broadcast ID hits only hosts on a common subnet. A directed broadcast is similar to a local broadcast.
The main difference is that routers will not propagate local broadcasts between segments, but they will, by default, propagate directed broadcasts.

Host Addresses

Any address between the network address and the directed broadcast address is called a host address for the segment. You assign these middle addresses to host devices on the segment, such as PCs, servers, routers, and switches.

Method of Subnetting

There is several method of subnetting. Different author different approach to calculate the subnets. You should choose the method you can understand and perform subnetting easily. Whatever approach you choose need conversion of decimal to binary. Cram up this chart
2726252423222120
1286432168421
To convert a decimal number into binary, you must turn on the bits (make them a 1) that would add up to that number, as follows:
187 = 10111011 = 128+32+16+8+2+1
224 = 11100000 = 128+64+32
To convert a binary number into decimal, you must add the bits that have been turned on (the 1s), as follows:
10101010 = 128+32+8+2 = 170
11110000 = 128+64+32+16 = 240
The IP address 138.101.114.250 is represented in binary as
 10001010.01100101.01110010.11111010 
The subnet mask of 255.255.255.224 is represented in binary as
 11111111.11111111.11111111.11100000 

Practical approach of subnetting

When faced with a subnetting question, the first thing to do is decide what class the address belongs to. for examples:
192.168.1.1
The first octet is between 192 and 223 so it is a Class C address
Default mask for Class C: is 255.255.255.0
In exam default subnet mask is not subnetted. Now write down the given ip address as shown here. Write down the default side of IP as it is and reset of part where actual subnetting will perform in binary
192.168. 1 .00000001
255.255.255.00000000
(defaul maks)
Step 1:- calculate the CIDR value
CIDR are the on bit in subnet mask. As you can see in our example we have on bit only in default side.
255.255.255.00000000
So our CIDR value is 24 + 0 = 24
Step 2:- calculate the Subnet mask
To calculate the subnet mask use the binary to decimal chart given above. Add the decimal place value of on network bit.
              <==H bit
 255.255.255.00000000
 N bit==>
In our example we are using on default mask so our subnet mask will be 255.255.255.0
Step 3:- calculate the Total Host
To calculate the total host count the H bit and use this formula
Total host = 2H
             <==H bit
 255.255.255.00000000
 Total host = 28 = 256
Step 4:- calculate the Valid Host
Subtract 2 from Total host Every network or subnet has two reserved addresses that cannot be assigned to a host. These addresses are called the Network ID and the Broadcast ID, respectively. They are the first and last IPs in any network or subnet. We lose those two IP addresses from the group of values that could be assigned to hosts.
Total host - 2
256 -2 = 254
Step 5:- calculate the Network
To calculate the Network count the N bit and use this formula
Network = 2N
255.255.255.00000000
            N bit==>
Network = 20 = 1 
Step 6:- Find out the block Size 
Finding block size is very easy just subtract the subnet mask from 256
256 – Subnet mask
(only the last octal, don't include the default subnet mask)
256 - 0 = 256
Step 7:- Write down the subnet chart
Network 1
CIDR Value /24IPSunetmask
Net ID192.168.1.0255.255.255.0
First Valid Host192.168.1.1255.255.255.0
Last Valid Host192.168.1.254255.255.255.0
Broadcast ID192.168.1.255255.255.255.0


Subnetting of CIDR /25


Now do the subnetting of CIDR /25 using same method
Step 1:- calculate the CIDR value CIDR = sum of all on bit in subnet mask
255.255.255.10000000
So our CIDR value is 24 + 1 = 25
Step 2:- calculate the Subnet mask
Add the decimal place value of on network bit.
              <==H bit
 255.255.255.10000000
    N bit==>
In our example we have one on bit and as you can see in decimal chart the place value of 1000000 is 128 so our subnet mask will be 255.255.255.128
Step 3:- calculate the Total Host
Total host = 2H <==H bit 255.255.255.10000000 Total host = 27 = 128 
Step 4:- calculate the Valid Host
Subtract 2 from Total host
Total host - 2
128 -2 = 126
Step 5:- calculate the Network
To calculate the Network count the N bit and use this formula
Network = 21 255.255.255.10000000 N bit==> Network = 21 = 2 
Step 6:- Find out the block Size
256 – Subnet mask (only the last octal, don't include the default subnet mask) 256 - 128 = 128
With help of block size you can easy find out the network ID and broadcast ID of all possible networks as we have 8 bits in one octal those can give maximum of 28 = 256 decimal number
We start from 0 so it will end up on 255 (Do not get confuse because we are counting from 0 not from 1 so the last digit will be 255 not 256. It will 256 only when you count from 1 ). All subnetting will perform between these two numbers.
Create a table of x Columns where x is the number of your network
First ip of first network will always be 0 and last ip of last network will be 255 fill its in chart 
Now you have network ID of first network and broadcast ID of last network.
Now add block size in the first ip of first network to get the network ID of second network and so on till we get the network id of last network
 First network ID 0 Second Network ID 0 +128 = 128
Fill this in Chart.
As you can see from 128 next network is started so the last IP of first network will be 127 fill it in chart. With this method you can fill the last ip of all networks.
Now you have first ip ( network ID ) of all networks and the last ip (Broadcast ID) of all networks. At this point you can easily fill the valid ip in each network. As valid hosts are all ip address those fall between network ip and host ip.
Step 7:- Write down the subnet chart
CIDR /25Network 1Network 2
Net ID192.168.1.0192.168.1.128
First Valid Host192.168.1.1192.168.1.129
Last Valid Host192.168.1.126192.168.1.254
Broadcast ID192.168.1.127192.168.1.255

Binary ANDing

Binary ANDing is the process of performing multiplication to two binary numbers. In the decimal numbering system, ANDing is addition: 2 and 3 equals 5. In decimal, there are an countless number of answers when ANDing two numbers together. However, in the binary numbering system, the AND function give up only two possible outcomes, based on four different combinations. These answers, can be displayed as a truth table:
 0 and 0 = 0 1 and 0 = 0 0 and 1 = 0 1 and 1 = 1
You use ANDing most often when comparing an IP address to its subnet mask. The end result of ANDing these two numbers together is to give up the network number of that address.

Example Question

What is the network number of the IP address 192.168.100.115 if it has a subnet mask of 255.255.255.240?
Answer
Step 1 Convert both the IP address and the subnet mask to binary:
192.168.100.115 = 11000000.10101000.01100100.01110011
255.255.255.240 = 11111111.11111111.11111111.11110000
Step 2 Perform the AND operation to each pair of bits—1 bit from the address ANDed to the corresponding bit in the subnet mask. Refer to the truth table for the possible outcomes:
192.168.100.115 = 11000000.10101000.01100100.01110011
255.255.255.240 = 11111111.11111111.11111111.11110000
  ANDed result = 11000000.10101000.01100100.01110000
Step 3 Convert the answer back into decimal:
11000000.10101000.01100100.01110000 = 192.168.100.112
The IP address 192.168.100.115 belongs to the 192.168.100.112 network when a mask of 255.255.255.240 is used.

My easy method

Conversion of decimal to binary and vice versa to get network ID is too time consuming process in exam. So I found this easy method.
Step 1:- Decide from which class this IP belongs and what's its default subnet mask
As given IP have 192 in its first octal so it's a class C IP. And default subnet mask of class C is 255.255.255.0
Step2:- Find out the block size. ( As we describe above)
 256 -240 = 16
Step3:- Write down all possible network using block size till we do not get our host partition in middle of two network
 0,16,32,48,64,80,96,112,128,
As our host number is 115 which fall in the network of 112 so our network ID is
 192.168.1.112
And our host's broad cast ID is 192.168.1.127 as from 128 onward next network will start. Easy as I promise