Showing posts with label step. Show all posts
Showing posts with label step. Show all posts

Mar 12, 2013

Lesson 26 - Binary World


Now this is a real fun part, which I love and am never tired of explaining :) 
The routing world awaits. But before we plunge into its depths, it is imperative that we become fluent with conversions between decimal and binary numeral systems. Why? Because all electronic devices such as our beloved computers and routers use binary numbers. On the other hand, we humans tend to use decimal notations almost all the time.

Believe it or not but the binary numeral system is easier to understand than the decimal one. But our problem is that we have been using the decimal notation for so long that looking at anything different feels very awkward.

It is good to know that all numeral systems (binary, octal, decimal, hexadecimal, the-one-you-may-want-to-create) are based on the same foundations. There are two major components of a numeral system: the base and the exponent.

Pic. 1 - Numeral System Components - The Formula.


I almost hear your thought: 'Eh... what?' Fear not. It's easy to understand if you remember the math at the elementary level.

The base in the above formula is determined based on how many digits (or characters) we use to denote the number. Consider the decimal system. We have exactly 10 digits to express the volume:0,1,2,3,4,5,6,7,8,9. So, the in decimal numeral system the base = 10 (ten digits available). What happens when we have more of something than 9?

It is simple we engage a new column of numbers on the left and zero the number on the right: 10. This way we get ten. The first column denotes the number of 10s and the next column, denotes the units. As soon as we run out of numbers in the unit columns, we increase the number in the columns of tens. For instance: 17, 18, 19... 20.

What happens when we run out of the number of the column of tens? We add one more column on the left, which is the columns of 100s and zero all other columns on the right. For instance: 9798,99... 100.

We know that in the four column number: 1048 the first column (1) on the left denotes thousands, the next to the right (0) denotes hundreds, the one next to it (4) denotes tens, and the last one (8) describes units. The column in each and every numeral system has the weight.

Check the picture below to see this in more detail.

Pic. 2 - Decimal Numbers - Formula.


Using the formula you calculate the numbers in decimal as shown in the next picture (pic. 3). Each number in the column must be multiplied by the corresponding weight of the column. These in turn, must be added together to give you the number. Pic. 3 shows that in more detail. Make sure that you understand it before you proceed with your reading.
Pic. 3 - Example of Decimal Numbers According to the Formula.
In exact same way we create others such as the binary numeral system. Here, our base is going to use only two digits: 1 or 0 called bits. Thus, our base = 2 (only two digits available). Since, we most often cluster 8 bits together to form a byte, our colums and weights are going to look as in the picture below (pic. 4).
Pic. 4 - Binary Numbers - Formula.



NOTICE!
Cisco expects their engineers to be able to do the binary-to-decimal and decimal-to-binary conversions WITHOUT using a calculator (using a paper and pen only).



Binary-to-Decimal Conversion

In order to convert the binary number to its decimal equivalent, you must follow the exact same rules explained for decimal system. You multiply the number in the column by its weight in every columns. The products of these multiplications must be added together.Take a look at the example in the pic. 5.

Pic. 5 - Examples of Binary-to-Decimal Conversion.


In order to practice those try to quickly convert the following binary to decimal (DO NOT USE A CALCULATOR):
Ex1: 11011010 (calculated above)
Ex2: 10011101 (calculated above)
Ex3: 11001011
Ex4: 00100101
Ex5: 01010101
Ex6: 11111010
Ex7: 01101101.

It should not take you more than a few seconds per example. Check your results using a calculator.

When it comes to opposite conversion it is a bit more difficult, but still at the elementary math level.

Decimal-to-Binary Conversion
The best way to learn how to do the conversion is actually do it and analyse every step of the way.

Example1: the decimal value of 172, to be converted into the binary.

The following table is going to come in handy.

Pic. 6 - Decimal-to-Binary Conversion.




Step 1
Find the closest weight value in the binary table that does NOT exceed the value you convert.

In the example1, the closest weight is: 128. The weight of the next column (here, non-existent column 9) would exceed the value of 172, since the weight of it is 256.


