CN Lab Manual Print PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

Academic Year 2019-20

VI SEMESTER
CBCS 2017 scheme

DEPARTMENT OF ELECTRONICS AND


COMMUNICATION ENGINEERING
Prepared by Scrutinized by
Prof. Naazneen M G Prof. Khamer Fathima
Assistant Professor Assistant Professor
Dept of E&CE Dept of E&CE

Lab Incharge
Prof. Mohammed Jebran P

Lab Instructor
Mr. Asif Pasha

#22/1,Opp. Manyata Tech Park, Nagavara, Bengaluru,


Karnataka 560045
COMPUTER NETWORKS LAB
B.E., VI Semester, Electronics & Communication Engineering
[As per Choice Based Credit System (CBCS) Scheme]
Course Code 17ECL68 CIE Marks 40
Number of Lecture 01Hr Tutorial (Instructions) SEE Marks 60
Hours/Week + 02 Hours Laboratory = 03
RBT Levels L1, L2, L3 Exam Hours 03
CREDITS – 02
Course objectives: This course will enable students to:
• Choose suitable tools to model a network and understand the protocols at various OSI
reference levels.
• Design a suitable network and simulate using a Network simulator tool.
• Simulate the networking concepts and protocols using C/C++ programming. Model the
networks for different configurations and analyze the results.
Laboratory Experiments
PART A: Simulation experiments using NS2/ NS3/ OPNET/ NCTUNS/ NetSim/ QualNet or any
other equivalent tool
1. Implement a point to point network with four nodes and duplex links between them. Analyze
the network performance by setting the queue size and varying the bandwidth.
2. Implement a four node point to point network with links n0-n2, n1-n2 and n2-n3. Apply TCP
agent between n0-n3 and UDP between n1-n3. Apply relevant applications over TCP and UDP
agents changing the parameter and determine the number of packets sent by TCP/UDP.
3. Implement Ethernet LAN using n (6-10) nodes. Compare the throughput by changing the error
rate and data rate.
4. Implement Ethernet LAN using n nodes and assign multiple traffic to the nodes and obtain
congestion window for different sources/ destinations.
5. Implement ESS with transmission nodes in Wireless LAN and obtain the performance
parameters.

6. Implementation of Link state routing algorithm.


PART-B: Implement the following in C/C++
1. Write a program for a HLDC frame to perform the following.
i) Bit stuffing
ii) Character stuffing.
2. Write a program for distance vector algorithm to find suitable path for transmission.
3. Implement Dijkstra‘s algorithm to compute the shortest routing path.
4. For the given data, use CRC-CCITT polynomial to obtain CRC code. Verify the program
for the cases

a. Without error
b. With error
5. Implementation of Stop and Wait Protocol and Sliding Window Protocol
6. Write a program for congestion control using leaky bucket algorithm
Course outcomes: On the completion of this laboratory course, the students will be able to:
• Use the network simulator for learning and practice of networking algorithms. Illustrate
the operations of network protocols and algorithms using C programming.
• Simulate the network with different configurations to measure the performance parameters.
• Implement the data link and routing protocols using C programming.
Conduct of Practical Examination:
• All laboratory experiments are to be included for practical examination.
• For examination one question from software and one question from hardware or only one
hardware experiments based on the complexity to be set.
• Students are allowed to pick one experiment from the lot.
• Strictly follow the instructions as printed on the cover page of answer script for breakup of
marks.
• Change of experiment is allowed only once and Marks allotted to the procedure part to be
made zero.
B.E: Electronics & Communication Engineering

Program Outcomes (POs)


At the end of the B.E program, students are expected to have developed the following
outcomes.

1. Engineering Knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering
problems.
2. Problem analysis: Identify, formulate, research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid conclusions.
5. Modern Tool Usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modelling to complex engineering
activities with an understanding of the limitations.
6. The Engineer and Society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal, and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.
7. Environment and Sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts and demonstrate the knowledge of need for
sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
9. Individual and Teamwork: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive
clear instructions.
11. Project Management and Finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one‘s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage
in independent and life-long learning in the broadest context of technological change

B) PROGRAM SPECIFIC OUTCOMES (PSOs)

1. Professional Skills: An ability to understand the basic concepts in Electronics &


Communication Engineering and to apply them to various areas, like Electronics,
Communications, Signal processing, VLSI, Embedded systems etc., in the design and
implementation of complex systems.

2. Problem-Solving Skills: An ability to solve complex Electronics and communication


Engineering problems, using latest hardware and software tools, along with analytical skills to
arrive cost effective and appropriate solutions.

3. Entrepreneur: An ability to become an entrepreneur or to contribute to industrial services


and / or Govt. organizations in the field of Electronics and Communication Engg.

4. Multidisciplinary Programming: An ability to work on multidisciplinary teams with


efficiency in different Programming techniques.
INDEX
NAME:
SUBJECT: 17ECL68 (Computer Networks Lab)

Sl. Date Title Page Marks Sign


No No.
PART A: Simulation using NCTUns.

Implement a point to point network with four nodes and


duplex links between them. Analyze the network
1
performance by setting the queue size and varying the
bandwidth.

Implement a four node point to point network with links n0-


n2, n1-n2 and n2-n3. Apply TCP agent between n0-n3 and
UDP between n1-n3. Apply relevant applications over TCP
2
and UDP agents changing the parameter and determine the
number of packets sent by TCP/UDP.

Implement Ethernet LAN using n (6-10) nodes. Compare the


throughput by changing the error rate and data rate.
3

Implement Ethernet LAN using n nodes and assign multiple


traffic to the nodes and obtain congestion window for
4 different sources/destinations.

Implement ESS with transmission nodes in Wireless LAN


5 and obtain the performance parameters.

Implement Link state routing algorithm


6
Sl. Page
Date Title Marks Sign
No No.
PART B: Perform Experiments using C/C++.
1. Write a program for a HLDC frame to perform the
following:
(i) Bit stuffing
(ii) Character stuffing.
2. Write a program for distance vector algorithm to find
suitable path for transmission.
3. Implement Dijkstra’s algorithm to compute the shortest
routing path.
4. For the given data, use CRC-CCITT polynomial to obtain
CRC code. Verify the program for the cases
a. Without error
b. With error
5. Implementation of Stop and Wait Protocol and Sliding
Window Protocol
6. Write a program for congestion control using leaky bucket
algorithm
Computer Networks Lab Manual 17ECL68 2019-20

PART A – NCTUNS SIMULATION

Introduction to Simulation

To study the network performance two things, you can use:


Emulator
Simulator

Emulator
A device on the [LAN], Real network, actual equipment, real software or a part of the
real system is replaced by a model. This model is called Emulator. Properties of an
existing part are simulated (only the part of the real system). A network emulator
emulates the network, imitates the behavior of application traffic.

