CN Lab Manual (Master)
CN Lab Manual (Master)
(DATA SCIENCE)
MASTER MANUAL
(DATA SCIENCE)
Regulation : R20
A.Y. : 2022-2023
DEPARTMENT VISION
To create the next generation and globally competent data scientists/data engineers in the field of
Data Science domain by providing quality engineering education along with cutting edge
technologies.
DEPARTMENT MISSION
To provide value based engineering education through continues learning and research by imparting
solid foundation in applied mathematics, algorithms and programming paradigms to build software
models and simulations.
To develop concepts building, logical and problem solving skills of graduates to address current global
challenges of industry and society.
To offer excellence in teaching and learning process, industry collaboration activities and researchto
mould graduates into industry ready professionals.
Course Outcomes
1. Implement data link layer farming methods
2. Analyze error detection and error correction codes.
3. Implement and analyze routing and congestion issues in network design.
4. Implement Encoding and Decoding techniques used in presentation layer
5. To be able to work with different network tools
List of Experiments
1. Implement the data link layer framing methods such as character, character-stuffing and bit stuffing.
2. Write a program to compute CRC code for the polynomials CRC-12, CRC-16 and CRC CCIP
3. Develop a simple data link layer that performs the flow control using the sliding window protocol, and
loss recovery using the Go-Back-N mechanism.
4. Implement Dijsktra’s algorithm to compute the shortest path through a network
5. Take an example subnet of hosts and obtain a broadcast tree for the subnet.
6. Implement distance vector routing algorithm for obtaining routing tables at each node.
7. Implement data encryption and data decryption
8. Write a program for congestion control using Leaky bucket algorithm.
9. Write a program for frame sorting technique used in buffers.
10. Wireshark
i. Packet Capture Using Wireshark
ii. Starting Wire shark
iii. Viewing Captured Traffic
iv. Analysis and Statistics & Filters.
11. How to run Nmap scan
12. Operating System Detection using Nmap
13. Do the following using NS2 Simulator
i. NS2 Simulator-Introduction
ii. Simulate to Find the Number of Packets Dropped
iii. Simulate to Find the Number of Packets Dropped by TCP/UDP
iv. Simulate to Find the Number of Packets Dropped due to Congestion
v. Simulate to Compare Data Rate& Throughput.
vi. Simulate to Plot Congestion for Different Source/Destination
vii. Simulate to Determine the Performance with respect to Transmission of Packets
LAB CODE
Students should report to the concerned lab as per the time table.
Students who turn up late to the labs will in no case be permitted to do the program
schedule for the day.
After completion of the program, certification of the concerned staff in-charge in the
observation book is necessary.
Student should bring a notebook of 100 pages and should enter the readings /observations into
the notebook while performing the experiment.
The record of observations along with the detailed experimental procedure of the experiment
in the immediate last session should be submitted and certified staff member in-charge.
The group-wise division made in the beginning should be adhered to and no mix up of
studentsamong different groups will be permitted.
When the experiment is completed, should disconnect the setup made by them, and should
return all the components/instruments taken for the purpose.
Any damage of the equipment or burn-out components will be viewed seriously either by
putting penalty or by dismissing the total group of students from the lab for the semester/year.
Students should be present in the labs for total scheduled duration.
Students are required to prepare thoroughly to perform the experiment before coming to
laboratory.
8. Write a program for congestion control using Leaky bucket algorithm. 42-44
9. Write a program for frame sorting technique used in buffers. 45-46
Wire shark
i. Packet Capture Using Wireshark 47-58
ii. Starting Wire shark
10. iii. Viewing Captured Traffic
iv. Analysis and Statistics & Filters Viewing
Captured Traffic
v. Analysis and Statistics & Filters.
11. How to run Nmap scan 59-60
12. Operating System Detection using Nmap 61-66
Do the following using NS2 Simulator
I. NS2 Simulator-Introduction
II. Simulate to Find the Number of Packets
Dropped
III. Simulate to Find the Number of Packets
13. Dropped by TCP/UDP
67-79
IV. Simulate to Find the Number of Packets
Dropped due to Congestion
V. Simulate to Compare Data Rate&
Throughput.
VI. Simulate to Plot Congestion for Different
Source/Destination
VII. Simulate to Determine the Performance
with respect to Transmission of Packets
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 a possibility 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.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
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 the outgoing bit stream. This technique is called bit stuffing. When the
receiver sees five 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.
SOURCE CODE:
#include<stdio.h>
#include<string.h>
char input[10][20];
int get_input();
void make_frames(int);
int count_chars(int s);
void main()
{
int no_of_words=get_input();
make_frames(no_of_words);
}
int get_input()
{
int answer;
int i=0;
do{
printf("\nEnter the Word:");
scanf("%s",input[i]);
fflush(stdin);
printf("\nDo you want to continue: (yes: 1 or no: 0)?:");
scanf("%d",&answer);
i++;
}
while(answer!=0);
return i;
}
for(;i<num_words;i++)
printf("%d%s",(count_chars(i)+1),input[i]);
printf("\n\n");
}
int count_chars(int index)
{
Output:
The new technique allows data frames to contain an arbitrary number if bits and allows character codes
with an arbitrary no of bits per character. Each frame begins and ends with special bit pattern,
01111110, called a flag byte. Whenever the senders data link layer encounters five consecutive
one’sin the data, it automatically stuffs a 0 bit into the outgoing bit stream. This bit stuffing is
analogous to character stuffing, in which a DLE is stuffed into the outgoing character stream before
DLE in the data
SOURCE CODE:
#include<stdio.h>
#include<string.h>
void main()
{
int a[20],b[30],i,j,k,count,n;
printf("Enter frame length:");
scanf("%d",&n);
printf("Enter input frame (0's & 1's only):");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
i=0;
count=1;
j=0;
while(i<n)
{
if(a[i]==1)
{
b[j]=a[i];
for(k=i+1;a[k]==1 && k<n && count<5;k++)
{
j++;
b[j]=a[k];
count++;
if(count==5)
{
j++;
b[j]=0;
}
i=k;
}
}
else
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
{
b[j]=a[i];
}
i++;
j++;
}
printf("After stuffing the frame is:");
for(i=0;i<j;i++)
printf("%d",b[i]);
}
Output:
Enter frame length:5
Enter input frame (0's & 1's only):
1
1
1
1
1
After stuffing the frame is: 111110
SOURCE CODE:
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
int j,l,m,c,k;
char a[50],b[50];
printf("Enter the string:");
scanf("%s",a);
strcpy(b,"DLESTX");
m=strlen(a);
for(j=0;j<m;)
{
if(a[j]=='d')
{
if(a[j+1]=='l')
{
if(a[j+2]=='e')
{
c=j+2;
for(l=0;l<3;l++)
{
for(k=m;k>c;k--)
{
a[k]=a[k-1];
}
m++;
a[m]='\0';
c+=1;
}
a[j+3]='d';
a[j+4]='l';
a[j+5]='e';
a[m]='\0';
j+=5;
}
}
}
j++;
}
strcat(b,a);
strcat(b,"DLEETX");
printf("\n%s",b);
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
printf("\nReceiver side:");
m=strlen(a);
for(j=0;j<m;)
{
if(a[j]=='d')
{
if(a[j+1]=='l')
{
if(a[j+2]=='e')
{
c=j;
for(l=0;l<3;l++)
{
for(k=c;k<m;k++)
a[k]=a[k+1];
}
c++;
}
j=c;
}
}
j++;
}
printf("\n%s",a);
getch();
}
OUTPUT:
Enter the string: ABC
DLESTXABCDLEETX
Receiver side:
ABC
2. Character Count?
This 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
3. 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 a possibility 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.
4. 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 the outgoing bit
stream. This technique is called bit stuffing. When the receiver sees five consecutive 1s in the
incoming data stream, followed by a zero bit, it automatically de-stuffs the 0 bit. The boundary
between two frames can be determined by locating the flag pattern.
The Data Link Layer is the second layer in the OSI model, above the Physical Layer, which ensures
that the error free data is transferred between the adjacent nodes in the network. It breaks the datagram passed
down by above layers and converts them into frames ready for transfer. This is called Framing. It provides two
main functionalities
Reliable data transfer service between two peer network layers
Flow Control mechanism, which regulates the flow of frames such that data congestion is not there at
slow receivers due to fast senders.
There are two basic strategies for dealing with errors. One way is to include enough redundant
information (extra bits are introduced into the data stream at the transmitter on a regular and logical basis)
along with each block of data sent to enable the receiver to deduce what the transmitted character must have
been. The other way is to include only enough redundancy to allow the receiver to deduce that error has
occurred, but not which error has occurred and the receiver asks for a retransmission. The former strategy uses
Error-Correcting Codes and latter uses Error-detecting Codes.
This Cyclic Redundancy Check is the most powerful and easy to implement technique. 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.
1. Bit strings are created as representation of polynomials with coefficients ‘0’ and ‘1’only.
2. A k-bit frame is regarded as coefficients list for a polynomial with ‘k’ terms (xk-1 to x0 )
Eg: x5 + x4 +x0 = 110001
When this method is used, the sender and the receiver should agree upon a generator polynomial, G(x) in
advance.
Both the high and low order bits of G(x) must be ‘1’
To compute checksum for some frame with ‘m’ bits ( polynomial = M(x), append ‘r’ zero bits to the lower
end of the frame (r = degree of the generator polynomial) so that this check summed frame is divisible by
G(x).
Divide M(x) by G(x) using modulo-2 division and subtract the remainder from M(x) using modulo-
2subtraction. let the resultant be called as T(x)
T(x) is passed to the receiver and the receiver divides it by G(x).
1. Let ‘r’ be the degree of G(x). Append ‘r’ to the lower end of the frame so that it contains (m + r) bits.
2. Divide M(x) by G(x) using MOD-2 division.
3. Subtract the remainder from M(x) using MOD-2 subtraction.
4. The result is the check summed frame to be transmitted.
SOURCE CODE:
#include <stdio.h>
#include <string.h>
#define N strlen(g)
char t[28],cs[28],g[28];
int a,e,c,b;
void xor()
{
for(c=1;c<N;c++)
cs[c]=((cs[c]==g[c])?'0':'1');
}
void crc()
{
for(e=0;e<N;e++)
cs[e]=t[e];
do
{
if(cs[0]=='1')
xor();
for(c=0;c<N-1;c++)
cs[c]=cs[c+1];
cs[c]=t[e++];
}while(e<=a+N-1);
}
int main()
{
int flag=0;
do{
printf("\n1.crc12\n2.crc16\ncrc ccit\n4.exit\n\nEnter your option.");
scanf("%d",&b);
switch(b)
{
case 1:strcpy(g,"1100000001111");
break;
case 2: strcpy(g,"11000000000000101");
break;
case 3:strcpy (g,"10001000000100001");
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
break;
case 4:return 0;
}
printf("\n enter data:");
scanf("%s",t);
printf("\n-----------------------\n");
printf("\n generating polynomial:%s",g);
a=strlen(t);
for(e=a;e<a+N-1;e++)
t[e]='0';
printf("\n--------------------------\n");
printf("mod-ified data is:%s",t);
printf("\n-----------------------\n");
crc();
printf("checksum is:%s",cs);
for(e=a;e<a+N-1;e++)
t[e]=cs[e-a];
printf("\n-----------------------\n");
printf("\n final codeword is : %s",t);
printf("\n------------------------\n");
printf("\ntest error detection 0(yes) 1(no)?:");
scanf("%d",&e);
if(e==0)
{
do{
printf("\n\tenter the position where error is to be inserted:");
scanf("%d",&e);
}
while(e==0||e>a+N-1);
t[e-1]=(t[e-1]=='0')?'1':'0';
printf("\n-----------------------\n");
printf("\n\terroneous data:%s\n",t);
}
crc();
for(e=0;(e<N-1)&&(cs[e]!='1');e++);
if(e<N-1)
printf ("error detected\n\n");
else
printf ("\n no error detected \n\n");
printf("\n-----------------------");
}while(flag!=1);
}
Output:
1.crc12
2.crc16
3.crc ccit
4.exit
-----------------------
1. crc12
2. crc16
3. crc ccit
4. exit
Enter your option.4
Result:
Thus the program for cyclic redundancy check is executed.
2. What is Redundancy?
The concept of including extra information in the transmission solely for the purpose of
comparison. This technique is called redundancy.
THEORY:
SLIDING WINDOW PROTOCOL
SOURCE CODE:
#include<stdio.h>
int main()
{
int w,i,f,frames[50];
printf("Enter window size: ");
scanf("%d",&w);
printf("\nEnter number of frames to transmit: ");
scanf("%d",&f);
printf("\nEnter %d frames: ",f);
for(i=1;i<=f;i++)
scanf("%d",&frames[i]);
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
printf("\nWith sliding window protocol the frames will be sent in the following manner (assuming no
corruption of frames)\n\n");
printf("After sending %d frames at each stage sender waits for acknowledgement sent by the
receiver\n\n",w);
for(i=1;i<=f;i++)
{
if(i%w==0)
{
printf("%d\n",frames[i]);
printf("Acknowledgement of above frames sent is received by sender\n\n");
}
else
printf("%d ",frames[i]);
}
if(f%w!=0)
printf("\nAcknowledgement of above frames sent is received by sender\n");
return 0;
}
Output
Enter window size: 3
Enter number of frames to transmit: 5
Enter 5 frames: 12 5 89 4 6
With sliding window protocol the frames will be sent in the following manner (assuming no corruption of
frames)
After sending 3 frames at each stage sender waits for acknowledgement sent by the receiver
12 5 89
Acknowledgement of above frames sent is received by sender
46
Acknowledgement of above frames sent is received by sender
Go-Back-N mechanism
If a frame is corrupted or lost in it, all In this, only the frame is sent again, whichis corrupted or lost.
subsequent frames have to be sent again.
If it has a high error rate ,it wastesa lot of There is a loss of low bandwidth.
bandwidth.
It is less complex. It is more complex because it has to dosorting and searching as
well. And it also requires more storage.
It does not require sorting. In this, sorting is done to get the frames inthe correct order.
It does not require searching. The search operation is performed in it.
THEORY:
It is a static routing algorithm. It is used to build a graph of the subnet, with each node of graph representing a
router and each arc of the graph representing a communication line. To choose a route between a given pair of
routers, the algorithm just finds the shortest path between them on the graph. Different ways of measuring the
path length is the number of Hops, Geographical distance in kmts, Mean Queuing delay, Transmission delay,
Functions of distance, Bandwidth, Average traffic, communication cost etc.,
Several algorithms for computing the shortest path between two nodes of a graph are known. This one is due
to Dijkstra (1959). Each node is labeled (in parentheses) with its distance from the source node along the best
known path. Initially, no paths are known, so all nodes are labeled with infinity. As the algorithm proceeds
and paths are found, the labels may change, reflecting better paths. A label may be either tentative or
permanent. Initially, all labels are tentative. When it is discovered that a label represents the shortest possible
path from the source to that node, it is made permanent and never changed thereafter.
To illustrate how the labeling algorithm works, look at the weighted, undirected graph of Fig. (a), where the
weights represent, for example, distance. We want to find the shortest path from A to D. We start out by
marking node A as permanent, indicated by a filled-in circle. Then we examine, in turn, each of the nodes
adjacent to A (the working node), relabeling each one with the distance to A. Whenever a node is relabeled,
we also label it with the node from which the probe was made so that we can reconstruct the final path later.
Having examined each of the nodes adjacent to A, we examine all the tentatively labeled nodes in the whole
graph and make the one with the smallest label permanent, as shown in Fig. (b). This one becomes the new
working node.
We now start at B and examine all nodes adjacent to it. If the sum of the label on B and the distance from B to
the node being considered is less than the label on that node, we have a shorter path, so the node is relabeled.
After all the nodes adjacent to the working node have been inspected and the tentative labels changed if
possible, the entire graph is searched for the tentatively-labeled node with the smallest value. This node is
made permanent and becomes the working node for the next round. Figure shows the first five steps of the
algorithm.
To see why the algorithm works, look at Fig. (c). At that point we have just made E permanent. Suppose that
there were a shorter path than ABE, say AXYZE. There are two possibilities: either node Z has already been
made permanent, or it has not been. If it has, then E has already been probed (on the round following the one
when Z was made permanent), so the AXYZE path has not escaped our attention and thus cannot be a shorter
path.
Now consider the case where Z is still tentatively labeled. Either the label at Z is greater than or equal to that
at E, in which case AXYZE cannot be a shorter path than ABE, or it is less than that of E, in which case Z and
not E will become permanent first, allowing E to be probed from Z.
This algorithm is given in Fig. 5-8. The global variables n and dist describe the graph and are initialized before
shortest path is called. The only difference between the program and the algorithm described above is that in
Fig. 5-8, we compute the shortest path starting at the terminal node, t, rather than at the source node, s. Since
the shortest path from t to s in an undirected graph is the same as the shortest path from s to t, it does not
matter at which end we begin (unless there are several shortest paths, in which case reversing the search might
discover a different one). The reason for searching backward is that each node is labeled with its predecessor
rather than its successor. When the final path is copied into the output variable, path, the path is thus reversed.
By reversing the search, the two effects cancel, and the answer is produced in the correct order.
Figure: The first five steps used in computing the shortest path from A to D. The arrows indicate the working
node
Finally, Destination ‘D’ is relabeled as D (10, H). The path is (D-H-F-E-B-A) as follows:
D(10,H) = H(8,F)
= F(6,E)
= E(4,B)
= B(2,A)
= A
SOURCE CODE:
#include<stdio.h>
#include<stdlib.h>
#define MAX_NODES 1024
#define INFINITY 1000
int n=8,cost=0,dist[8][8]={{0,2,0,0,0,0,6,0},
{2,0,7,0,2,0,0,0},
{0,7,0,3,0,3,0,0},
{0,0,3,0,0,0,0,2},
{0,2,0,0,0,2,1,0},
{0,0,3,0,2,0,0,2},
{6,0,0,0,1,0,0,4},
{0,0,0,2,0,2,4,0}};
for(p=&state[0];p<&state[n];p++)
{
p->pre=-1;
p->length=INFINITY;
p->label=0;
}
state[0].length=0;
state[0].label=1;
state[0].pre=-1;
k=t;
do
{
for(i=0;i<n;i++)
if(dist[k][i]!=0 && state[i].label==0)
{
if(state[k].length+dist[k][i]<state[i].length)
{
state[i].pre=k;
state[i].length=state[k].length+dist[k][i];
}
}
k=0;
min=INFINITY;
for(i=0;i<n;i++)
}while(k!=s);
i=0;
k=s;
do
{
}while(k>=0);
return i;
}
void main()
{
int i,j,m,path[102],q,p;
m=shortest_dist(q-1,p-1,path);
for(i=0;i<m;i++)
{
printf(" %c-> ",path[i]+'A');
}
printf("\nCost is: %d \n",cost);
}
Output:
Enter Number of nodes(1-8): 7
Enter Source Vertex (1-8): 1
Enter Destination vertex(1-8): 7
G-> E-> B-> A->
Cost is: 6
Result:
Thus the program Implement Dijkstra ‘s algorithm to compute the Shortest path through a graph is
executed
Viva Question and Answers
4. Dijkstra’s Algorithm run on a weighted, directed graph G={V,E} with non-negative weight
function?
The equality d[u]=delta(s,u) holds good when vertex u is added to set S and this equality is
maintained thereafter by the upper bound property.
THEORY:
Sending a packet to all destinations simultaneously is called broadcasting. The set of optimal routes from a
source to all destinations form a tree rooted at the source. Such a tree is called a sink tree. It is illustrated in
Fig., where the distance metric is the number of hops. Note that a sink tree is not necessarily unique; other
trees with the same path lengths may exist. The goal of all routing algorithms is to discover and use the sink
trees for all routers
SOURCE CODE:
#include<stdio.h>
#include<stdlib.h>
#define MAX_NODES 20
#define INFINITY 1000
for(j=0;j<n;j++)
{
i=0;k=j;
do
{
path[j][i++]=k;
k=state[k].prev;
}
while(k>=0);
hops[j]=i;
}
}
Output:
->0->2
->1->2
->2
->3->2
Result:
Thus the program to obtain broadcast tree for an example subnet of hosts is executed.
2. What is Any-casting?
Any-casting: If the message is sent to any of the nodes from the source then it is known as anycasting. It is
mainly used to get the content from any of the servers in the Content Delivery System.
3. What is Multicasting?
Multicasting: If the message is sent to a subset of nodes from the source then it is known as multicasting.
Used to send the same data to multiple receivers.
4. What is Broadcasting?
Broadcasting: If the message is sent to all the nodes in a network from a source then it is known as
broadcasting. DHCP and ARP in the local network use broadcasting.
THEORY:
Each node constructs a one-dimensional array containing the "distances"(costs) to all other nodes and
distributes that vector to its immediate neighbors.
The starting assumption for distance-vector routing is that each node knows the cost of the link to each
of its directly connected neighbors.
A link that is down is assigned an infinite cost.
Example.
A 0 1 1 � 1 1 �
B 1 0 1 � � � �
C 1 1 0 1 � � �
D � � 1 0 � � 1
E 1 � � � 0 � �
F 1 � � � � 0 1
G � � � 1 � 1 0
Table 1. Initial distances stored at each node(global view).
1. We can represent each node's knowledge about the distances to all other nodes as a table like the one
given in Table 1.
2. Note that each node only knows the information in one row of the table.
3. Every node sends a message to its directly connected neighbors containing its personal list of distance.
( for example, A sends its information to its neighbors B,C,E, and F. )
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
4. If any of the recipients of the information from A find that A is advertising a path shorter than the one
they currently know about, they update their list to give the new path length and note that they should
send packets for that destination through A. ( node B learns from A that node E can be reached at a cost of
1; B also knows it can reach A at a cost of 1, so it adds these to get the cost of reaching E by means
of A. B records that it can reach E at a cost of 2 by going through A.)
5. After every node has exchanged a few updates with its directly connected neighbors, all nodes will know
the least-cost path to all the other nodes.
6. In addition to updating their list of distances when they receive updates, the nodes need to keep track of
which node told them about the path that they used to calculate the cost, so that they can create their
forwarding table. ( for example, B knows that it was A who said " I can reach E in one hop" and so B puts
an entry in its table that says " To reach E, use the link to A.)
Information
Distance to Reach Node
Stored at Node
A B C D E F G
A 0 1 1 2 1 1 2
B 1 0 1 2 2 2 3
C 1 1 0 1 2 2 2
D 2 1 0 3 2 1
E 1 2 2 3 0 2 3
Table 2. final distances stored at each node ( global view).
In practice, each node's forwarding
F table
1 consists
2 of2a set 2of triples
2 of 0the form:1 ( Destination, Cost,
NextHop).
A 1 A
C 1 C
D 2 C
E 2 A
F 2 A
G 3 A
Table 3. Routing table maintained at node B.
SOURCE CODE:
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
scanf("%d",&dmat[i][j]);
dmat[i][i]=0;
rt[i].dist[j]=dmat[i][j];
rt[i].from[j]=j;
}
do
{
count=0;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
for(k=0;k<n;k++)
if(rt[i].dist[j]>dmat[i][k]+rt[k].dist[j])
{
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;
count++;
}
}while(count!=0);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
printf("\n state value for router %d is\n",i+1);
for(j=0;j<n;j++)
{
printf("\n node %d via %d Distance %d", j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf("\n");
}
Output:
Result:
Thus the program for obtain Routing table art each node using distance vector routing algorithm is
executed.
3. What Is Routing?
The ROUTING TABLE is a table maintained in the kernel that determines how packets are
routed to other systems. A number of programs may add or delete routes from the routing tables,
including route, ifconfig, in.routed and in.rdisc. The routing table consists of three types of routes:
HOST ROUTES are checked first and define a route to just one host. NETWORK ROUTES are
checked second and define a route to all the hosts on one network. DEFAULT ROUTES are used as a
catch-all, when no host or network routes are found to a destination. They usually send to a more
knowledgeable routing machine, which has a better chance of being able to find a host or network route
to the destination.
THEORY:
Data encryption and decryption
Encryption is the process of translating plain text data (plaintext) into something that appears to be
random and meaningless (ciphertext). Decryption is the process of converting ciphertext back to
plaintext.
To encrypt more than a small amount of data, symmetric encryption is used. A symmetric key is used
during both the encryption and decryption processes. To decrypt a particular piece of ciphertext, the
key that was used to encrypt the data must be used.
The goal of every encryption algorithm is to make it as difficult as possible to decrypt the generated
ciphertext without using the key. If a really good encryption algorithm is used, then there's no
technique significantly better than methodically trying every possible key. For such an algorithm, the
longer the key, the more difficult it is to decrypt a piece of ciphertext without possessing the key.
It's difficult to determine the quality of an encryption algorithm. Algorithms that look promising
sometimes turn out to be very easy to break, given the proper attack. When selecting an encryption
algorithm, it's a good idea to choose one that's been in use for several years, and has successfully
resisted all attacks.
SOURCE CODE:
#include <stdio.h>
int main()
{
int i, x;
char str[100];
printf("\nPlease enter a string:\t");
gets(str);
printf("\nPlease choose following options:\n");
printf("1 = Encrypt the string.\n");
printf("2 = Decrypt the string.\n");
scanf("%d", &x);
case 2:
for(i = 0; (i < 100 && str[i] != '\0'); i++)
str[i] = str[i] - 3; //the key for encryption is 3 that is subtracted to ASCII value
default:
printf("\nError\n");
}
return 0;
}
}
OUTPUT:
1. What is FDM?
FDM is an analog technique that can be applied when the bandwidth of a link is greater than the combined
bandwidths of the signals to be transmitted.
2. What is WDM?
WDM is conceptually the same as FDM, except that the multiplexing and de multiplexing involve light signals
transmitted through fiber optics channel.
3. What is TDM?
TDM is a digital process that can be applied when the data rate capacity of the transmission medium is greater than
the data rate required by the sending and receiving devices.
4. What is Synchronous TDM?
In STDM, the multiplexer allocates exactly the same time slot to each device at all times, whether or not a device has
anything to transmit.
The congesting control algorithms are basically divided into two groups: open loop and closed loop. Open
loop solutions attempt to solve the problem by good design, in essence, to make sure it does not occur in the
first place. Once the system is up and running, midcourse corrections are not made. Open loop algorithms are
further divided into ones that act at source versus ones that act at the destination.
In contrast, closed loop solutions are based on the concept of a feedback loop if there is any congestion.
Closed loop algorithms are also divided into two sub categories: explicit feedback and implicit feedback. In
explicit feedback algorithms, packets are sent back from the point of congestion to warn the source. In implicit
algorithm, the source deduces the existence of congestion by making local observation, such as the time
needed for acknowledgment to come back.
The presence of congestion means that the load is (temporarily) greater than the resources (in part of the
system) can handle. For subnets that use virtual circuits internally, these methods can be used at the network
layer.
Another open loop method to help manage congestion is forcing the packet to be transmitted at a more
predictable rate. This approach to congestion management is widely used in ATM networks and is called
traffic shaping.
The other method is the leaky bucket algorithm. Each host is connected to the network by an interface
containing a leaky bucket, that is, a finite internal queue. If a packet arrives at the queue when it is full, the
packet is discarded. In other words, if one or more process are already queued, the new packet is
unceremoniously discarded. This arrangement can be built into the hardware interface or simulate d by the
host operating system. In fact it is nothing other than a single server queuing system with constant service
time.
The host is allowed to put one packet per clock tick onto the network. This mechanism turns an uneven flow
of packet from the user process inside the host into an even flow of packet onto the network, smoothing out
bursts and greatly reducing the chances of congestion.
SOURCE CODE:
# #include<stdio.h>
#include<stdlib.h>
#define MIN(x,y) (x>y)?y:x
int main()
{
int orate,drop=0,cap,x,count=0,inp[10]={0},i=0,nsec,ch;
printf("\n enter bucket size : ");
scanf("%d",&cap);
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
printf("\n enter output rate :");
scanf("%d",&orate);
do{
printf("\n enter number of packets coming at second %d :",i+1);
scanf("%d",&inp[i]);
i++;
printf("\n enter 1 to contiue or 0 to quit..........");
scanf("%d",&ch);
}while(ch);
nsec=i;
printf("\n second \t recieved \t sent \t dropped \t remained \n");
for(i=0;count || i<nsec;i++)
{
printf(" %d",i+1);
printf(" \t%d\t ",inp[i]);
printf(" \t %d\t ",MIN((inp[i]+count),orate));
if((x=inp[i]+count-orate)>0)
{
if(x>cap)
{
count=cap;
drop=x-cap;
}
else
{
count=x;
drop=0;
}
}
else
{
drop=0;
count=0;
}
printf(" \t %d \t %d \n",drop,count);
}
return 0;
}
Output
enter bucket size : 50
enter output rate :120
enter number of packets coming at second 1 :200
enter 1 to contiue or 0 to quit..........1
enter number of packets coming at second 2 :85
enter 1 to contiue or 0 to quit..........0
When the host has to send a packet , packet is In this leaky bucket holds tokens generated at regular
thrown in bucket. intervals of time.
Bursty traffic is converted into uniform traffic If there is a ready packet , a token is removed from
by leaky bucket. Bucket and packet is send.
If bucket is full in token Bucket, tokens are discard not packets. While in leaky bucket, packets are discarded.
Token Bucket can send Large bursts at a faster rate while leaky bucket always sends packets at constant rate.
SOURCE CODE:
#include<stdio.h>
struct frame{
int num;
char str[20];
};
struct frame arr[10];
int n;
void sort(){
int i,j;
struct frame temp;
for(i=0;i<n-1;i++)
for(j=0;j<n-i-1;j++)
if(arr[j].num>arr[j+1].num)
{ temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
int main()
{
int i;
system("clear");
printf("Enter the number of frames\n");
scanf("%d",&n);
printf("Enter the frame sequence number and frame contents\n");
for(i=0;i<n;i++)
scanf("%d%s",&arr[i].num,&arr[i].str);
sort();
printf("The frame in sequences\n");
for(i=0;i<n;i++)
printf("%d\t%s\n",arr[i].num,arr[i].str);
}
Output
Enter the number of frames
5
Enter the frame sequence number and frame contents
3
NETWORK LAYER
2
DATALINK LAYER
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
5
APPLICATION LAYER
1
PHYSICAL LAYER
4
TRANSPORT LAYER
1 PHYSICAL LAYER
2 DATALINK LAYER
3 NETWORK LAYER
4 TRANSPORT LAYER
5 APPLICATION LAYER
EXPERIMENT-10
PACKET SNIFFING AND WIRESHARK
Wireshark
Introduction
Wireshark is a free open- source network protocol analyzer. It is used for network troubleshooting and
communication protocol analysis. Wireshark captures network packets in real time and display them in human-
readable format. It provides many advanced features including live capture and offline analysis, three-pane
packet browser, coloring rules for analysis. This document uses Wireshark for the experiments, and it covers
Wireshark installation, packet capturing, and protocol analysis.
Background
- Application Layer: The application layer includes the protocols used by most applications for providing user
services. Examples of application layer protocols are Hypertext Transfer Protocol (HTTP), Secure Shell (SSH),
File Transfer Protocol (FTP), and Simple Mail Transfer Protocol (SMTP).
- Transport Layer: The transport layer establishes process-to-process connectivity, and it provides end-to-end
services that are independent of underlying user data. To implement the process-to-process communication, the
protocol introduces a concept of port. The examples of transport layer protocols are Transport Control Protocol
(TCP) and User Datagram Protocol (UDP). The TCP provides flow- control, connection establishment, and
reliable transmission of data, while the UDP is a connectionless transmission model.
- Internet Layer: The Internet layer is responsible for sending packets to across networks. It has two functions: 1)
Host identification by using IP addressing system (IPv4 and IPv6); and 2) packets routing from source to
destination. The examples of Internet layer protocols are Internet Protocol (IP), Internet Control Message
Protocol (ICMP), and Address Resolution Protocol (ARP).
- Link Layer: The link layer defines the networking methods within the scope of the local network link. It is used
to move the packets between two hosts on the same link.A common example of link layer protocols is Ethernet.
Packet Sniffer
Packet sniffer is a basic tool for observing network packet exchanges in a computer. As the name suggests, a
packet sniffer captures (“sniffs”) packets being sent/received from/by your computer; it will also typically store
and/or display the contents of the various protocol fields in these captured packets. A packet sniffer itself is
passive. It observes messages being sent and received by applications and protocols running on your computer,
but never sends packets itself.
Figure shows the structure of a packet sniffer. At the right of Figure are the protocols (in this case,
Internet protocols) and applications (such as a web browser or ftp client) that normally run on your computer.
The packet sniffer, shown within the dashed rectangle in Figure is an addition to the usual software in your
computer, and consists of two parts. The packet capture library receives a copy of every link-layer frame that is
sent from or received by your computer. Messages exchanged by higher layer protocols such as HTTP, FTP,
TCP, UDP, DNS, or IP all are eventually encapsulated in link-layer frames that are transmitted over physical
media such as an Ethernet cable. In Figure 1, the assumed physical media is an Ethernet, and so all upper-layer
protocols are eventually encapsulated within an Ethernet frame. Capturing all link-layer frames thus gives you
access to all messages sent/received from/by all protocols and applications executing in your computer.
The second component of a packet sniffer is the packet analyzer, which displays the contents of all fields
within a protocol message. In order to do so, the packet analyzer must “understand” the structure of all
messages exchanged by protocols. For example, suppose we are interested in displaying the various fields in
messages exchanged by the HTTP protocol in Figure. The packet analyzer understands the format of Ethernet
frames, and so can identify the IP datagram within an Ethernet frame. It also understands the IP datagram
format, so that it can extract the TCP segment within the IP datagram. Finally, it understands the TCP segment
structure, so it can extract the HTTP message contained in the TCP segment. Finally, it understands the HTTP
protocol and so, for example, knows that the first bytes of an HTTP message will contain the string “GET,”
“POST,” or “HEAD”.
We will be using the Wireshark packet sniffer [http://www.wireshark.org/] for these labs, allowing us to
display the contents of messages being sent/received from/by protocols at different levels of the protocol stack.
(Technically speaking, Wireshark is a packet analyzer that uses a packet capture library in your computer).
Wireshark is a free network protocol analyzer that runs on Windows, Linux/Unix, and Mac computers.
Getting Wireshark
Wireshark can be downloaded from here:
https://www.wireshark.org/download.html
Starting Wireshark
When you run the Wireshark program, the Wireshark graphic user interface will be shown as Figure 5.
Currently, the program is not capturing the packets.
The command menus are standard pulldown menus located at the top of the window. Of interest to us
now is the File and Capture menus. The File menu allows you to save captured packet data or open a file
containing previously captured packet data, and exit the Wireshark application. The Capture menu allows you
to begin packet capture.
The packet-listing window displays a one-line summary for each packet captured, including the packet
number (assigned by Wireshark; this is not a packet number contained in any protocol’s header), the time at
which the packet was captured, the packet’s source and destination addresses, the protocol type, and protocol-
specific information contained in the packet. The packet listing can be sorted according to any of these
categories by clicking on a column name. The protocol type field lists the highest- level protocol that sent or
received this packet, i.e., the protocol that is the source or ultimate sink for this packet.
The packet-header details window provides details about the packet selected (highlighted) in the
packet-listing window. (To select a packet in the packet-listing window, place the cursor over the packet’s one-
line summary in the packet-listing window and click with the left mouse button.). These details include
information about the Ethernet frame and IP datagram that contains this packet. The amount of Ethernet and IP-
layer detail displayed can be expanded or minimized by clicking on the right- pointing or down-pointing
arrowhead to the left of the Ethernet frame or IP datagram line in the packet details window. If the packet has
been carried over TCP or UDP, TCP or UDP details will also be displayed, which can similarly be expanded or
minimized. Finally, details about the highest-level protocol that sent or received this packet are also provided.
The packet-contents window displays the entire contents of the captured frame, in both ASCII and
hexadecimal format.
Towards the top of the Wireshark graphical user interface, is the packet display filter field, into which a
protocol name or other information can be entered in order to filter the information displayed in the packet-
listing window (and hence the packet-header and packet-contents windows). In the example below, we’ll use
the packet-display filter field to have Wireshark hide (not display) packets except those that correspond to
HTTP messages.
Capturing Packets
After downloading and installing Wireshark, you can launch it and click the name of an interface under
Interface List to start capturing packets on that interface. For example, if you want to capture traffic on the
wireless network, click your wireless interface.
Test Run
Do the following steps:
1.Start up the Wireshark program (select an interface and press start to capture packets).
2.Start up your favorite browser (Mozilla Firefox).
3.In your browser, go to Wayne State homepage by typing www.wayne.edu.
4.After your browser has displayed the http://www.wayne.edu page, stop Wireshark packet capture by
selecting stop in the Wireshark capture window. This will cause the Wireshark capture window to disappear
and the main Wireshark window to display all packets captured since you began packet capture see image
below:
5.Color Coding: You’ll probably see packets highlighted in green, blue, and black. Wireshark uses colors to
help you identify the types of traffic at a glance. By default, green is TCP traffic, dark blue is DNS traffic,
light blue is UDP traffic, and black identifies TCP packets with problems — for example, they could have
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
6.You now have live packet data that contains all protocol messages exchanged between your computer and
other network entities! However, as you will notice the HTTP messages are not clearly shown because there
are many other packets included in the packet capture. Even though the only action you took was to open
your browser, there are many other programs in your computer that communicate via the network in the
background. To filter the connections to the ones we want to focus on, we have to use the filtering
functionality of Wireshark by typing “http” in the filtering field as shown below:
Notice that we now view only the packets that are of protocol HTTP. However, we also still do not have the
exact communication we want to focus on because using HTTP as a filter is not descriptive enough to allow us
to find our connection to http://www.wayne.edu. We need to be more precise if we want to capture the correct
set of packets.
7. To further filter packets in Wireshark, we need to use a more precise filter. By setting the
http.host==www.wayne.edu, we are restricting the view to packets that have as an http host the
www.wayne.edu website. Notice that we need two equal signs to perform the match “==” not just one. See the
screenshot below:
1. Now, we can try another protocol. Let’s use Domain Name System (DNS) protocol as an example here.
2. Let’s try now to find out what are those packets contain by following one of the conversations (also called
network flows), select one of the packets and press the right mouse button (if you are on a Mac use the
command button and click), you should see something similar to the screen below:
Click on Follow UDP Stream, and then you will see following screen.
3. If we close this window and change the filter back to “http.host==www.wayne.edu” and then follow a packet
from the list of packets that match that filter, we should get the something similar to the following screens. Note
that we click on Follow TCP Stream this time.
1. What is Wireshark?
Wireshark is a network protocol analyzer. It lets you capture and interactively browse the traffic
running on a computer network. It has a rich and powerful feature set and is world's most popular tool of its
kind. It runs on most computing platforms including Windows, macOS, Linux, and UNIX. Network
professionals, security experts, developers, and educators around the world use it regularly. It is freely
available as open source, and is released under the GNU General Public License version 2. It
is developed and maintained by a global team of protocol experts, and it is an example of a disruptive
technology.
Wireshark used to be known as Ethereal®. See the next question for details about the name change. If you're
still using Ethereal, it is strongly recommended that you upgrade to Wireshark as Ethereal is
unsupported and has known security vulnerabilities.
2. How would you setup wireshark to monitor packets passing through an internet router
A system on the network can be configured and setup with wireshark. The appropriate port on the
switch to which the system and internet router is connected can be configured for port mirroring. All packets
passing through the switch interface to the router can be mirrored to the system on which wireshark is setup.
5. A user is unable to ping a system on the network. How can wireshark be used to solve the problem.
Ping uses ICMP. Wireshark can be used to check if ICMP packets are being sent out from the
system. If it is sent out, it can also be checked if the packets are being received.
6. Which wireshark filter can be used to check all incoming requests to a HTTP Web server
HTTP web servers use TCP port 80. Incoming requests to the web server would have the destination
port number as 80. So the filter tcp.dstport==80.
7. Which wireshark filter can be used to monitor outgoing packets from a specific system on the network?
Outgoing packets would contain the IP address of the system as it’s source address. So assuming
that the IP address of the system is 192.168.1.2, the filter would be ip.src==192.168.1.2
EXPERIMENT-11
How to run Nmap scan
HOW TO RUN A SIMPLE NMAP SCAN
1. Download the Nmap installer. This can be found for free from the developer’s website. It is highly
recommended that you download directly from the developer to avoid any potential viruses or fake files.
Downloading the Nmap installer includes Zenmap, the graphical interface for Nmap which makes it easy for
newcomers to perform scans without having to learn command lines.
The Zenmap program is available for Windows, Linux, and Mac OS X. You can find the installation files
for all operating systems on the Nmap website.
2. Install Nmap. Run the installer once it is finished downloading. You will be asked which components you
would like to install. In order to get the full benefit of Nmap, keep all of these checked. Nmap will not install
any adware or spyware.
3. Run the “Nmap – Zenmap” GUI program. If you left your settings at default during installation, you
should be able to see an icon for it on your desktop. If not, look in your Start menu. Opening Zenmap will start
the program.
4. Enter in the target for your scan. The Zenmap program makes scanning a fairly simple process. The first
step to running a scan is choosing your target. You can enter a domain (example.com), an IP address
(127.0.0.1), a network (192.168.1.0/24), or a combination of those.
Depending on the intensity and target of your scan, running an Nmap scan may be against the terms of your
internet service provider, and may land you in hot water. Always check your local laws and your ISP
contract before performing Nmap scans on targets other than your own network.
5. Choose your Profile. Profiles are preset groupings of modifiers that change what is scanned. The profiles
allow you to quickly select different types of scans without having to type in the modifiers on the command
line. Choose the profile that best fits your needs:
Intense scan - A comprehensive scan. Contains Operating System (OS) detection, version detection, script
scanning, traceroute, and has aggressive scan timing. This is considered an intrusive scan.
Ping scan - This scan simply detects if the targets are online, it does not scan any ports.
Quick scan - This is quicker than a regular scan due to aggressive timing and only scanning select ports.
Regular scan - This is the standard Nmap scan without any modifiers. It will return ping and return open
ports on the target.
6. Click Scan to start scanning. The active results of the scan will be displayed in the Nmap Output tab. The
time the scan takes will depend on the scan profile you chose, the physical distance to the target, and the target’s
network configuration.
7. Read your results. Once the scan is finished, you’ll see the message “Nmap done” at the bottom of the
Nmap Output tab. You can now check your results, depending on the type of scan you performed. All of the
results will be listed in the main Nmap Output tab, but you can use the other tabs to get a better look at specific
data.
Ports/Hosts - This tab will show the results of your port scan, including the services for those ports.
Topology - This shows the traceroute for the scan you performed. You can see how many hops your data
goes through to reach the target.
Host Details - This shows a summary of your target learned through scans, such as the number of ports, IP
addresses, hostnames, operating systems, and more.
Scans - This tab stores the commands of your previously-run scans. This allows you to quickly re-scan
with a specific set of parameters.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
EXPERIEMENT: 12
Operating System Detection using Nmap
$cat <target-file>
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
192.168.1.1
192.168.1.10-100
Q3. How to write Nmap command for specific ports and services?
Ans:
#using wildcard
$nmap -p snmp* <target>
EXPERIMENT NO: 13
NAME OF THE EXPERIMENT: NS2 Simulator
Description:
NS2 Simulator-Introduction
1. NS2 stands for Network Simulator Version
2. It is an open-source event-driven simulator designedspecifically for research in computer
communication networks.
Features of NS2
1. It is a discrete event simulator for networking research.
2. It provides substantial support to simulate bunch of protocols like TCP, FTP, UDP, https and DSR.
Network simulation is an important tool in developing, testing and evaluating network protocols.
Simulation can be used without the target physical hardware, making it economical and practical for
almost any scale of network topology and setup.
GETTING STARTED
Setting up the environment
A user using the NCTUns in single machine mode, needs to do the following steps before
he/she starts the GUI program:
1. Set up environment variables:
Before the user can run up the dispatcher, coordinator, or NCTUns GUI programhe/she must set up
the NCTUNSHOME environment variable.
2. Start up the dispatcher on terminal 1.
3. Start up the coordinator on terminal 2.
4. Start up the nctunsclient on terminal 3.
After the above steps are followed, the starting screen of NCTUns disappears and the user is
presented with the working window as shown below:
i) Simulate a three node point to point network with a duplex link between them. Set the queue
size and vary the bandwidth and find the number of packets dropped.
Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
2. Select Add button on the HOST window to invoke the command window and provide the following
command in the command textbox.
stg –u 1024 100 1.0.1.2
3. Click OK button on the command window to exit and once again click on the OK button on the
HOST window to exit.
4. Double click the left mouse button while cursor is on HOST2 to open the HOST window.
5. Select Add button on the HOST window to invoke the command window and provide the following
command in the command textbox.
rtg –u –w log1
6. Click OK button on the command window toexit.
7. Click NODE EDITOR Button on the HOST window and select the MAC tab fromthe modal window
that pops up.
8. Select LOG STATISTICS and select checkboxes for Number of Drop Packetand Number of
Collisions in the MAC window
9. Click OK button on the MAC window to exit and once again click on the OK buttonon the HOST
window to exit.
Note: To set QUEUEsize
1. Double click the left mouse button while cursor is on HOST2 to open the HOST window.
2. Click NODE EDITOR Button on the HOST window and select the FIFO tab from the modal
window that pops up.
3. Change Queue size (Default 50).
4. Click OK button on the FIFO window to exit and once again click on the OK buttonon the HOST
window to exit.
5.
Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the dropdownlist to execute the
simulation.
iii. venTo start playback select “►” icon located at the bottom right corner ofthe editor.
iv. To view results, Open up new TERMINAL window, move to file1.results folder and open collision
and drop log files in separate TERMINAL window.
v.
Changing configurationsChange1
1. Open the above file,
2. Do not change the topology or any other configuration,
3. Select E icon on thetoolbar
4. Reduce the bandwidth at link2 by double clicking the left mouse button while cursor ison link2
.(Change bandwidth on both tabs Uplink/Downlink)
5. Repeat Step3 (Simulate)
Change 2
1. Open the above file.
2. Remove HUB and replace it with SWITCH.
3. Do not change anything in theconfiguration
4. Repeat Step3(Simulate)
ii) Simulate a four node point to point network and connect the link as follows Apply a
TCP agent between n0 to n3 and apply a UDP agent between n1 and n3.Apply relevant
applications over TCP and UDP agents changing the parameters and determine the number of
packets sent by two agents.
Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
2. Change simulation time from 0 to 20 for HOST1
3. Select Add button on the HOST1 window to invoke the command window and provide the following
command in the command textbox.
ttcp –t –u –s –p 8000 1.0.1.3
4. Click OK button onthe command window to exit
5. Click NODE EDITOR Button on the HOST window and select the MAC tab from the modal
window that pops up.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
6. Select LOG STATISTICS and select checkbox for output throughput in the MAC window
7. Click OK button on the MAC window to exit and once again click on the OK button on
the HOST window to exit.
8. Double click the left mouse button while cursor is on HOST2 to open the HOST window.
9. Change simulation time from 21 to 40 for HOST2
10. Select Add button on the HOST2 window to invoke the command window and provide the following
command in the command textbox.
Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the dropdownlist to execute the
simulation.
iii. To start playback select “►” icon located at the bottom right corner of theeditor.
iv. To view results, Open up new TERMINAL window, move to file2.results folder and open input and
output throughput log files in separate TERMINAL window.
iii) Simulate the transmission of ping messages over a network topology consisting of 6
nodes and find the number of packets dropped due to congestion.
3. Click on the “E” icon on the toolbar to save the current topology e.g: file4.tpl (Look for the
******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.
Step2: Configuration
1. Make 5 HOST as sender and make 1 HOST as receiver and give the commands with particular port
number
2. Sender Commands
Sender 1 : stcp –p 21 –l 1024 1.0.1.1
Sender 2 : stcp –p 22 –l 1024 1.0.1.1
Sender 3 : stcp –p 23 –l 1024 1.0.1.1
Sender 4 : stcp –p 24 –l 1024 1.0.1.1
Sender 5 : stcp –p 25 –l 1024 1.0.1.1
Receiver Commands
rtcp –p 21 –l 1024
rtcp –p 22 –l 1024
rtcp –p 23 –l 1024
rtcp –p 24 –l 1024
rtcp –p 25 –l 1024
3. For each sender HOST select the Out through put, Collision and Droppackets.
4. For receiver HOST select the In throught put, Collision and Drop packets.
5.
Step3: Simulate
i. Click “R” icon on the tool bar
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
ii. Select Simulation in the menu bar and click/ select RUN in the dropdown list to execute the
simulation.
iii. During simulation, double click the mouse button on any sender HOST, the HOST window pops
up, select / click on command console button located atthe bottom.
iv. A terminal window appears, type ping IP address of a receiver HOST in the subnet atthe command
prompt.
v. To view results, Open up new TERMINAL window, move to file4.results folder andopen drop and
collision log files in separate TERMINAL window.
vi.
iv) Simulate an ETHERNET LAN using n nodes (6-10), change error rate and data rate
and compare throughput.
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.
Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1to open theHOST window.
2. Select Add button on the HOST window to invoke the command window and provide the following
command in the command textbox.
ttcp –t –u –s –p 8001 1.0.1.4 (Split time from 0 to 10)
3. Change error rate and data rate in the physical layer and selectOut throughput in MAC layer
4. Click OK button on the command window to exit and once againclick on the OK button on the
HOST window to exit.
5. Repeat this step at HOST 2 and HOST3 by changing port number& IP address of receiver. Change
error rate and data rate.
ttcp –t –u –s –p 8002 1.0.1.5 (Split time from 11 to 20)
ttcp –t –u –s –p 8003 1.0.1.6 (Split time from 21 to 30)
5. Double click the left mouse button while cursor is on HOST4to open theHOST window.
6. Select Add button on the HOST window to invoke the commandwindow and provide the following
command in the command textbox.
ttcp –r –u –s –p 8001(Split time from 0 to 10)
7. Change error rate and data rate in the physical layer and selectIN throughput in MAC layer
8. Repeat this step at HOST 5 and HOST6, but use different commands. Change error rate and data
rate.
ttcp –r –u –s –p 8002(Split time from 11 to 20)ttcp –r –u –s –p 8003(Split time from 21 to 30)
Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the dropdown list to execute the
simulation.
iii. To start playback select “►” icon located at the bottom right corner of the editor. To view results,
Open up new TERMINAL window, move to file5.results folder and open output throughput log
files in separate TERMINAL window.
v) Simulate an ETHERNET LAN using n nodes and set multiple traffic nodes and plot
congestion window for different source/destination.
1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor, to place
HOST1 on the editor.
i. Repeat the above procedure and place 3 other hosts “HOST2”, “HOST3”, “HOST4”, “HOST5”, and
“HOST6”on the editor.
2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor, to place
HUB1 on the editor.
Repeat the above procedure and place another host “HUB2” on the editor
3. Click on the LINK icon on the toolbar and connect HOST1, HOST2 and HOST3 to HUB1, HOST4,
HOST5 and HOST6 to HUB2.
4. Select/click the SWITCH icon on the toolbar and click the left mousebutton on the editor, to place
SWITCH1 the editor.
5. Click on the LINK icon on the toolbar and connect HUB1 to SWITCH1 and HUB2 to SWITCH1.
Click on the “E” icon on the toolbar to save the current topology e.g:
file7.tpl (Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selectingthe “E” icon.
Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
2. Select Add button on the HOST window to invoke the command window and provide the following
command in the command textbox.
ttcp –t –u –s –p 8001 1.0.1.4
3. Click OK button on the command window to exit and once againclick on the OK button on the
HOST window to exit.
4. Repeat this step at HOST 2 and HOST3 by changing port number & IP address of receiver. Change
error rate and data rate.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
Step3: Simulate
i. Click “R” icon on the toolbar
Select Simulation in the menu bar and click/ select RUN in the dropdown list to execute the
simulation.
i. To start playback select “►” icon located at the bottom right corner oftheeditor.
iv. To plot congestion window select Tools in the menu bar and select
PLOT GRAPH in the drop down list.
v. In the Graph window, select File->OPEN, move to file7.results folder and the drop and collision log
file.
vi. To open another Graph window, Select File->New tab on the drop down list to open up to a
maximum of 6 windows
vii. To view results, Open up new TERMINAL window, move to file7.results folder and open input and
output throughput log files in separate TERMINAL window.
vi) Simulate simple BSS and with transmitting nodes in wireless LAN by simulation and
determine the performance with respect to transmission of packets.
To create Subnet
7. Select wireless subnet icon in the toolbar now select MOBILE NODE1, MOBILE NODE2 and
ACCESS POINT1 by clicking on left mouse button, and clicking right mouse button will create a
subnet.
8. Repeat the above step for MOBILE NODE3, MOBILE NODE4 and ACCESS POINT2.
9. Click on the “E” icon on the toolbar to save the current topology e.g:
file8.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.
Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
2. Select Add button on the HOST window to invoke the command window and providethe following
command in the command textbox.
ttcp –r –u –s –p 8001
3. Click OK button onthe command window to exit
4. Repeat this step and add the following commands at HOST1ttcp –r –u –s –p 8002
ttcp –r –u –s –p 8003ttcp –r –u –s –p 8004 ttcp –r –u –s –p 8005
5. Click NODE EDITOR Button on the HOST1 window and select the MACtab from the modal
window that pops up.
6. Select LOG STATISTICS and select checkbox for Input throughput in the MAC window
7. Click OK button on the MAC window to exit and once again click on theOK button on the HOST
window to exit.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
8. Double click the left mouse button while cursor is on MOBILE NODE 1 to open the MOBILE
NODE window.
9. Select Application tab and select Add button to invoke the command window and provide the
following command in the command textbox.
ttcp –t –u –s –p 8001 1.0.2.2 (host’s ip address)
10. Click NODE EDITOR Button on the MOBILE NODE1 window andselect the MAC tab
from the nodal window that pops up.
11. Select LOG STATISTICS and select checkbox for Output throughput in the MACwindow
12. Click OK button on the MAC window to exit and once again click onthe OK button onthe
MOBILE NODE1 window to exit.
13. Repeat the above steps (step 8 to step12) for the MOBILE NODE2,3 and4 and add
thefollowing commands at
MOBILE NODE2:- ttcp –t –u –s –p 8002 1.0.2.2 MOBILE NODE 3:- ttcp –t–u –s –p 8003
1.0.2.2 MOBILE NODE4:- ttcp –t –u –s –p 8004 1.0.2.2
14. Double click the left mouse button while cursor is on ROTER1 to open the ROUTER
window.
15. Click NODE EDITOR Button on the ROUTER1 window and you can see three stacks.
two stacks for two ACCESS POINTS and another stackfor HOST1 which is connected to the
ROUTER1.
16. Select the MAC tab of ACCESS POINT1 and Select LOG STATISTICS and select
checkbox for Input throughput in the MAC window. Click OK button on the MAC window to exit.
17. Select the MAC tab of ACCESS POINT2 and Select LOG STATISTICS and select
checkbox for Input throughput in the MAC window. Click OK button on the MAC window to exit.
18. Select the MAC tab of HOST1 and Select LOG STATISTICS and select checkbox
forOutput throughput in the MAC window. Click OK button onthe MAC window to exit.
19. Add the following command for router
ttcp –t –u –s –p 8005 1.0.2.2 (host’s ip address)
Step3: Simulate
I Click “R” icon on the tool bar
.
I Select Simulation in the menu bar and click/ select
I RUN in the
.
dropdown list to execute the simulation.
III. To start playback select “►” icon located at the bottom right corner of theeditor.
IV. MOBILE NODE’s start moving across the paths alreadydrawn.