Step 2
In our handy table, write in ‘1’ in the column you have chosen.

Pic. 7 - Decimal-to-Binary Conversion.





Step 3
From the initial decimal number take away the weight you have used (the ‘1’ you put in the table takes away the weight from the number you are converting).

In the example1, the decimal number we have is: 172 and the weight we just used by putting a ‘1’ in our table is: 128. So, our calculation looks like the one below:

172 – 128 = 44


Step 4
Check if the number you have left (in our example the value left is: 44) is larger or smaller than the weight of the next column on the right-hand side in our table.


a) If the number you have left is larger than the weight in the next column to the right, put in ‘1’ in the next column and subtract its weight from the number you have left.

b) If the number you have left is smaller than the weight in the next column to the right, put in ‘0’ in the next column and perform the same check against the next column (step 4a). You have to do it until the check in step 4a is true.

In the example1, the value we have left is: 44. We check it against the weight in the next column on the right. The number (44) is smaller than the weight in the next column to the right (64). Since 44 < 64, we follow the instructions in the step 4b.

Pic. 8 - Decimal-to-Binary Conversion.


The next check against step 4a is true! Since 44 > 32, we put in a ‘1’ in the next column and take away the weight (32) from the number we have left (44).
Pic. 9 - Decimal-to-Binary Conversion.


44 – 32 = 12


We go back to the step 4.

The number we are left with (12) is smaller than the weight of the next column to the right (16). Since12 < 16, we proceed to the step 4b.

Pic. 10 - Decimal-to-Binary Conversion.



The next check against step 4a is true! Because 12 > 8 we put in a ‘1’ in the next available column on the right and take away its weight (8) from the number we are left with now (12).


Pic. 11 - Decimal-to-Binary Conversion.


12 - 8 = 4

The difference is: 4. I hope you already know what is going to happen. Step 4a is true, so we put in a ‘1’ in the column and take away the weight from the number.

Pic. 12 - Decimal-to-Binary Conversion.


4 - 4 = 0 

The difference now reaches 0, so we fill in the remaining columns with 0.

Pic. 13 - Decimal-to-Binary Conversion.


In order to practice those try to quickly convert the following binary to decimal (DO NOT USE A CALCULATOR):
Ex1: 172 (calculated above)
Ex2: 67
Ex3: 124
Ex4: 168
Ex5: 215
Ex6: 237

It should not take you more than a few seconds per example. Check your results using a calculator.

Understanding and fluency with the conversion is the pre-requisite to calculating IP subnets, maximizing the addresses per subnets etc.

In my next post, we will take a look at IP address and play with subnet calculations.

Mar 11, 2013

Lesson 14 - NTP and Syslog Services



My previous three posts were a humble attempt to show you some real life networking issues and how to go about them using the skills described so far.

In this lesson I would like to present two services that are extremely important in management of your switches and routers: Network Time Protocol, and Syslog Services. Even though you will not find them in CCNA curriculum, it is good idea to know what is their role and how to quickly configure them on your devices.

System Messages
If you work as a network admin, it is critical that you collect and analyze system messages sent by switches and routers. IOS can send those important messages to the console port 0 by default. You can store them in the switch or router's memory but they will be purged if you have power outage or reboot your device. Also, memory will store as many of them, and then it will begin to overwrite the oldest ones. We need to redirect them to an external server. One of the popular services used to collect system messages is called: Syslog Server. If you are Window user you must probably pay for such server software (although KIWI server used to be freeware, but I don't know if it still free software). Unix and Linux have this service installed by default. All you have to do is to set it up correctly, so it accepts messages from external clients.

System messages have the different levels of severity as shown below.

0 - Emergency - System-unusable messages
1 - Alert - Take immediate action
2 - Critical - Critical condition
3 - Error - error message
4 - Warning - warning message
5 - Notice - normal but significant condition
6 - Informational - information message
7 - Debug - debug messages and log FTP commands and WWW URLs

As you see, the lower the number the higher severity the level is. I'm sure I don't have to tell you that the levels 0-3 will need your special attention, do I?

System Logging Message takes the following format:

timestamp%<facility>-<severity>-<mnemonic>: <message-text>

Take a look at such message as sent by IOS (Pic. 1)

Pic. 1 - IOS Syslog Message Example.

Network Time Protocol (NTP)
All messages should carry a time stamp. The time of an event allows administrator to see when things went hairy and correlate them with other events that might follow. The problem is that Cisco devices do not keep the date and time like computers do. In order for them to keep the track of time you must either manually set the clock with 'clock' command or synchronize their time with some external sources. The first method is not recommended as after reboot, a router or switch loses its time. That is why the second method is recommended using NTP protocol.

It is not my intention to give you an in-depth description of NTP and syslog services. Instead, I would like to draw your attention to those services and show you how to set it up quickly.

NTP server information: 

NTP Server IP = 10.1.1.1
NTP Password = S3cr3t!!!
NTP MD5 Key = 1

Step 1
Create MD5 key 1 to authenticate with the NTP server.

R1(config)#ntp authentication-key 1 md5 S3cr3t!!!

Step 2
Enable authentication for NTP.

R1(config)#ntp authenticate

Step 3
Tell the router which key our router trusts (we have only one but may use more in the future). We do not want to accidentally synchronize the time with same 'fake' server.

R1(config)#ntp trusted-key 1

Step 4
Finally, configure IP address of the NTP server and specify which key to use for authentication.

R1(config)#ntp server 10.1.1.1 key 1

In case you did not use authentication (not recommended), you would be typing in the step 4 line without the 'key 1' argument.


Verification


Notice!
It is recommended that you initially set the clock manually before you allow NTP synchronization. Big time gap between your router and the NTP server clocks, will make synchronization extremely long process.



Step 1 - Check the status of NTP

R1#show ntp status

Clock is synchronized, stratum 5, reference is 10.1.1.1
nominal freq is 250.0000 Hz, actual freq is 250.0001 Hz, precision is 2**18
reference time is D04096A6.9715EE2B (14:03:18.590 UTC Sun Sep 19 2010)
clock offset is -7.9613 msec, root delay is 3.83 msec
root dispersion is 14.74 msec, peer dispersion is 6.74 msec
R1#

Step 2 (optional) - Check NTP association.

R1#show ntp association

      address         ref clock     st  when  poll reach  delay  offset    disp
*~10.1.1.1         127.127.7.1       4     9    64  377     5.6    4.22    13.4
 * master (synced), # master (unsynced), + selected, - candidate, ~ configured
R1#

Step 3 (optional) - Check NTP association details.


R1#show ntp association detail

10.1.1.1 configured, authenticated, our_master, sane, valid, stratum 4
ref ID 127.127.7.1, time D04097CC.0209500C (14:08:12.007 UTC Sun Sep 19 2010)
our mode client, peer mode server, our poll intvl 64, peer poll intvl 64
root delay 0.00 msec, root disp 0.03, reach 377, sync dist 10.239
delay 7.72 msec, offset 5.1799 msec, dispersion 6.35
precision 2**24, version 3
org time D04097E6.97A012CA (14:08:38.592 UTC Sun Sep 19 2010)
rcv time D04097E6.98D73524 (14:08:38.597 UTC Sun Sep 19 2010)
xmt time D04097E6.905799B4 (14:08:38.563 UTC Sun Sep 19 2010)
filtdelay =    33.02    7.72   15.73   22.32    5.65   27.62   23.62   15.66
filtoffset =   11.77    5.18   13.89   23.08    4.22    7.94   12.65    3.32
filterror =     0.02    0.99    1.97    2.94    3.92    4.90    5.87    6.85

Syslog Server Configuration


Syslog Server Information:
IP address = 192.168.1.2
Facility = Local7

R1 Configuration:

R1(config)#logging host 192.168.1.2 
R1(config)#logging facility local7


From now on, all system messages are going to be sent to syslog server with ip address 192.168.1.2.

In my next lesson, I'm going to introduce another layer 2 technology: Virtual LANs (VLANs).

Lesson 13 - Layer 2 Connectivity Troubleshooting Part 3