Objective:
➢ To test control systems, under realistic condition.
➢ To do analysis.
➢ To access the performance.
➢ To predict the impact of change
➢ To optimize technology decision-making.

Advantage:
Reflect results precisely

Disadvantage:
▪ Must run in real time
▪ Expensive
▪ Requires a lot of setup
▪ We won’t use emulation for experimentation.

Simulator
Network simulators are typically programs which run on a single computer, take
an abstract description of the network traffic (such as a flow arrival process) and yield
performance statistics (such as buffer occupancy as a function of time).

Objective:
To test and develop different solutions and finally to arrive at a best solution.

DEPARTMENT OF ECE 1 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Advantage:
▪ Cost effective
▪ Flexible.
▪ No risk involved. Extensive experiments can be done.
▪ Easier to analyze.

Disadvantage:
Not just a part but a complete network simulator needs to simulate
networking devices and application programs.
Needs network utility programs to configure and monitor.
Simulation model maintains its own simulation clock. When a decision is
taken within the model, the simulation clock does not advance until the
necessary calculations have been performed.
Results are not convincing.

Different types of simulators:


❖ REAQL
❖ NS
❖ OPNET
❖ NCTUns

NCTUns
• Open source,
• high quality
• support many type of networks
• Extensible. Can be used as emulator also.
• Uses real-life Linux’s TCP/IP protocol
• Uses real-life UNIX network configuration.
• Can simulate various networking devices.
• Can simulate various network protocols
• Simulation speed is high.
• It uses kernel re-enter methodology. For this it uses tunnel network interface.
Tunnel devices are available in most UNIX machines.
• NCTUns modifies the kernel to use a special virtual timer. The kernel code is
modified. Each kernel on which NCTUns runs need to be patched. Kernel
needs to be patched on all simulation machines.

DEPARTMENT OF ECE 2 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

NCTUns Architecture
NCTUns uses distributed Architecture.
NCTUns has following components. They
are:
a. GUI Operating Environment (nctunsclient)
b. Simulation Engine
c. Protocol and job Dispatcher
d. Coordinator
e. Kernel modification
f. User-level daemon and real-world application program
g. Remote, concurrent and Parallel simulation

i. GUI Operating Environment:


1. It is a GUI program which generates the simulation job.
2. It uses TCP/IP sockets to communicate with other components.
3. The simulation job generated is submitted to remote simulation
machine for execution. When the simulation is finished, the
simulation results and generated log files are transferred back to
the GUI. The user then examines the logged data and plots the
graphs, play back packet transfer animations.
ii. Simulation Engine:
1. It is a user level program. It is compiled along with Protocols to
form Simulation server. Simulation server takes simulation job
and generates data and log files.
iii. Protocol and job Dispatcher:
1. It is a user level program. It takes simulation jobs from the GUI
user and dispatches it to the simulation server machine.
2. It coordinates large number of GUI users and a large number of
simulation machines.
iv. Coordinator:
1. It is a user level program.
2. It is executed on every simulation machine where simulation
server resides.
3. It takes simulation jobs from the dispatcher and executes the
simulation server to process the simulation job.
4. Coordinator informs the dispatcher whether machine is busy or
not.
5. It communicates with the dispatcher and GUI on behalf of
server.
6. Message exchange between simulation server and GUI are
DEPARTMENT OF ECE 3 HKBKCE
Computer Networks Lab Manual 17ECL68 2019-20

performed through coordinator.

v.Kernel Modification
vi.User-level Daemon and real-world application program:
The NCTUns real-world application programs run at the user level to generate
network traffic, configure network, or monitor network traffic, etc. For
example, the tcpdump program can run on a simulated network to capture
packets flowing over a link and the trace route program can run on a simulated
network to find out the routing path traversed by a packet.
vii.Remote, concurrent and parallel simulations.
NCTUns uses a distributed architecture, by which simulation machines can be
far away from the machines where the GUI programs are run. For example, the
simulation service machines may reside at NCTU in Taiwan while the GUI
users come from many different places of the world. Multiple simulation jobs
can be concurrently simulated on different machines (one machine serves one
job) to increase the total simulation throughput. When the NCTUns simulation
jobsare run on multiple machines, we say that NCTUns is operating in the
“multiple machine‟ mode [13]. This mode supports remote and concurrent
simulations. In the “single-machine‟ mode, the simulation jobs run on the
same machine. With the inter-process communication (IPC) design, NCTUns
can be used for either mode without changing its program code. Only the mode
parameter in its configuration file needs to be changed.

DEPARTMENT OF ECE 4 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

STEPS TO START NCTUNS


Three things we are going to start. They are:
❖ Dispatcher (With ADMINprivilege)
❖ Coordinator (With ADMIN privilege)
❖ Nctunsclient (With ADMIN or user privilege)
But after drawing the topology, you should submit the simulation with user
privilege only we need three terminals.
1st terminal to execute. /dispatcher at the server 2nd terminal to execute
./coordinator at the server 3rd terminal to execute ./nctunsclient at the client

STEP 1: # cd /usr/local/nctuns/bin
STEP 2: #. /dispatcher <enter key>
Right click on the blank space of the screen and select open
tab STEP 3: #. /coordinator <enter key>
Right click on the blank space of the screen and select open
tab STEP 4: #. /nctunsclient <enter key>

DEPARTMENT OF ECE 5 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

To submit the simulation, you should be the normal user

WORKING WITH NCTUNS


There are 4 steps in doing the NCTUNS experiments. They are as below.

1. Drawing a network topology D

2. Editing node’s properties E

3. Running the simulation R

4. Post analysis P

DEPARTMENT OF ECE 6 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

1.5.1 Drawing a network topology:


1.5.2 Identification of tools on the toolbar:

Select

Draw topology
D

Edit property
E

Run Simulation
R

Play back
P

Delete
X

Label
A

Point – to – point link

Moving path

Hub (Blue color)

Switch (Green color)


X

Host (Black color)

Router (Red color)

WLAN mobile node (Infra-structure mode) Yellow color – Top row

A user can draw a new network topology or change an existing simulation topology
only in the Draw topology mode. Draw topology mode is the default mode of
NCTUNs.

DEPARTMENT OF ECE 7 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

To check whether the mode is in draw mode or not do as follow.


Choose Menu → File → Operating mode → and make sure that the “Draw Topology”
mode is checked.

1) Move the cursor to the toolbar.


2) Left click the router icon on the toolbar
3) Left click anywhere in the blank working area to add a router to the current
network topology. In the same way we can add switch, hub, WLAN access
pointed.
4) Left click the host icon on the toolbar. Add the required number of hosts to the
current topology.
5) To add links between the hosts and the router, left click the link icon on the
toolbar to select it.
6) Left click a host and hold the mouse button. Drag this link to the router and
then release the mouse left button on top of the router. Now a link between the
selected host and the router has been created.
7) Add the other, required number of links in the same way. This completes the
creation of a simple network topology.
8) Save this network topology by choosing Menu → File → Save. It is saved with
a .tpl extension.

