Upload
mahesh-jagarapu
View
241
Download
1
Embed Size (px)
Citation preview
8/2/2019 CN Manual - CSE A B
1/52
Computer Networks Lab
Laboratory Manual
Department of Computer Science and EngineeringPragati Engineering College
(Affiliated to JNTU Kakinada)
ADB Road, Surampalem 533 437
8/2/2019 CN Manual - CSE A B
2/52
Computer Networks Lab
Dept. of CSE, PEC Page 2
Student Name :
Hall ticket No. :
Year & Branch :
Syllabus
1. Implement the data link layer framing methods such as character stuffing and bit stuffing.
2. Implement on a data set of characters the three CRC polynomials CRC 12, CRC 16 and
CRC CCITT.
3. Implement Dijkstras algorithm to compute the Shortest path thru a graph.
4. Take an example subnet graph with weights indicating delay between nodes. Now obtain
Routing table art each node using distance vector routing algorithm
5. Take an example subnet of hosts. Obtain broadcast tree for it.
6. Take a 64 bit playing text and encrypt the same using DES algorithm.
7. Write a program to break the above DES coding
8. Using RSA algorithm Encrypt a text data and Decrypt the same.
8/2/2019 CN Manual - CSE A B
3/52
Computer Networks Lab
Dept. of CSE, PEC Page 3
Contents
DATA LINK LAYER FRAMING METHODS ............................................................................................. 4
CYCLIC REDUNDANCY CHECK .............................................................................................................. 9
DIJKSTRAS ALGORITHM TO COMPUTE THE SHORTEST PATH.................................................. 16
DISTANCE VECTOR ROUTING ALGORITHM ..................................................................................... 21
BROADCAST TREE FOR A GIVEN SUBNET ......................................................................................... 27
DATA ENCRYPTION STANDARD ........................................................................................................... 31
BREAKING DES ......................................................................................................................................... 37
RSA ENCRYPTION & DECRYPTION ...................................................................................................... 40
ADDITIONAL EXCERSISES..... 44
8/2/2019 CN Manual - CSE A B
4/52
Computer Networks Lab
Dept. of CSE, PEC Page 4
Data Link Layer Framing MethodsAim:
To implement the data link layer framing methods such as character stuffing and bit
stuffing.
Objective:
Student knows about different framing methods.
Outcome:
Student will implement bit stuffing and character stuffing mechanisms.
Pre-requisites:
Basic C programming OSI layer functionalities Concept of Framing
Theory:
Since the physical layer merely accepts and transmits a stream of bits without any
regard to meaning or structure, it is up to the data link layer to create and recognize frame
boundaries. This can be accomplished by attaching special bit patterns to the beginning and
end of the frame. If these bit patterns can accidentally occur in data, special care must be
taken to make sure these patterns are not incorrectly interpreted as frame delimiters. The four
framing methods that are widely used are
Character count Starting and ending characters, with character stuffing Starting and ending flags, with bit stuffing Physical layer coding violations
Character CountThis method uses a field in the header to specify the number of characters in the
frame. When the data link layer at the destination sees the character count, it knows how
many characters follow, and hence where the end of the frame is. The disadvantage is that if
the count is garbled by a transmission error, the destination will lose synchronization and will
be unable to locate the start of the next frame. So, this method is rarely used.
Character stuffing
In the second method, each frame starts with the ASCII character sequence DLE STX
and ends with the sequence DLE ETX.(where DLE is Data Link Escape, STX is Start of
TeXt and ETX is End of TeXt.) This method overcomes the drawbacks of the character count
method. If the destination ever loses synchronization, it only has to look for DLE STX and
DLE ETX characters. If however, binary data is being transmitted then there exists apossibility of the characters DLE STX and DLE ETX occurring in the data. Since this can
interfere with the framing, a technique called character stuffing is used. The sender's data link
layer inserts an ASCII DLE character just before the DLE character in the data. The receiver's
data link layer removes this DLE before this data is given to the network layer. However
character stuffing is closely associated with 8-bit characters and this is a major hurdle in
transmitting arbitrary sized characters.
Bit stuffing
The third method allows data frames to contain an arbitrary number of bits and allows
character codes with an arbitrary number of bits per character. At the start and end of each
frame is a flag byte consisting of the special bit pattern 01111110. Whenever the sender's data
link layer encounters five consecutive 1s in the data, it automatically stuffs a zero bit into theoutgoing bit stream. This technique is called bit stuffing. When the receiver sees five
Date:
8/2/2019 CN Manual - CSE A B
5/52
Computer Networks Lab
Dept. of CSE, PEC Page 5
consecutive 1s in the incoming data stream, followed by a zero bit, it automatically destuffs
the 0 bit. The boundary between two frames can be determined by locating the flag pattern.
Physical layer coding violations
The final framing method is physical layer coding violations and is applicable to
networks in which the encoding on the physical medium contains some redundancy. In such
cases normally, a 1 bit is a high-low pair and a 0 bit is a low-high pair. The combinations oflow-low and high-high which are not used for data may be used for marking frame
boundaries.
Algorithm:Bit Stuffing:
1. Read the bit stream2. Scan the bit stream for continuous 6 1s3.
If it is found then insert 0 after 5th 1
4. Finally print the bit stream with delimiter 0 1 1 1 1 1 1 0(i.e. 0 1 1 1 1 1 1 1 0 bit stream 0 1 1 1 1 1 1 0 )
Character Stuffing:1. Read the data units with delimiters DLE STX and DLE ETX2. Scan the data for any occurrences of delimiters like DLE3. If DLE found in the sequence, then stuff the another DLE4. Repeat the above 2 step until data stream ends.
Code:
8/2/2019 CN Manual - CSE A B
6/52
Computer Networks Lab
Dept. of CSE, PEC Page 6
8/2/2019 CN Manual - CSE A B
7/52
Computer Networks Lab
Dept. of CSE, PEC Page 7
8/2/2019 CN Manual - CSE A B
8/52
Computer Networks Lab
Dept. of CSE, PEC Page 8
Result:
Evaluation:
Criteria Max. Marks Allotted Marks
Bit Stuffing 4
Character Stuffing 4
Programming Efficiency 2
Total 10
Instructors Signature
8/2/2019 CN Manual - CSE A B
9/52
Computer Networks Lab
Dept. of CSE, PEC Page 9
Cyclic Redundancy CheckAim:
To implement on a data set of characters the three CRC polynomialsCRC 12, CRC
16 and CRC CCITT.
Objective:
Student knows about the error detecting and correcting mechanisms.
Outcome:
Student will implement CRC checksum computation with CRC-12, CRC-16 and
CRC-CCITT generator polynomials.
Pre-requisites:
Basic C programming Need for error detection Binary division (with 2s complement method)
Theory:
CRC is an error-detecting code. An n-bit CRC, applied to a data block of arbitrary
length, will detect any single error burst not longer than n bits (in other words, any single
alteration that spans no more than n bits of the data), and will detect a fraction 1 2 n
of all
longer error bursts.CRC Implementation
The number to be divided is the message augmented with zeros at the end. The
number of zero bits added to the message is the same as the width of the checksum (c). The
divisor is a c+1-bit number known as the generator polynomial.
Call the uppermost c+1 bits of the message the remainder Beginning with the most significant bit in the original message and for eachbit position that follows, look at the c+1 bit remainder:
o If the most significant bit of the remainder is a one, the divisor is saidto divide into it. If that happens (just as in any other long division) it is
necessary to indicate a successful division in the appropriate bit position in the
quotient and to compute the new remainder. In the case of modulo-2 binary
division, we simply: Set the appropriate bit in the quotient to a one, and
Date:
8/2/2019 CN Manual - CSE A B
10/52
Computer Networks Lab
Dept. of CSE, PEC Page 10
XOR the remainder with the divisor and store the result backinto the remainder
o Otherwise (if the first bit is not a one): Set the appropriate bit in the quotient to a zero, and XOR the remainder with zero (no effect)
o Left-shift the remainder, shifting in the next bit of the message. The bitthat's shifted out will always be a zero, so no information is lost.
Generator Polynomials of Some CRC Codes
CRC-12 x12 + x11 + x3 + x2 + x+ 1
CRC-16 x16 + x15 + x2 + 1
CRC-CCITT x16 + x12 + x5 + 1
Algorithm:Step-1: Read the frame
Step-2: Read the generator polynomial
Step-3: find out the degree of the generator polynomial
Step-4: Append the number of the zeros to the frame that number is equal to the degree
of the polynomial
Step-5: Find out number of digits in the generator polynomial
Step-6: Repeat the following until the number of digits are exhausted
Step-7: If the frame is starting with 1 , then exclusive-or the frame with generator
Step-8: Check whether the result obtained in step 7 is starting with 1, If so exclusive-or
the remainder with the generator
Step-9: If the result obtained in step7 is starting with 0, then exclusiveor the
remainder (result) with zeros. The number of zeroes must be equal to the length of
the generator.
Code:
8/2/2019 CN Manual - CSE A B
11/52
Computer Networks Lab
Dept. of CSE, PEC Page 11
8/2/2019 CN Manual - CSE A B
12/52
Computer Networks Lab
Dept. of CSE, PEC Page 12
8/2/2019 CN Manual - CSE A B
13/52
Computer Networks Lab
Dept. of CSE, PEC Page 13
8/2/2019 CN Manual - CSE A B
14/52
Computer Networks Lab
Dept. of CSE, PEC Page 14
8/2/2019 CN Manual - CSE A B
15/52
Computer Networks Lab
Dept. of CSE, PEC Page 15
Result:
Evaluation:
Criteria Max. Marks Allotted Marks
Polynomial management in code 2
Reach 5
Applicability for different polynomial sets 3
Total 10
Instructors Signature
8/2/2019 CN Manual - CSE A B
16/52
Computer Networks Lab
Dept. of CSE, PEC Page 16
Dijkstras algorithm to compute the Shortest PathAim:
To implement Dijkstras algorithm to compute the Shortest path thru a subnet.
Objective:
Student knows about the shortest path.
Outcome:
Student will implement a program that computes shortest path in over subnet, using
Dijkstras algorithm.
Pre-requisites:
Basic C programming Concept of Spanning tree Shortest path routing
Theory:
Let the node we are starting be called an initial node. Let a distance of a node Y be thedistance from the initial node to it. Dijkstra's algorithm will assign some initial distance
values and will try to improve them step-by-step.
1. Assign to every node a distance value. Set it to zero for our initial node and to infinityfor all other nodes.
2. Mark all nodes as unvisited. Set initial node as current.3. For current node, consider all its unvisited neighbors and calculate their distance
(from the initial node). For example, if current node (A) has distance of 6, and an
edge connecting it with another node (B) is 2, the distance to B through A will be
6+2=8. If this distance is less than the previously recorded distance (infinity in the
beginning, zero for the initial node), overwrite the distance.
4. When we are done considering all neighbors of the current node, mark it as visited. Avisited node will not be checked ever again; its distance recorded now is final andminimal.
5. Set the unvisited node with the smallest distance (from the initial node) as the next"current node" and continue from step 3.
Date:
8/2/2019 CN Manual - CSE A B
17/52
Computer Networks Lab
Dept. of CSE, PEC Page 17
Pseudo Code1 function Dijkstra(Graph, source):2 for each vertex vin Graph: //Initializations
3 dist[v] := infinity
//Unknown distance function from source to v4 previous[v] := undefined//Previous node in optimal path from source
5 dist[source] := 0//Distance from source to source
6 Q:= the set of all nodes in Graph//All nodes in the graph are unoptimized - thus are in Q
7 whileQis not empty: //The main loop
8 u := vertex in Qwith smallest dist[]9 if dist[u] = infinity:
10 break
//all remaining vertices are inaccessible from source11 remove u from Q12 for each neighbor vof u:
//where v has not yet been removedfrom Q.
13 alt := dist[u] + dist_between(u, v)14 ifalt < dist[v]: //Relax (u,v,a)
15 dist[v] := alt16 previous[v] := u17 return dist[]
Code:
8/2/2019 CN Manual - CSE A B
18/52
Computer Networks Lab
Dept. of CSE, PEC Page 18
8/2/2019 CN Manual - CSE A B
19/52
Computer Networks Lab
Dept. of CSE, PEC Page 19
8/2/2019 CN Manual - CSE A B
20/52
Computer Networks Lab
Dept. of CSE, PEC Page 20
Result:
Evaluation:
Criteria Max. Marks Allotted Marks
Implementation of algorithm 8
Programming Efficiency 2
Total 10
Instructors Signature
8/2/2019 CN Manual - CSE A B
21/52
Computer Networks Lab
Dept. of CSE, PEC Page 21
Distance Vector Routing AlgorithmAim:
Take an example subnet graph with weights indicating delay between nodes. Now
obtain Routing table art each node using distance vector routing algorithm.
Objective:
Student knows about routing by exchanging distance vectors.
Outcome:
Student will implement Distance Vector routing.
Pre-requisites:
Basic C programming Issues in routing Concept of distance vector routing mechanism
Theory:
A typical distance vector routing protocol uses a routing algorithm in which routers
periodically send routing updates to all neighbors by broadcasting their entire route tables.
At time t0, routers A through D have just become active. Looking at the route tables
across the top row, at t0 the only information any of the four routers has is its own directly
connected networks. The tables identify these networks and indicate that they are directly
connected by having no next-hop router and by having a hop count of 0. Each of the four
routers will broadcast this information on all links.
At time t1, the first updates have been received and processed by the routers. Look at
router A's table at t1. Router B's update to router A said that router B can reach networks
10.1.2.0 and 10.1.3.0, both 0 hops away. If the networks are 0 hops from B, they must be 1
hop from A. Router A incremented the hop count by 1 and then examined its route table. It
already knew about 10.1.2.0, and the hop count (0) was less than the hop count B advertised,
(1), so A disregarded that information.
Date:
8/2/2019 CN Manual - CSE A B
22/52
Computer Networks Lab
Dept. of CSE, PEC Page 22
Network 10.1.3.0 was new information, however, so A entered this in the route table.
The source address of the update packet was router B's interface (10.1.2.2) so that
information is entered along with the calculated hop count.
Notice that the other routers performed similar operations at the same time t 1. Router
C, for instance, disregarded the information about 10.1.3.0 from B and 10.1.4.0 from C but
entered information about 10.1.2.0, reachable via B's interface address 10.1.3.1, and 10.1.5.0,
reachable via C's interface 10.1.4.2. Both networks were calculated as 1 hop away.
At time t2, the update period has again expired and another set of updates has been
broadcast. Router B sent its latest table; router A again incremented B's advertised hop counts
by 1 and compared. The information about 10.1.2.0 is again discarded for the same reason as
before. 10.1.3.0 is already known, and the hop count hasn't changed, so that information is
also discarded. 10.1.4.0 is new information and is entered into the route table.
The network is converged at time t3. Every router knows about every network, the
address of the next-hop router for every network, and the distance in hops to every network.
Code:
8/2/2019 CN Manual - CSE A B
23/52
Computer Networks Lab
Dept. of CSE, PEC Page 23
8/2/2019 CN Manual - CSE A B
24/52
Computer Networks Lab
Dept. of CSE, PEC Page 24
8/2/2019 CN Manual - CSE A B
25/52
Computer Networks Lab
Dept. of CSE, PEC Page 25
8/2/2019 CN Manual - CSE A B
26/52
Computer Networks Lab
Dept. of CSE, PEC Page 26
Result:
Evaluation:
Criteria Max. Marks Allotted Marks
Reach 8
Output Efficiency (i.e. with less limitations) 2
Total 10
Instructors Signature
8/2/2019 CN Manual - CSE A B
27/52
Computer Networks Lab
Dept. of CSE, PEC Page 27
Broadcast Tree for a Given SubnetAim:
Take an example subnet of hosts. Obtain broadcast tree for it.Objective:
Student knows about broadcast routing.
Outcome:
Student will implement a program that computes broadcast tree for a given subnet of
routers.
Pre-requisites:
Basic C programming Concept of broadcasting
Theory:A broadcast tree of a subnet is a tree with nodes N, edges E and root node is the
source of broadcast.
Where, N is the set of all nodes of the actual subnet and E is a subset of set of all edges of thesubnet such that no edge in E forms a loop.
Or in simple terms broadcast tree is a spanning tree for the subnet. And that tree need
not be a minimal spanning tree.
Algorithm:Step 1 : Find the cheapest edge in the graph (if there is more than one, pick one at random).
Mark it with any given color, say red.
Step 2 : Find the cheapest unmarked (uncolored) edge in the graph that doesn't close a
colored or red circuit. Mark this edge red.
Step 3 : Repeat Step 2 until you reach out to every vertex of the graph (or you have N ; 1
colored edges, where N is the number of Vertices.) The red edges form the desired
minimum spanning tree.
Code:
Date:
8/2/2019 CN Manual - CSE A B
28/52
Computer Networks Lab
Dept. of CSE, PEC Page 28
8/2/2019 CN Manual - CSE A B
29/52
Computer Networks Lab
Dept. of CSE, PEC Page 29
8/2/2019 CN Manual - CSE A B
30/52
Computer Networks Lab
Dept. of CSE, PEC Page 30
Result:
Evaluation:
Criteria Max. Marks Allotted Marks
Reach 4
Scalability 2
Complexity 2
Total 10
Instructors Signature
8/2/2019 CN Manual - CSE A B
31/52
Computer Networks Lab
Dept. of CSE, PEC Page 31
Data Encryption StandardAim:
Take a 64 bit playing text and encrypt the same using DES algorithm.
Objective:
Student knows about DES encryption.
Outcome:
Student will implement DES encryption and key schedule.
Pre-requisites:
Basic C programming Concepts of network security Concept of DES
Theory:
The Data Encryption Standard (DES) is a block
cipher. The block size is 64 bits. It is based on a
symmetric-key algorithm that uses a 64-bit key, only 56
of these are actually used by the algorithm. Eight bits are
used solely for checking parity, and are thereafter
discarded.
There are 16 identical stages of processing, termed
rounds.
A block to be enciphered is subjected to an initial
permutation (IP), then to a complex key-dependent
computation and finally to a permutation which is the
inverse of the initial permutation (IP-1). The key-
dependent computation can be simply defined in terms of
a function f, called the cipher function, and a function KS,
called the key schedule.
Before the main rounds, the block is divided into
two 32-bit halves and processed alternately; this
crisscrossing is known as the Feistel scheme.
Figure 1: Encryption
Date:
8/2/2019 CN Manual - CSE A B
32/52
Computer Networks Lab
Dept. of CSE, PEC Page 32
The Feistel (F) function
The F-function, depicted in
Figure 2, operates on half a block (32
bits) at a time and consists of four
stages:1. Expansion the 32-bit half-
block is expanded to 48 bits using the
expansion permutation, denoted E in
the diagram, by duplicating half of the
bits. The output consists of 8 6-bit
pieces, each containing a copy of 4
corresponding input bits, plus a copy
of the immediately adjacent bit from
each of the input pieces to either side.
2. Key mixing the result iscombined with a subkey using an XOR
operation. Sixteen 48-bit subkeys
one for each round are derived
from the main key using the key
schedule (described below).
3. Substitution after mixing in the subkey,the block is divided into eight 6-bit pieces
before processing by the S-boxes, or
substitution boxes. Each of the eight S-
boxes replaces its six input bits with four
output bits according to a non-lineartransformation, provided in the form of a
lookup table. The S-boxes provide the core
of the security of DES without them,
the cipher would be linear, and trivially
breakable.
4. Permutation finally, the 32 outputsfrom the S-boxes are rearranged according
to a fixed permutation, the P-box. This is
designed so that, after expansion, each S-
box's output bits are spread across 6
different S boxes in the next round.
Key schedule
Initially, 56 bits of the key are selected
from the initial 64 by Permuted Choice 1 (PC-
1)the remaining eight bits are either discarded
or used as parity check bits. The 56 bits are then
divided into two 28-bit halves; each half is
thereafter treated separately. In successive rounds, both halves are rotated left by one and two
bits (specified for each round), and then 48 subkey bits are selected by Permuted Choice 2
(PC-2)24 bits from the left half, and 24 from theright. The rotations (denoted by "
8/2/2019 CN Manual - CSE A B
33/52
Computer Networks Lab
Dept. of CSE, PEC Page 33
mean that a different set of bits is used in each subkey; each bit is used in approximately 14
out of the 16 subkeys.
Code:
8/2/2019 CN Manual - CSE A B
34/52
Computer Networks Lab
Dept. of CSE, PEC Page 34
8/2/2019 CN Manual - CSE A B
35/52
Computer Networks Lab
Dept. of CSE, PEC Page 35
8/2/2019 CN Manual - CSE A B
36/52
Computer Networks Lab
Dept. of CSE, PEC Page 36
Result:
Evaluation:
Criteria Max. Marks Allotted Marks
IP, IP-1
implementation 2
Feistel function implementation 5Key schedule implementation 2
Modularity 1
Total 10
Instructors Signature
8/2/2019 CN Manual - CSE A B
37/52
Computer Networks Lab
Dept. of CSE, PEC Page 37
Breaking DESAim:
To write a program that breaks the above DES coding.
Objective:
Student knows about strength of DES algorithm and how to break it.
Outcome:
Student will implement an attack on DES.
Pre-requisites:
Basic C programming Attacks on DES Concept of cryptanalysis
Theory:
Brute force attack
For any cipher, the most basic method of attack is brute forcetrying every possible
key in turn. The length of the key determines the number of possible keys, and hence the
feasibility of this approach.
Attacks faster than brute force
There are three attacks known that can break the full sixteen rounds of DES with less
complexity than a brute-force search: differential cryptanalysis (DC), linear cryptanalysis
(LC), and Davies' attack.
Differential cryptanalysis was rediscovered in the late 1980s by Eli Biham and AdiShamir; it was known earlier to both IBM and the NSA and kept secret. To break the
full 16 rounds, differential cryptanalysis requires 247 chosen plaintexts. DES was
designed to be resistant to DC.
Linear cryptanalysis was discovered by Mitsuru Matsui, and needs 243 knownplaintexts (Matsui, 1993); the method was implemented (Matsui, 1994), and was the
first experimental cryptanalysis of DES to be reported. There is no evidence that DES
was tailored to be resistant to this type of attack. A generalization of LC multiple
linear cryptanalysis was suggested in 1994 (Kaliski and Robshaw), and was
further refined by Biryukov et al. (2004); their analysis suggests that multiple linear
approximations could be used to reduce the data requirements of the attack by at leasta factor of 4 (i.e. 2
41instead of 2
43). A similar reduction in data complexity can be
obtained in a chosen-plaintext variant of linear cryptanalysis (Knudsen andMathiassen, 2000). Junod (2001) performed several experiments to determine the
actual time complexity of linear cryptanalysis, and reported that it was somewhat
faster than predicted, requiring time equivalent to 2392
41DES evaluations.
Improved Davies' attack: while linear and differential cryptanalysis are generaltechniques and can be applied to a number of schemes, Davies' attack is a specialized
technique for DES, first suggested by Donald Davies in the eighties, and improved by
Biham and Biryukov (1997). The most powerful form of the attack requires 250
known plaintexts, has a computational complexity of 250
, and has a 51% success rate.
Date:
8/2/2019 CN Manual - CSE A B
38/52
Computer Networks Lab
Dept. of CSE, PEC Page 38
Code:
8/2/2019 CN Manual - CSE A B
39/52
Computer Networks Lab
Dept. of CSE, PEC Page 39
Result:
Evaluation:
Criteria Max. Marks Allotted Marks
IP, IP-1 implementation 2
Feistel function implementation 5
Key schedule implementation 2
Modularity 1
Total 10
Instructors Signature
8/2/2019 CN Manual - CSE A B
40/52
Computer Networks Lab
Dept. of CSE, PEC Page 40
RSA Encryption & DecryptionAim:
To implement RSA algorithm for encrypting and decrypting textual data.
Objective:
Student knows about RSA encryption and decryption mechanisms.
Outcome:
Student will implement RSA public key cryptography mechanism.
Pre-requisites:
Basic C programming Concept of Public key cryptography Little knowledge of mathematics RSA algorithm
Theory:
The RSA algorithm involves three steps: key generation, encryption and decryption.
Key generation
1. Generate two large random primes, p and q, of approximately equal size such thattheir product n = pq is of the required bit length, e.g. 1024 bits.
2. Compute n = pq and = (p-1)(q-1).3. Choose an integer e, 1 < e < , such that gcd(e, ) = 1.4. Compute the secret exponent d, 1 < d < , such that ed 1 (mod ).5. The public key is (n, e) and the private key is (n, d). Keep all the values d, p, q and
secret.
n is known as the modulus. e is known as thepublic exponentor encryption exponentor just the exponent. d is known as the secret exponentor decryption exponent.
Encryption
1. Obtains the recipient's public key (n, e).2. Represents the plaintext message as a positive integer m.3. Computes the cipher text c = me mod n.4. Sends the cipher text c to recipient.
Decryption
1. Uses his private key (n, d) to compute m = cd mod n.2. Extracts the plaintext from the message representative m.
Date:
8/2/2019 CN Manual - CSE A B
41/52
Computer Networks Lab
Dept. of CSE, PEC Page 41
Code:
8/2/2019 CN Manual - CSE A B
42/52
Computer Networks Lab
Dept. of CSE, PEC Page 42
8/2/2019 CN Manual - CSE A B
43/52
Computer Networks Lab
Dept. of CSE, PEC Page 43
Result:
Evaluation:
Criteria Max. Marks Allotted Marks
Key generation 5
Encryption 2
Decryption 2
Selection of p and q 1
Total 10
Instructors Signature
8/2/2019 CN Manual - CSE A B
44/52
Computer Networks Lab
Dept. of CSE, PEC Page 44
Additional ExercisesImplement Hamming Code error correction mechanism
Aim:
To implement Hamming Code error correction mechanism.Objective:
Student knows Hamming Code error correction mechanisms.
Outcome:
Student will implement Hamming Code error correction mechanism.
Pre-requisites:
Basic C programming Need for error correction Hamming Code error Correction
Theory:
Hamming code is a error correcting code. For correcting
an error one has to know the exact position of error, i.e. exactly which bit is in error (to
locate the invalid bits). For example, to correct a single-bit error in an ASCII character,
the error correction must determine which one of the seven bits is in error. To this, we
have to add some additional redundant bits.
To calculate the numbers of redundant bits (r) required to correct d data bits, let us find
out the relationship between the two. So we have (d+r) as the total number of bits, which
are to be transmitted; then r must be able to indicate at least d+r+1 different values. Of
these, one value means no error, and remaining d+r values indicate error location of error
in each of d+r locations. So, d+r+1 states must be distinguishable by r bits, and r bits can
indicates 2rstates. Hence, 2
rmust be greater than d+r+1.
2r>= d+r+1
The value of r must be determined by putting in the value of d in the relation. For
example, if d is 7, then the smallest value of r that satisfies the above relation is 4. So thetotal bits, which are to be transmitted is 11 bits (d+r = 7+4 =11).
Basic approach for error detection by using Hamming code is as follows:
To each group of m information bits k parity bits are added to form (m+k) bit
code as shown in above Fig.
Location of each of the (m+k) digits is assigned a decimal value.
Date:
8/2/2019 CN Manual - CSE A B
45/52
Computer Networks Lab
Dept. of CSE, PEC Page 45
The k parity bits are placed in positions 1, 2 2k-1 positions.K parity checks
are performed on selected digits of each codeword.
At the receiving end the parity bits are recalculated. The decimal value of the k
parity bits provides the bit-position in error, if any.
Code:
8/2/2019 CN Manual - CSE A B
46/52
Computer Networks Lab
Dept. of CSE, PEC Page 46
8/2/2019 CN Manual - CSE A B
47/52
Computer Networks Lab
Dept. of CSE, PEC Page 47
Result:
Evaluation:
Criteria Max. Marks Allotted Marks
Adding of r bits to data 3
Reach 3
Implementation 4
Total 10
Instructors Signature
8/2/2019 CN Manual - CSE A B
48/52
Computer Networks Lab
Dept. of CSE, PEC Page 48
Implement Link State routing algorithm.Aim:
Take an example subnet graph with weights indicating delay between nodes. Now
obtain Routing table art each node using Link State routing algorithm.
Objective:Student knows about routing by discovering neighbors, measure delay or cost,
Constructing packet and sending using shortest path..
Outcome:
Student will implement Link State routing.
Pre-requisites:
Basic C programming Issues in routing Concept of Link State routing mechanism
Theory
Link State Routing is implemented in order to avoid the disadvantages of Distance Vector
routing. In Link state Routing ,Each router must do the following:
1. Discover its neighbors and learn their network addresses.2. Measure the delay or cost to each of its neighbors.3. Construct a packet telling all it has just learned.4. Send this packet to all other routers.5. Compute the shortest path to every other router.
Code:
Date:
8/2/2019 CN Manual - CSE A B
49/52
Computer Networks Lab
Dept. of CSE, PEC Page 49
8/2/2019 CN Manual - CSE A B
50/52
Computer Networks Lab
Dept. of CSE, PEC Page 50
Result:
Evaluation:
Criteria Max. Marks Allotted Marks
Reach 8
Output Efficiency (i.e. with less limitations) 2
Total 10
Instructors Signature
8/2/2019 CN Manual - CSE A B
51/52
Computer Networks Lab
Dept. of CSE, PEC Page 51
Space for Additional Notes
8/2/2019 CN Manual - CSE A B
52/52
Computer Networks Lab
*****