This lesson is the last one in the series on how to troubleshoot connectivity issues at the layer 2 of OSI model. Bear in mind, that these do not involve layer 2 technologies such as VLANs or Spanning-Tree Protocol, since we have not talked about those yet.

NOTICE
The steps presented in this lesson are not the ALL possible diagnostics you can do. And they do not have to be done in this specific order. I am merely listing some logical steps which might be useful in order to 'nail down' the root cause of the problem.



Trouble Ticket 3
New installation as per Pic. 1 shows lack of connectivity between the two computers. Initial diagnostics performed revealed the following facts:

  • Switches are connected via fibre optics cable and the ports show proper status (interface is up, line protocol is up).
  • Computers have proper addresses and subnet masks assigned.
  • Cables connecting computers with switches have been tested and proved to be working correctly.
  • Computers reply to echo requests packets (firewalls disabled).
The technician who set up this new network calls you for help.
Pic. 1 - New design with connectivity problem
Icons designed by: Andrzej Szoblik - http://www.newo.pl

Dealing with this trouble ticket we are going to collect the tools we used in the previous lessons trying to resolve this issue.

Step 1
First let's try to 'divide and conquer' (concept mentioned in lesson 11) by sending ping packets fromPC1 to PC2. Before we do that though, we need to purge the existing ARP cache on PC1 and PC2to have a fresh information. We do that by opening Command Line Interface window and typing: arp -d host-address (linux), or arp -d (MS Windows).
Test results:
  • The pings timed out. No reply from PC2.
Step 2
Since the ARP cache entries age out relatively quickly (depending on which operating system you use), we need to quickly check what they contain Alternatively we can send large series of ping packets.
Test results:
  • PC1 does NOT contain expected mac-to-ip mapping. We expected to see
    192.168.1.2 at 00:1e:4f:b0:b2:fc. It is not there, though.
  • PC2 DOES contain the the right mac-to-ip mapping. It shows the following:
    192.168.1.1 at 00:50:bf:9c:45:6a
    .
These are very interesting results, don't you think? Before we take the next step let's gather what we know so far.

Since the ping was initiated by PC1, it sent its ARP request broadcast message and that query must have been delivered to PC2. We can conclude that, based on the fact that we have clearedPC2's ARP cache in step 1, and it has the proper mapping now. PC2 did receive ARP request fromPC1 and learned what MAC and IP address it uses. 

Step 3
We could omit that step, but we're curious if PC2 replies to the ARP request from PC1. We launch our 'wireshark' tool on PC2, ping again from PC1 to PC2 and capture all packets on PC2. What we discover in this packet trace is that PC2 has replied to ARP request with proper ARP reply unicast message back to PC1.

Step 4
Clearly, something between the computers (switches) does not work properly. It seems that we have some sort of unidirectional communication. What we need to establish is, where this unidirectional communication is taking place. We login to the SW1 and SW2 and issue the following commands ('x' here stands for switch number in Pic. 1):

SWx#show mac address-table interface f0/1
SWx#show mac address-table interface f0/24

Test results:
  • SW1 learns source MAC address of PC1 (00:50:bf:9c:45:6a) on its Fa0/1 interface. This is expected.
  • SW1 does NOT learn MAC address of PC2 (00:1e:4f:b0:b2:fc) on its Fa0/24 interface. This is unexpected. It should learn it from the ARP reply sent by PC2.
  • SW2 learns source MAC address of PC2 (00:1e:4f:b0:b2:fc) on its Fa0/1 interface. This is expected.
  • SW2 learns source MAC address of PC1 (00:50:bf:9c:45:6a) on its Fa0/24 interface. This is expected.
This way, we have discovered that SW1 has unidirectional link towards SW2 (SW2 sends frames towards SW1 but the latter does not seem to receive those). Probably, the fiber optics connection does not work properly (grease, dirt, a strand is broken etc.).

One more time, this lesson illustrates how useful the commands and knowledge described in the previous posts, can be in real life scenarios. 

In my next post, I will show you how to log system messages so they can be analyzed later. System messages are invaluable pieces information in the process of troubleshooting networking issues.