Editing Node’s Properties:


A network node (device) may have many parameters to set. Some parameters are
▪ Bandwidth
▪ Queue size
▪ IPaddress
The GUI automatically finds subnets in a network and generates and assigns IP and
MAC addresses to layer 3 network interfaces.
If the user switches the mode back to the “Draw Topology” mode and when the user
again switches the mode back to the “Edit topology” mode, node’s IP and MAC
addresses will be regenerated and assigned to layer 3 interfaces.
Therefore, the application programs now may use wrong IP addresses to communicate
with their partners.

DEPARTMENT OF ECE 8 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

PART A Programs

Start up

1. Open three terminals


a) in terminal 1 at command prompt run dispatcher (root@localhost# dispatcher)
b) in terminal 2 at command prompt run coordinator (root@localhost# coordinator)
c) in terminal 3 at command prompt run nctunsclient (root@localhost# nctunsclient)

2. After the above steps NCTUns starting screen will appear.

3. To draw the network topology perform the following steps


Choose Menu-> File-> Operating Mode-> D(draw mode), draw the required
topology or change the existing simulation topology.(drag and drop)
4 Once topology is drawn, set the node property by switching to “Edit
property” modeE
5 Configure the node with appropriate commands at source and destination
6 Under Simulation menu-> Simulation Run
7 Play back the simulation.

DEPARTMENT OF ECE 9 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Experiment No 1

1. Implement a point to point network with four nodes and duplex links between
them. Analyze the network performance by setting the queue size and varying the
bandwidth.
Topology:

STEPS:

To draw a network topology, do the following steps:

1. Select the host icon on the toolbar and drag it onto the working window. Repeat
this for another host icon. Select the link icon on the toolbar and drag it on the screen
from host [node 1] to the hub and again
from host [node2] to the hub. Here the hub acts as node 3 in the point-to-point
network. This leads to the creation of the 3-node point-to-point network topology.
[We can see the ip address of the host by moving the mouse pointer on host]

2. Save this topology as a filename.tpl

To configure the network devices, do the following steps:


At Sender
1. Double click on host [node-1], a host dialog box will open up

DEPARTMENT OF ECE 10 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

2. Click on the Add button and enter the command (at the sender)
stg [-u udp][-t duration (sec)] [-p port number]HostIPaddr and set the
simulation time 0 to 40 sec then click ok

DEPARTMENT OF ECE 11 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

3. Click on the node editor and you can see the different layers-
interface, ARP, FIFO, MAC, TCPDUMP, Physical
layers.

4. Select MAC and then select full-duplex for switches and routers and half-
duplex for hubs, and check the log packet statistics check box,

DEPARTMENT OF ECE 12 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

5. Select output throughput log file etc (at sender), select the number of
drop packets, number of collisions.

Click the OK button.

At Receiver: Steps
1. Click on the Add button and enter the command (at the
receiver) rtg [-t] [-w log] [-p port number] and clickOK.

DEPARTMENT OF ECE 13 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

2. Click on the node editor and you can see the different layers-interface,
ARP, FIFO, MAC, TCPDUMP, Physical layers.

3. Select input throughput log file etc (at receiver), select the number of drop
packets, number of collisions. Click OK.

DEPARTMENT OF ECE 14 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

To RUN the Simulation

1. Now click on the R button (Run simulation). By doing such a user can
run/pause/continue/stop/abort/disconnect/reconnect/submit a simulation. No
simulation settings can be changed in this mode.

2. Now go to the Menu->Simulation->Run. Executing this command will submit


the current simulation job to one available simulation server managed by t
h e dispatcher. When the simulation server is executing, the user will see the
time knot at the bottom of the screen move. The time knot reflects the current
virtual time (progress) of the simulationcase.

DEPARTMENT OF ECE 15 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

To PLAYBACK the simulation

To start the playback, the user can left-click the start icon ( |>) of the time bar
located at the bottom. The animation player will then start playing the recorded
packet animation.

The results are stored in file.results folder(“file” is the same name given by the
user to the simulation file).
You will see the following log files in the folder: file.results
Filename.8023_N2_P1_OutThrput.log
Filename.8023_N3_P1_InThrput.log
Filename..8023_n2_p1_coll.log
Filename.8023_N2_P1_Drop.log

Here the drop and collision files do not have data, because of point to point connection
no drop, no collision

DEPARTMENT OF ECE 16 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Graph can be plotted during the play mode


To plot the graph on menu Tools plot graph open file
name Graph for 10 mbps bandwidth

DEPARTMENT OF ECE 17 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Change the bandwidth say, 9 Mbps or less, and run the simulation and
compare the two results. To view the results go to the filename.results
folder.

DEPARTMENT OF ECE 18 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

To change the setting of the graph and X-values and


Y-values, go to options general setting

Time N0-N2, N1-N2, N2-N3 N0 N1 N3 Queue Size


Out Throughput Out In Throughput
Throughput
10, 10, 10
50, 100, 20
200, 150, 100

DEPARTMENT OF ECE 19 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Experiment No 2

2. Implement a four-node point to point network with links


n0-n2, n1-n2 and n2-n3. Apply TCP agent between n0-n3
and UDP between n1-n3. Apply relevant applications over
TCP and UDP agents changing the parameter and
determine the number of packets sent by TCP/UDP.

Topology:-

Sender:-
stcp –p 3000 –l 1024 1.0.1.3
stg –u 1024 1.0.1.3

Receiver:-
rtcp –p 3000 –l 1024
rtg –u 3000

Parameters:-
Throughput of incoming and outgoing Packets

DEPARTMENT OF ECE 20 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Experiment No 3

3. Implement Ethernet LAN using n (6-10) nodes. Compare the


throughput by changing the error rate and data rate

Topology: -

Sender: -
stcp –p 2000 –l 1024 1.0.1.4

Receiver:-
rtcp –p 2000 –l 1024

Double click on receiver link and change BER to

0.000001, Run Again. Parameters: -


Throughput of outgoing Packets

Results

Table:

Cases In throughput Out throughput


Case 1: BER=0, BW=100

Case 2: BER=0.0001, BW=100

Case 3: BER=0.001, BW=100

DEPARTMENT OF ECE 21 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Experiment No 4

4. Implement Ethernet LAN using n nodes and assign multiple


traffic to the nodes and obtain congestion window for
different sources/ destinations

Topology:-

Sender:-
stcp –p 2000 –l 1024 1.0.1.4

Receiver:-
rtcp –p 2000 –l 1024

Parameters:-
Collision Packets and Drop Packets (Optional)
1. Place and click on nodes 4,5,6 acting as senders and
add the command

“stcp –p 3000 –l 1024 1.0.1.4 and similarly consider for nodes 7,8,9 as receiver
and
add command “rtcp –p 3000 –l 1024”

4. Consider UDP too and add sender command “stg –u 3000 1024
1.0.1.5”
and receiver command “rtg –u 3000 1024”

5. Click on node editor, select the MAC layer and check for the log
packet logistics with parameters out throughput, drop and collision
packets.

6. Similarly, at receiver side repeat step 5 with in throughput.


7. Run, simulate and observe the data transmission
8. Plot the graph and observe the variations

Results:

DEPARTMENT OF ECE 22 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Experiment No 5

5. Implement ESS with transmission nodes in Wireless


LAN and obtain the performance parameters.

Topology:-

Steps for drawing the topology

1. Select host icon, router and place on the window


2. Select wireless access point 802.11(b) icon and name it
AP1 and repeat for AP2.
3. Select the mobile node [infrastructure mode] and name it
MN1. Repeat for MN2, 3 & 4.
4. Click the LINK icon and connect router to AP1 and AP2
& host.
5. Click the “CREATE A MOVING PATH” from the
toolbar and draw the path across MN1 and MN2. Repeat
for MN3 and MN4.

Steps to create subnet


1. Select the wireless subnet icon in the toolbar, select MN1, MN2
and AP1, right click mouse bottom and create a subnet. Repeat
for MN3 and MN4 and AP2 as well.
2. Click on [E] and save the file

DEPARTMENT OF ECE 23 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Configurations
1. Double click on host (node & add the command “ttcp -r -u -s -
p 8001”)
2. Repeat similarly by adding the same command with 8002, 8003,
8004.
3. Click on node editor of host→ MAC → In throughput. OK and
Exit the window.
4. Double click on MN1 to open the mobile node window →
application tab → Add→“ttcp -r -u -s -p 8001 1.0.2.2”
5. Add Out throughput in MAC.
Repeat 4 & 5 for MN2, MN3 & MN4 with respective IP addresses.
6. Double click on router → node editor→ stacks
7. Simulate & Run. When played we observe the mobile nodes
moves across the data transmission path.
8. Run and then play to plot the graph.

Click on “access point”. Got wireless interface and tick on “show


transmission range and then click OK.

Double click on Router -> Node Editor and then Left stack ->
throughput of Incoming packets Right stack -> throughput of
Outgoing packets

Select mobile hosts and access points then click on.


Tools -> WLAN mobile nodes-> WLAN Generate infrastructure.
SubnetID: Port number of router (2) Gateway ID: IP address of router

Mobile Host 1
ttcp –t –u –s –p 3000 1.0.1.1

Mobile Host 1
ttcp –t –u –s –p 3001 1.0.1.1

Host (Receiver)
ttcp –r –u –s –p 3000
ttcp –r –u –s –p 3001

Results:

DEPARTMENT OF ECE 24 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

PART B

Experiment 1 . Write a program for a HDLC frame to perform the following


a. Bit Stuffing
b. Character Stuffing

Theory
i) Bit Stuffing:

