Sunday, July 28, 2013

Computer Networking - Error Detection during data transmission

Error is a condition when the receiver’s information does not match with the sender’s information. During transmission, digital signals suffer from noise that can introduce errors in the binary bits travelling from sender to receiver. That means a 0 bit may change to 1 or a 1 bit may change to 0

Whenever a message is transmitted, it may get scrambled by noise or data may get corrupted. To avoid this, we use error-detecting codes which are additional data added to a given digital message to help us detect if any error has occurred during transmission of the message. Error detecting codes are implemented either at Data Link Layer or Transport Layer of OSI Model. Basic approach used for error detection is the use of redundancy bits, where additional bits are added to facilitate detection of errors.
Some popular techniques for error detection are:
1. Simple Parity check
2. Two-dimensional Parity check
3. Checksum
4. Cyclic redundancy check

1. Simple Parity check 
Blocks of data from the source are subjected to a check bit or parity bit generator form, where a parity of :
  • 1 is added to the block if it contains odd number of 1’s, and
  • 0 is added if it contains even number of 1’s
This scheme makes the total number of 1’s even, that is why it is called even parity checking.

















2. Two-dimensional Parity check
Parity check bits are calculated for each row, which is equivalent to a simple parity check bit. Parity check bits are also calculated for all columns, then both are sent along with the data. At the receiving end, these are compared with the parity bits calculated on the received data.
























3. Checksum
  • In checksum error detection scheme, the data is divided into k segments each of m bits.
  • In the sender’s end the segments are added using 1’s complement arithmetic to get the sum. The sum is complemented to get the checksum.
  • The checksum segment is sent along with the data segments.
  • At the receiver’s end, all received segments are added using 1’s complement arithmetic to get the sum. The sum is complemented.
  • If the result is zero, the received data is accepted; otherwise discarded.





























4. Cyclic redundancy check (CRC)
  • Unlike checksum scheme, which is based on addition, CRC is based on binary division.
  • In CRC, a sequence of redundant bits, called cyclic redundancy check bits, are appended to the end of data unit so that the resulting data unit becomes exactly divisible by a second, predetermined binary number.
  • At the destination, the incoming data unit is divided by the same number. If at this step there is no remainder, the data unit is assumed to be correct and is therefore accepted.
  • A remainder indicates that the data unit has been damaged in transit and therefore must be rejected.


Saturday, July 13, 2013

Computer Networking - IP Addressing

IP address is an address having information about how to reach a specific host, especially outside the LAN. An IP address is a 32 bit unique address having an address space of 232
Generally, there are two notations in which IP address is written, dotted decimal notation and hexadecimal notation.

Dotted Decimal Notation






Hexadecimal Notation

Some points to be noted about dotted decimal notation :
1. The value of any segment (byte) is between 0 and 255 (both included).
2. There are no zeroes preceding the value in any segment (054 is wrong, 54 is correct).

Classful Addressing
The 32 bit IP address is divided into five sub-classes. There are two notations for classful addressing, binary notation and decimal notation.
Binary Notation

Example : Find the class of the address 11000001 10000011 00011011 11111111
Solution : The first two bits of the given address are 1, and the third bit is 0. Therefore, it is a class C address.

Decimal Notation
Example : Find the class of the address 227.12.14.87
Solution : The first byte is 227, which is between 224 and 239, and thus, the given address is a class D address.

Net ID and Host ID
Net ID is the part of the IP address that identifies the network; and Host ID is the part of the IP address that identifies the host on the network.


Problems with Classful Addressing:
The problem with this classful addressing method is that millions of class A address are wasted, many of the class B address are wasted, whereas, number of addresses available in class C is so small that it cannot cater the needs of organizations. Class D addresses are used for multicast routing, and are therefore available as a single block only. Class E addresses are reserved.

Because of these problems, Classful networking was replaced by Classless Inter-Domain Routing (CIDR) in 1993. And to discuss it properly let us first understand Network Address, Mask and Subnetting.
Network address - It identifies a network on internet.  Using this, we can find range of addresses in the network and total possible number of hosts in the network.
Mask - It is a 32-bit binary number that gives the network address in the address block when AND operation is bitwise applied on the mask and any IP address of the block.
The default mask in different classes are :
Class A – 255.0.0.0
Class B – 255.255.0.0
Class C – 255.255.255.0
Example : Given IP address 132.6.17.85 and default class B mask, find the beginning address (network address).
Solution : The default mask is 255.255.0.0, which means that the only the first 2 bytes are preserved and the other 2 bytes are set to 0. Therefore, the network address is 132.6.0.0.
Subnetting - Dividing a large block of addresses into several contiguous sub-blocks and assigning these sub-blocks to different smaller networks is called subnetting. It is a practice that is widely used when classless addressing is done.

Classless Addressing
To reduce the wastage of IP addresses in a block, we use sub-netting. What we do is that we use host id bits as net id bits of a classful IP address. We give the IP address and define the number of bits for mask along with it (usually followed by a ‘/’ symbol), like, 192.168.1.1/28. Here, subnet mask is found by putting the given number of bits out of 32 as 1, like, in the given address, we need to put 28 out of 32 bits as 1 and the rest as 0, and so, the subnet mask would be 255.255.255.240.

Some values calculated in subnetting :
1. Number of subnets : Given bits for mask – No. of bits in default mask
2. Subnet address : AND result of subnet mask and the given IP address
3. Broadcast address : By putting the host bits as 1 and retaining the network bits as in the IP address
4. Number of hosts per subnet : 2(32 – Given bits for mask) – 2
5. First Host ID : Subnet address + 1 (adding one to the binary representation of the subnet address)
6. Last Host ID : Subnet address + Number of Hosts

Example : Given IP Address – 172.16.0.0/25, find the number of subnets and the number of hosts per subnet. Also, for the first subnet block, find the subnet address, first host ID, last host ID and broadcast address.
Solution : This is a class B address. So, no. of subnets = 2(25-16) = 29 = 512.
No. of hosts per subnet = 2(32-25) – 2 = 27 – 2 = 128 – 2 = 126
For the first subnet block, we have subnet address = 0.0, first host id = 0.1, last host id = 0.126 and broadcast address = 0.127