Use reserved bit patterns to indicate the start and end of a frame. For instance, use the 4-bit sequence
of 0111 to delimit consecutive frames. A frame consists of everything between two delimiters.
Problem: What happens if the reserved delimiter happens to appear in the frame itself? If we don't
remove it from the data, the receiver will think that the incoming frame is actually two smaller frames!

Solution: Use bit stuffing. Within the frame, replace every occurrence of two consecutive 1's with
110. E.g., append a zero bit after each pair of 1's in the data. This prevents 3 consecutive 1's from
ever appearing in the frame.

Likewise, the receiver converts two consecutive 1's followed by a 0 into two 1's, but recognizes the
0111 sequence as the end of the frame.

Example: The frame ``1011101'' would be transmitted over the physical layer as
``0111101101010111''.

Note: When using bit stuffing, locating the start/end of a frame is easy, even when frames are
damaged. The receiver simply scans arriving data for the reserved patterns. Moreover, the receiver
will resynchronize quickly with the sender as to where frames begin and end, even when bits in the
frame get garbled.

The main disadvantage with bit stuffing is the insertion of additional bits into the data stream, wasting
bandwidth. How much expansion? The precise amount depends on the frequency in which the
reserved patterns appear as user data.

ii) Character stuffing:

Same idea as bit-stuffing, but operates on bytes instead of bits.

Use reserved characters to indicate the start and end of a frame. For instance, use the two-character
sequence DLE STX (Data-Link Escape, Start of TeXt) to signal the beginning of a frame, and the
sequence DLE ETX (End of TeXt) to flag the frame's end.

Problem: What happens if the two-character sequence DLE ETX happens to appear in the frame
itself?

Solution: Use character stuffing; within the frame, replace every occurrence of DLE with the two-
character sequence DLE DLE. The receiver reverses the processes, replacing every occurrence of
DLE DLE with a single DLE.

Example: If the frame contained ``A B DLE D E DLE'', the characters transmitted over the channel
would be ``DLE STX A B DLE DLE D E DLE DLE DLE ETX''.

DEPARTMENT OF ECE 25 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Disadvantage: character is the smallest unit that can be operated on; not all architectures are byte
oriented.

a. BIT STUFFING

#include<stdio.h>
int main()
{

int a[20],b[30],i,j,k,count,n;
printf("Enter the length of the frame : \n");
scanf("%d",&n);
printf(" Enter the bit of the frame : \n");
for(i=0;i<n;i++)
{
printf("\n element[%d]:",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
{
b[j]=a[i];

DEPARTMENT OF ECE 26 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

count=1;
i++;j++;

printf("\n after bit stuffing the output is:");


for(i=0;i<j;i++)
{
printf("%d",b[i]);
}

}
Bit Stuffing output:

[root@localhost partb]# gcc bit.c


[root@localhost partb]# ./a.out
Enter the length of the frame :
8
Enter the bit of the frame :

element[0]:0

element[1]:1

element[2]:1

element[3]:1

element[4]:1

element[5]:1

element[6]:1

element[7]:1

after bit stuffing the output is:011111101[root@localhost partb]#

DEPARTMENT OF ECE 27 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

b. CHARACTER STUFFING

#include<stdio.h>
#include<string.h>
int main()
{
char a[20],s[40];
char *fb = "dlestx";
char *fe= "dleetx";
int i, j, n;

printf("Enter the string: ");


scanf("%s", a);
n=strlen(a);
strcpy(s,fb);
j=strlen(fb);
i=0;

while(i<n)
{
if(a[i] =='d' && a[i+1] == 'l' && a[i+2] == 'e')
{
s[j] ='\0';
strcat(s,"dle");
strcat(s,"dle");
j=j+6;
i=i+3;
}
else
{
s[j] = a[i];
i++;
j++;
}
}

s[j] = '\0';
strcat(s,fe);

printf("\n The stuffed string is: ");


printf("%s",s);
return 0;
}

Character stuffing output

DEPARTMENT OF ECE 28 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

[root@localhost partb]#
[root@localhost partb]# gcc char.c
[root@localhost partb]# ./a.out
Enter the string: abcdelfgh

The stuffed string is: dlestxabcdelfghdleetx[root@localhost partb]#

DEPARTMENT OF ECE 29 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Experiment. 2: WAP for Distance vector algorithm to find suitable path for transmission

Theory
Routing algorithm is a part of network layer software which is responsible for deciding
which output line an incoming packet should be transmitted on. If the subnet uses
datagram internally, this decision must be made anew for every arriving data packet since
the best route may have changed since last time. If the subnet uses virtual circuits
internally, routing decisions are made only when a new established route is being set up.
The latter case is sometimes called session routing, because a rout remains in force for
an entire user session (e.g., login session at a terminal or afile).
Routing algorithms can be grouped into two major classes: adaptive and nonadaptive.
Nonadaptive algorithms do not base their routing decisions on measurement or estimates
of current traffic and topology. Instead, the choice of route to use to get from I to J (for all
I and J) is compute in advance, offline, and downloaded to the routers when the network
ids booted. This procedure is sometime called staticrouting.
Adaptive algorithms, in contrast, change their routing decisions to reflect changes in the
topology, and usually the traffic as well. Adaptive algorithms differ in where they get
information (e.g., locally, from adjacent routers, or from all routers), when they change the
routes (e.g., every T sec, when the load changes, or when the topology changes), and what
metric is used for optimization (e.g., distance, number of hops, or estimated transit time).
Two algorithms in particular, distance vector routing and link state routing are the most
popular. Distance vector routing algorithms operate by having each router maintain a table
(i.e., vector) giving the best known distance to each destination and which line to get
there. These tables are updated by exchanging information with the neighbors.
The distance vector routing algorithm is sometimes called by other names, including the
distributed B e l l m a n -Ford r o u t i n g algorithm and the Ford- Fulkerson algorithm,
after the researchers who developed it (Bellman, 1957; and Ford and Fulkerson, 1962). It
was the original ARPANET routing algorithm and was also used in the Internet under
the RIP and in early versions of DECnet and Novell’s IPX. AppleTalk and Cisco routers
use improved distance vector protocols.
In distance vector routing, each router maintains a routing table indexed by, and containing
one entry for, each router in subnet. This entry contains two parts: the preferred out going
line to use for that destination, and an estimate of the time or distance to that destination.
The metric used might be number of hops, time delay in milliseconds, total number of
packets queued along the path, or something similar.
The router is assumed to know the “distance” to each of its neighbor. If the metric is hops,
the distance is just one hop. If the metric is queue length, the router simply examines each
queue. If the metric is delay, the router can measure it directly with special ECHO packets
hat the receiver just time stamps and sends back as fast as possible.

The Count to Infinity Problem.


Distance vector routing algorithm reacts rapidly to good news, but leisurely to bad news.
Consider a router whose best route to destination X is large. If on the next exchange
neighbor A suddenly reports a short delay to X, the router just switches over to using

DEPARTMENT OF ECE 30 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

the line to A to send traffic to X. In one vector exchange, the good news is processed.

To see how fast good news propagates, consider the five node (linear) subnet of
following figure, where the delay metric is the number of hops. Suppose A is down
initially and all the other routers know this. In other words, they have all recorded the
delay to A as infinity.

A B C D E A B C D E

∞ ∞ ∞∞Initially 1 2 3 4
Initially

1 ∞ ∞ ∞ After1exchange 3 2 3 4
After1exchange

1 2 ∞ ∞After 2exchange 3 3 3 4
After2exchange

1 2 3 ∞After 3exchange 5 3 5 4
After3exchange

1 2 3 4 After4exchange 5 6 5 6 After
4 exchange

7 6 7 6 After
5 exchange

7 8 7 8 After
6 exchange

:
:
:

∞∞ ∞∞

DISTANCE VECTOR ALGORITHM


#include<stdio.h>
struct node
{
unsigned dist [20];
unsigned from [20];
}
rt[10];
int main()
{
int dmat[20][20];
int n,i,j,k;
printf("\n enter the number of nodes:");
scanf("%d",&n);

DEPARTMENT OF ECE 31 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

printf("\n enter the cost matrix:\n");


for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
scanf("%d",&dmat[i][j]);
rt[i].dist[j]=dmat[i][j];
rt[i].from[j]=j;
}
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]=dmat[i][k]+rt[k].dist[j];
rt[i].from[j]=k;
}
for(i=0;i<n;i++)
{
printf("\n\n state value for router %d is \n", i+1);
for(j=0;j<n;j++)
{
printf("\n \n node %d via %d Distance %d", j+1, rt[i].from[j]+1, rt[i].dist[j]);
}
}
printf("\n\n");
}

Distance Vector Algorithm output


[root@localhost syed]# gcc Distance.c
[root@localhost syed]# ./a.out

enter the number of nodes:3

enter the cost matrix:


012
105
250

state value for router 1 is

node 1 via 1 Distance 0

node 2 via 2 Distance 1

node 3 via 3 Distance 2

DEPARTMENT OF ECE 32 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

state value for router 2 is

node 1 via 1 Distance 1

node 2 via 2 Distance 0

node 3 via 1 Distance 3

state value for router 3 is

node 1 via 1 Distance 2

node 2 via 1 Distance 3

node 3 via 3 Distance 0

DEPARTMENT OF ECE 33 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Experiment 3: Implement Djiktras Algorithm to compute the shortest routing path.

Theory
Let the node at which we are starting be called the initial node. Let the distance of node
Y be the distance from the initial node to Y. Dijkstra’s algorithm will assign some initial
distance values and will try to improve them step by step.

1. Assign to every node a tentative distance value: set it to zero for our initial node and to
infinity for all other nodes.
2. Mark all nodes unvisited. Set the initial node as current. Create a set of the unvisited
nodes called the unvisited set consisting of all the nodes except the initial node.
3. For the current node, consider all of its unvisited neighbors and calculate
their tentative distances. For example, if the current node A is marked with a distance
of 6, and the edge connecting it with a neighbor B has length 2, then the distance to B
(through A) will be 6+2=8. If this distance is less than the previously recorded tentative
distance of B, then overwrite that distance. Even though a neighbor has been examined,
it is not marked as “visited” at this time, and it remains in the unvisited set.
4. When we are done considering all of the neighbors of the current node, mark the current
node as visited and remove it from the unvisited set. A visited node will never be
checked again.
5. If the destination node has been marked visited (when planning a route between two
specific nodes) or if the smallest tentative distance among the nodes in the unvisited
set is infinity (when planning a complete traversal), then stop. The algorithm has
finished.
6. Select the unvisited node that is marked with the smallest tentative distance, and set it
as the new “current node” then go back to step 3.

DEPARTMENT OF ECE 34 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

DJIKTRA’S ALGORITHM

#include<stdio.h>

int main()
{
int path[5][5],i,j,min,a[5][5],p,st=1,ed=5,stp,edp,t[5],index;
printf("\n enter the cost matrix\n");
for(i=1;i<=5;i++)
for(j=1;j<=5;j++)
scanf("%d",&a[i][j]);
printf("enter no of paths\n");
scanf("%d",&p);
printf("\n enter possible paths\n");
for(i=1;i<=p;i++)
for(j=1;j<=5;j++)
scanf("%d",&path[i][j]);
for(i=1;i<=p;i++)
{
t[i]=0;
stp=st;
for(j=1;j<=5;j++)
{
edp=path[i][j];
t[i]=t[i]+a[stp][edp];
if(edp==ed)
break;
else
stp=edp;
}
}
min=t[st];
index=st;
for(i=1;i<=p;i++)
{
if(min>t[i])
{
min=t[i];
index=i;
}
}
printf("min cost %d",min);
printf("\n shrtest path");
for(i=1;i<=5;i++)
{
printf("-->%d",path[index][i]);
if(path[index][i]==ed)

DEPARTMENT OF ECE 35 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

break;
}
return 0;
}

Dijktras Algoritm output

[root@localhost partb]# gcc dj_new.c


[root@localhost partb]# ./a.out

enter the cost matrix


0223 0
00305
00002
00000
00000
enter no of paths
3

enter possible paths


12350
13500
12500
min cost 4
shrtest path-->1-->3-->5[root@localhost partb]#

DEPARTMENT OF ECE 36 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Experiment 4. For a given data use CRC-CCITT polynomial to obtain CRC code .
Verify the program for the cases
a. without error b. with error

#include<stdio.h>
#include<string.h>
#define N strlen(g)
char t[28],cs[28],g[ ]= "10001000000100001";

int a,e,c;
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()
{
printf("\n enter data:");
scanf("%s",t);
printf("\n generator polynomial: %s", g);
a=strlen(t);
//#define a strlen(t)
for(e=a;e<a+N-1;e++)
t[e]='0';
printf("\n modified data is : %s",t);
crc();
printf("\n checksum is :%s", cs);
for(e=a;e<a;e++)
t[e]=cs[e-a];
printf("\n frame transmnitted msg(mode word)is :%s",t);
printf("\n test error detectio0nh 0(yes), 1(no) ?:");
scanf("%d",&e);

DEPARTMENT OF ECE 37 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

if(e==0)
{
do
{
printf("enter the position where error is to be inserted :");
scanf("%d",&e);
}
while(e==0||e>a+N-1);
t[e-1]=(t[e-1]=='o')? '1' : '0';
printf("\n erroreous data recieved : %s\n",t);
crc();
for(e=0;(e<N-1) && (cs[e]!='1');e++);
if(e<N-1)
printf("\n error detected");
}
else
printf("\n no error dected");
return 0;
}

enter data:1101

generator polynomial: 10001000000100001


modified data is : 11010000000000000000
checksum is :1101000110101101
frame transmnitted msg(mode word)is :11010000000000000000
test error detection 0(yes), 1(no) ?:0
enter the position where error is to be inserted :2

erroreous data recieved : 10010000000000000000

DEPARTMENT OF ECE 38 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Experiment 5: Implement Stop and Wait and Sliding Window Protocol

Theory:
Stop-and-wait ARQ, also referred to as alternating bit protocol, is a method
in telecommunications to send information between two connected devices. It ensures that
information is not lost due to dropped packets and that packets are received in the correct order.
It is the simplest automatic repeat-request (ARQ) mechanism. A stop-and-wait ARQ sender
sends one frame at a time; it is a special case of the general sliding window protocol with
transmit and receive window sizes equal to one and greater than one respectively. After sending
each frame, the sender doesn't send any further frames until it receives
an acknowledgement (ACK) signal. After receiving a valid frame, the receiver sends an ACK.
If the ACK does not reach the sender before a certain time, known as the timeout, the sender
sends the same frame again. The timeout countdown is reset after each frame transmission. The
above behavior is a basic example of Stop-and-Wait. However, real-life implementations vary
to address certain issues of design.
Typically the transmitter adds a redundancy check number to the end of each frame. The receiver
uses the redundancy check number to check for possible damage. If the receiver sees that the
frame is good, it sends an ACK. If the receiver sees that the frame is damaged, the receiver
discards it and does not send an ACK—pretending that the frame was completely lost, not merely
damaged.
One problem is when the ACK sent by the receiver is damaged or lost. In this case, the sender
doesn't receive the ACK, times out, and sends the frame again. Now the receiver has two copies
of the same frame and doesn't know if the second one is a duplicate frame or the next frame of
the sequence carrying identical data.
Another problem is when the transmission medium has such a long latency that the sender's
timeout runs out before the frame reaches the receiver. In this case the sender resends the same
packet. Eventually the receiver gets two copies of the same frame, and sends an ACK for each
one. The sender, waiting for a single ACK, receives two ACKs, which may cause problems if it
assumes that the second ACK is for the next frame in the sequence.
To avoid these problems, the most common solution is to define a 1 bit sequence number in the
header of the frame. This sequence number alternates (from 0 to 1) in subsequent frames. When
the receiver sends an ACK, it includes the sequence number of the next packet it expects. This
way, the receiver can detect duplicated frames by checking if the frame sequence numbers
alternate. If two subsequent frames have the same sequence number, they are duplicates, and the
second frame is discarded. Similarly, if two subsequent ACKs reference the same sequence
number, they are acknowledging the same frame.
Stop-and-wait ARQ is inefficient compared to other ARQs, because the time between packets,
if the ACK and the data are received successfully, is twice the transit time (assuming the
turnaround time can be zero). The throughput on the channel is a fraction of what it could be. To
solve this problem, one can send more than one packet at a time with a larger sequence number
and use one ACK for a set. This is what is done in Go-Back-N ARQ and the Selective Repeat
ARQ.

DEPARTMENT OF ECE 39 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

ALGORITHM:

Step 1: Start the program.


Step 2: Generate a random that gives the total number of frames to be transmitted.
Step 3: Transmit the first frame.
Step 4: Receive the acknowledgement for the first frame. Step 5: Transmit the next frame
Step 6: Find the remaining frames to be sent.
Step 7: If an acknowledgement is not received for a particular frame retransmit that frame alone
again.
Step 8: Repeat the steps 5 to 7 till the number of remaining frames to be send becomes zero.
Step 9: Stop the program.

STOP AND WAIT PROTOCOL


#include<stdio.h>

int main()
{
int i,j,noframes,x,x1=10,x2;

for(i=0;i<200;i++)

noframes=19200/200;
i=1;
j=1;
noframes = noframes / 8;
printf("\n number of frames is %d",noframes);

while(noframes>0)
{
printf("\nsending frame%d",i);
srand(x1++);
x =rand()%10;
if(x%2 ==0)
{
for (x2=1; x2<2; x2++)
{
printf("waiting for %d seconds\n", x2);
sleep(x2);

}
printf("\nsending frame %d",i);
srand(x1++);
x = rand()%10;

DEPARTMENT OF ECE 40 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

}
printf("\nack for frame %d",j);
noframes-=1;
i++; j++;
}
printf("\n end of stop and wait protocol");

Stop and wait Protocol Output


[root@localhost partb]# gcc stw.c
[root@localhost partb]# ./a.out

number of frames is 12
sending frame1
ack for frame 1
sending frame2
ack for frame 2
sending frame3waiting for 1 seconds

sending frame 3
ack for frame 3
sending frame4
ack for frame 4
sending frame5
ack for frame 5
sending frame6waiting for 1 seconds

sending frame 6
ack for frame 6
sending frame7waiting for 1 seconds

sending frame 7
ack for frame 7
sending frame8
ack for frame 8
sending frame9waiting for 1 seconds

sending frame 9
ack for frame 9
sending frame10waiting for 1 seconds

sending frame 10
ack for frame 10
sending frame11
ack for frame 11

DEPARTMENT OF ECE 41 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

sending frame12
ack for frame 12
end of stop and wait protocol[root@localhost partb]#

SLIDING WINDOW PROTOCOL


#include<stdio.h>

int main()
{
int temp1,temp2,temp3,temp4,temp5,i,winsize=8,noframes,moreframes; char c;
int reciever(int);
int simulate(int);
int nack(int);
temp4=0,temp1=0,temp2=0,temp3=0,temp5 = 0;
for(i=0;i<200;i++)

noframes=1200/200;
printf("\n number of frames is %d",noframes);
moreframes=noframes;
while(moreframes>=0)
{
temp1=simulate(winsize);
winsize-=temp1;
temp4+=temp1;
if(temp4 >noframes)
temp4 = noframes;
for(i=noframes - moreframes;i<=temp4;i++)
printf("\nsending frame %d",i);

temp2=reciever(temp1);
temp3+=temp2;
if(temp3 > noframes) temp3 = noframes;
temp2 = nack(temp1);
temp5+=temp2;
if (temp5 !=0)
{
printf("\n No acknowledgement for the frame %d",temp5);

for(i=1;i<temp5;i++)
;
printf("\n Retransmitting frame %d",temp5);

}
moreframes-=temp1; if(winsize<=0) winsize=8;

DEPARTMENT OF ECE 42 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

}
printf("\n end of sliding window protocol Selective Reject");

int reciever(int temp1)


{
int i;
for(i=1;i<100;i++)
rand();
i=rand()%temp1;
return i;
}

int nack(int temp1)


{
int i; for(i=1;i<100;i++)
rand();
i=rand()%temp1;
return i;
}
int simulate(int winsize)
{
int temp1,i;
for(i=1;i<50;i++)
temp1=rand();
if(temp1==0)
temp1=simulate(winsize);
i = temp1%winsize;
if(i==0)
return winsize;
else
return temp1%winsize;
}

Sliding Window protocol Output


[root@localhost partb]# gcc sld.c
[root@localhost partb]# ./a.out

number of frames is 6
sending frame 0
sending frame 1
sending frame 2
sending frame 3
No acknowledgement for the frame 2
Retransmitting frame 2

DEPARTMENT OF ECE 43 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

sending frame 3
sending frame 4
No acknowledgement for the frame 2
Retransmitting frame 2
sending frame 4
sending frame 5
sending frame 6
No acknowledgement for the frame 5
Retransmitting frame 5
end of sliding window protocol Selective Reject[root@localhost partb]#

DEPARTMENT OF ECE 44 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Experiment.6: WAP for congestion control using Leaky Bucket Algorithm.

Problem Statement
Write a program for congestion control using Leaky bucket algorithm.

Theory
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 subcategories: 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 tocome 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.

DEPARTMENT OF ECE 45 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Algorithm:

1. Start
2. Set the bucket size or the buffer size.
3. Set the output rate.
4. Transmit the packets such that there is no overflow.
5. Repeat the process of transmission until all packets are transmitted. (Reject packets where
its size is greater than the bucket size)
6. Stop

LEAKY BUCKET
#include<stdio.h>
#include<string.h>

int min(int x,int y)


{
if(x<y)
return x;
else
return y;
}

int main()
{
int drop=0,mini,nsec,cap,count=0,i,inp[25],out;
printf("\nenter the bucket size:");
scanf("%d",&cap);
printf("\nenter the output rate:");
scanf("%d",&out);
printf("\nenter the number of sec you want to simulate:");
scanf("%d",&nsec);

for(i=0;i<nsec;i++)
{
printf("\nenter the size of the packets entering at %d sec\n",i+1);
scanf("%d",&inp[i]);
}

DEPARTMENT OF ECE 46 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

printf("\nsecond\tpackets recived\tpackets sent\tpacket left\tpacket dropped\n");


printf("--------------------------------------------------------------------------\n");

for(i=0;i<nsec;i++)
{
count=count+inp[i];
if(count>cap)
{
drop=count-cap;
count=cap;
}
printf("%d",i+1);
printf("\t%d",inp[i]);
mini=min(count,out);
printf("\t\t%d",mini);
count=count-mini;
printf("\t\t%d",count);
printf("\t\t%d\n",drop);
}
return 0;
}

Leaky Bucket Output

[root@localhost syed]# gcc lbk.c


[root@localhost syed]# ./a.out

enter the bucket size:8

enter the output rate:3

enter the number of sec you want to simulate:3

enter the size of the packets entering at 1 sec


5

enter the size of the packets entering at 2 sec


6

enter the size of the packets entering at 3 sec


4

Seconds Packets received Packets Sent Packets left Packet Dropped


-------------------------------------------------------------------------------------------------
1 5 3 2 0
2 6 3 5 0
3 4 3 5 1

DEPARTMENT OF ECE 47 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

BEYOND SYLLABUS LEARNING

Aim: Study of basic network command and Network configuration commands.

Apparatus (Software): Command Prompt And Packet Tracer.

Procedure: To do this EXPERIMENT- follows these steps:


In this EXPERIMENT- students must understand basic networking commands e.g ping, tracert
etc.

All commands related to Network configuration which includes how to switch to privilege mode
and normal mode and how to configure router interface and how to save this configuration to
flash memory or permanent memory.

This command includes

• Configuring the Router commands


• General Commands to configure network
• Privileged Mode commands of a router
• Router Processes & Statistics
• IP Commands
• Other IP Commands e.g. show ip route etc.

Ping (8) sends an ICMP ECHO_REQUEST packet to the specified host. If the host responds, you get an
ICMP packet back. Sound strange? Well, you can “ping” an IP address to see if a machine is alive. If
there is no response, you know something is wrong.

DEPARTMENT OF ECE 48 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

Traceroute:

Tracert is a command which can show you the path a packet of information takes from your computer
to one you specify. It will list all the routers it passes through until it reaches its destination or fails to
and is discarded. In addition to this, it will tell you how long each 'hop' from router to router takes.

DEPARTMENT OF ECE 49 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

nslookup:

Displays information from Domain Name System (DNS) name servers.


NOTE: If you write the command as above it shows as default your pc's server name firstly.

pathping:

A better version of tracert that gives you statics about packet lost and latency.

Getting Help

In any command mode, you can get a list of available commands by entering a question mark (?).

Router>?
To obtain a list of commands that begin with a particular character sequence, type in those
haracters followed immediately by the question mark (?).

Router#co?
configure connect copy
To list keywords or arguments, enter a question mark in place of a keyword or argument. Include
a space before the question mark.

Router#configure ?

memory Configure from NV memory network Configure from a TFTP network host terminal
Configure from the terminal
You can also abbreviate commands and keywords by entering just enough characters to make the
command unique from other commands. For example, you can abbreviate the show command to
sh.

Configuration Files

Any time you make changes to the router configuration, you must save the changes to memory
because if you do not they will be lost if there is a system reload or power outage. There are two
types of configuration files: the running (current operating) configuration and the startup
configuration.
DEPARTMENT OF ECE 50 HKBKCE
Computer Networks Lab Manual 17ECL68 2019-20
Use the following privileged mode commands to work with configuration files.
Viva Questions
1.What do you mean by data communication?
2.What is simplex?
3.What is half-duplex?
4.What is full duplex?
5.What is a network?
6.What is distributed processing?
7.What is point to point connection?
8.What is multipoint connection?
9.What is a topology?
10.Define LAN, MAN and WAN.
11.Define internet?
12.What is a protocol?
13.What is TCP/IP protocol model?
14.Describe the functions of five layers?
15.What is ISO-OSI model?
16. What is multiplexing?
17.What is switching?
18.How data is transmitted over a medium?
19. Compare analog and digital signals?
20.Define bandwidth?
21.What are the factors on which data rate depends?
22.Define bit rate and bit interval?
23.What is Nyquist bit rate formula?
24.Define Shannon Capacity?
25.What is sampling?
26.Define pulse amplitude modulation?
27.Define pulse code modulation?
28.What is Nyquist Theorem?
29.What are the modes of data transmission?
30.What is Asynchronous mode of data transmission?
31.What is Synchronous mode of data transmission?
32.What are the different types of multiplexing?
33.What is FDM?
34.What is TDM?
35.What are the different transmission media?
36.What are the different Guided Media?
37.Describe about the different Guided Medias.
38.What do you mean by wireless communication?
39.What are the switching methods?
40.What are the duties of data link layer?
41.What are the types of errors?
42.What do you mean by redundancy?
43.Define parity check.
44. Define cyclic redundancy check (CRC).
45. What is hamming code?
46.What do you mean by flow control?
47.What do you mean by error control?
48.Define stop and wait ARQ.
49.Define Go-Back-N ARQ?
50.Define Selective Repeat ARQ?
50.What do you mean by pipelining, is there any pipelining in error control?
51.What is HDLC?
52.What do you mean by point to point protocol?
53. What do you mean by point to point protocol stack?
DEPARTMENT OF ECE 51 HKBKCE
Computer Networks Lab Manual 17ECL68 2019-20
54.What do you mean by line control protocol?

55.What do you mean by Authentication protocol?


56.What do you mean by network control protocol?
57. What do you mean by CSMA?
58.What do you mean by Bluetooth?
59.What is IP address?
60.What do you mean by subnetting?
61.What are the advantages of fiber optics cable?
62.What are the disadvantages of fiber optics cable?
63.What are the propagation type of radio wave?
64.What do you mean by Geosynchronous Satellites?
65.What are the factors for evaluating the suitability of the media?
66.What do you mean by medium access control (MAC) sublayer.
67.What do you mean by ALOHA?
68.What is pure ALOHA?
69.What is slotted ALOHA?
70.What do you mean by persistent CSMA (carrier sense multiple access) ?
71.What do you mean by non-persistent CSMA (carrier sense multiple access) ?
72.What do you mean by p persistent CSMA (carrier sense multiple access) ?
73.What is FDDI?
74.What is Firewalls?
75.What is Repeaters?
76.What is Bridges?
77.What is Routers?
78.What is Gateway?
79.What do you mean by Data Terminal Equipment (DTE)?
80.What do you mean by Data Terminating Equipment (DCE)?
81.What do you mean by protocol stack?
82.What do you mean by peer?
83.What do you mean by broadcasting?
84.What are the advantages of broadcast network?
85.What do you mean by point to point network?
86.What are the design issue of layers?
87.What are the protocols in application layer?
88.What are the protocols in transport layer?
89.Define TCP?
90.Define UDP?
91.Define IP?
92.What do you mean by client server model?
93.What are the information that a computer attached to a TCP/IP internet must
possesses?
94.What is domain name system (DNS)?
95.What is TELNET?
96.What do you mean by local login and remote login?
97.What is Network Virtual Terminal?
98.What do you mean by Simple Mail Transfer Protocol?
99.What is Hypertext Transfer Protocol (HTTP)?
100.What is URL?
101. What is World Wide Web?
102.What is HTML?

DEPARTMENT OF ECE 52 HKBKCE


Computer Networks Lab Manual 17ECL68 2019-20

REFERENCES
1. Data Communications and Networking , Forouzan, 5th Edition, McGraw Hill, 2016
ISBN: 1-25-906475-3
2. Communication Networks: Fundamental Concepts and Key Architectures -
Alberto Leon, Garcia and Indra Widjaja, 3rd Edition, Tata McGraw- Hill, 2004.
3. Data and Computer Communication, William Stallings, 8th t Edition, Pearson
Education, 2007.
4. Computer Networks: A Systems Approach - Larry L. Peterson and Bruce S. David,
4th Edition, Elsevier, 2007.
5. Introduction to Data Communications and Networking – Wayne Tomasi, Pearson
Education, 2005.
6. Communication Networks – Fundamental Concepts and Key architectures –
Alberto Leon- Garcia and Indra Widjaja:, 2rd Edition, Tata McGraw-Hill, 2004
7. Computer and Communication Networks – Nader F. Mir:, Pearson Education, 2007.

DEPARTMENT OF ECE 53 HKBKCE

You might also like