Nothing Special   »   [go: up one dir, main page]

Laboratory Manual: Computer Network Laboratory Sub Code: 15ecl68

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

LABORATORY MANUAL

Dept of Electronics and Communication Engg.,

COMPUTER NETWORK LABORATORY


T
I

SUB CODE: 15ECL68


E
I
N

NIE INSTITUTE OF TECHNOLOGY

1
(Approved by AICTE, New Delhi and Affiliated to VTU, Belagavi) No

50, Koorgalli Village, Hootagalli Industrial Area, Next to BEML, Mysuru, Karnataka 570018 Phone: 0821
240 3734FAX: 91-821-2485802

TABLE OF CONTENTS

S. No Title of Contents Page

From To
1Syllabus 33

2Course Objective and Course Outcome 44

3Do’s And Don’ts 55


T

4Theory 71
2
I
E
I

5Programs and Sample output 1


35
6
N

6Viva Questions 5
77
2

6Sample Questions 7
37
4

2
COMPUTER NETWORKS LABORATORY
B.E., VI Semester, Electronics & Communication Engineering.
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
T
I

parameters.
E
I

PART-B: Implement the following in C/C++


N

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.

3
Course Objectives

Sl.NO Statement

Choose suitable tools to model a network and understand the protocols at various OSI
1
reference levels.

2 Design a suitable network and simulate using a Network simulator tool.

3 Simulate the networking concepts and protocols using C/C++ programming

4 Model the networks for different configurations and analyze the results.

Course Outcomes

Year/Sem: 7th sem


T
I

Subject: Computer Communication Network lab


E
I
N

Course Code: 15ECL68( C328)

Course Instructor: PawanBharadwaj,RaghavendraM,Girish M R

CO- Statement

Implement data link layer algorithms such as Bit stuffing, CRC, stop and wait
C328.1
protocols in C Language

Implement Network Layer algorithms such as distance vector routing, Dijkstras


C328.2
algorithm and congestion control using leaky bucket algorithms in C Language.

Simulate point to point four node duplex links with TCP /UDP agent using
C328.3
NCTUNS

Simulate ESS and Ethernet LAN with N nodes and assign multiple traffic to
C328.4
compare throughput using NCTUNS.

4
N
E
I
T
I

5
DO’S AND DON’TS
Do’s
· Do wear ID card and follow dress code

·
Do log off the computers when you finish.
·
Do ask for assistance if you need help.
·
Do keep your voice low when speaking to others in the LAB.
·
Do ask for assistance in downloading any software.
·
Do make suggestions as to how we can improve the LAB.
·
In case of any hardware related problem, ask LAB in charge for solution.
·
If you are the last one leaving the LAB, make sure that the staff in charge of the LAB
is informed to close the LAB.
·
Be on time to LAB sessions.
·
Do keep the LAB as clean as possible.
T
I

Don’ts
E

·
Do not use mobile phone inside the lab.
I

·
Don’t do anything that can make the LAB dirty (like eating, throwing waste papers
N

etc.)
·
Do not carry any external devices without permission.
·
Don’t move the chairs of the LAB.
·
Don’t interchange any part of one computer with another.
·
Don’t leave the computers of the LAB turned on while leaving the LAB.
·
Do not install or download any software or modify or delete any system files on any
lab computers.
·
Do not damage, remove, or disconnect any labels, parts, cables, or equipment.
·
Don’t attempt to bypass the computer security system.
·
Do not read or modify other user’s file.
·
If you leave the lab, do not leave your personal belongings unattended. We are not
responsible for any theft.

6
PART-A:
Simulation experiments using NCTUNS.

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.
T
I
E
I
N

7
Components and Architecture of NCTUns
NCTUns adopts a distributed architecture. It is a system comprising eight components.
1.The first component is the GUI program by which a user edits a network topology,
configures the protocol modules used inside a network node, specifies mobile nodes,
initial location and moving paths, plots performance graphs, plays back the animation of
a packet transfer trace, etc.

2.The second component is the simulation engine program, which provides basic and
useful simulation services (e.g., event scheduling, timer management, and packet
manipulation,etc.) to protocol modules. We call a machine on which a simulation engine
program resides a “simulation server.”

3.The third component is the set of various protocol modules, each of which implements
a specific protocol or function (e.g., packet scheduling or buffer management).All
protocol modules are C++ classes and are compiled and linked with the simulation
engine program. T
I

4. The fourth component is the simulation job dispatcher program that can
E

simultaneously manage and use multiple simulation servers to increase the aggregate
I
N

simulation throughput. It can be run on a separate machine or on a simulation server.

5. The fifth component is the coordinator program. On every simulation server, the
“coordinator” program must be run up. The coordinator should be alive as long as the
simulation server is alive. When a simulation server is powered onand brought up, the
coordinator must be run up. It will register itself with the dispatcher to join in the
dispatcher’s simulation server farm. Later on, when the status (idle or busy) of the
simulation server changes, it will notify the dispatcher of the new status. This enables
the dispatcher to choose an available simulation server from its simulation server farm
to service a job.
When the coordinator receives a job from the dispatcher, it forks a simulation engine
process to simulate the specified network and protocols. It may also fork several real-life
application program processes specified in the job. These processes are used to generate
traffic in the simulated network. When the simulation engine process is alive, the
coordinator communicates with the dispatcher and the GUI program on behalf of the
simulation engine process. For example, the simulation engine process needs to
periodically send its current simulation clock to the GUI program. This is done by first
sending the clock information to the coordinator and then asking the coordinator to

8
forward this information to the GUI program. This enables the GUI user to know the
progress of the simulation. During a simulation, the GUI user can also on-line set or get an
object’s value (e.g., to query or set a switch’s current switch table). Message exchanges
that occur between the simulation engine process and the GUI program are all relayed via
the coordinator.

6. The sixth component is the kernel patches that need to be made to the kernel source
code so that a simulation engine process can run on a UNIX machine correctly.
Currently NCTUns 6.0 runs on Red-Hat’s Fedora 11, which uses the Linux 2.6.28.9
kernel.

T
I
E
I
N

9
7 .seventh component is the various real-life user-level application programs. Due to the
novel kernel-reentering simulation methodology, any real-life existing or to-be
developed application program can be directly run up on a simulated network to
generate realistic network traffic.

8.The eighth component is the various user-level daemons that are run up for the whole
simulation case. For example, NCTUns provides RIP and OSPF routing daemons. By
running The these daemons, the routing entries needed for a simulated network can be
constructed automatically. As another example, NCTUns provides and automatically
runs up several emulation daemons when it is turned into an emulator.

Following steps are followed for simulation


Draw network topology
After the starting screen of N TUns disappears, a user will be presented a working window
where the required topology can be drawn.
Edit the properties of the network components
T

A network node (device) may have many parameters to set. For example, we may want to
I

set the maximum queue length of a FIFO queue used inside a network interface. For
E
I

another example, we may want to specify that some application programs (traffic
N

generators) should be run up on some hosts or routers to generate network traffic.


Run the simulation
When the mode is switched to the “Run Simulation” mode, the GUI will export many
simulation files that collectively describe the simulation case. These simulation files will
be transferred to the (either remote or local) simulation server for it to execute the
simulation. These files are stored in the “mainFileName.sim” directory, where
mainFileName is the name of this simulation case.
Packet Animation Player
By using the packet animation player, a packet ransfer race logged during a simulation
can be replayed at a specified speed. Both wired and wireless networks are supported.
This capability is very useful b cause it helps a researcher visually see and debug the
behavior of a network protocol. It is very useful for educational purposes because
students can see how a protocol behaves.
Play back animation features
• A link is painted in yellow color if there is any packet flowing on it.

10
• A packet is depicted by a segment with an arrow (for brevity, it will be called an
“arrow” in the following description).

• A collided packet is depicted by an arrow with a cross on it.

During a packet transfer, if a link is painted in red, it means that this link is an intermediate
link for this packet. In contrast, if this link is painted in yellow, it means that one end of
this link is the real source or destination node of the packet.
• The arrow length is determined by the packet’s length. Therefore, a user can
expect that the arrow length is proportional to the packet length. In fact, a
packet’s segment length on a particular link is determined by the transmission
time of that packet on that link relative to the signal propagation delay of the
link.

GETTING STARTED
Setting up the environment
T

A user using the NCTUns in single machine mode, needs to do the following steps before
I

he/she starts the GUI program:


E
I

1. Start up the dispatcher on terminal 1.


N

2. Start up the coordinator on terminal 2.

3. Start up the nctunsclient on terminal 3.

4. Enter command ./run and press tab and press enter.


After the above steps are followed, the starting screen of NCTUns disappears and the
user is presented with the working window.

Commands used:

TCP command for sender and receiver


Stcp –p 2000 –l 1024 1.0.1.2
rtcp –p 2000 –l 1024

11
UDP command for sender and receiver
Stg –u 1024 100 1.0.1.2
Rtg –u –w log1

p = port no, 1024 = length of packet size, 1.0.1.2–receiver ip address for TCP
u = user datagram, 100 = time in seconds for UDP

PART A Programs

1. Implement a point to point network with four nodes andduplex links between them.
Analyze the network performance by setting queue size and varying the bandwidth .
STEPS:
Step1: Create a topology as shown in the below figure.
T
I
E
I
N

Step 2: Select the hub icon on the toolbar and drag it onto the working window.
Step 3: select the host icon on the toolbar and drag it onto the working window.
Repeat this for another host icon.
Step 4: Select the link icon on the toolbar and drag it on the screen from host (node-2n to
the hub, host(node-3) to hub, node 4 to hub.

12
here node-1 is sender and other nodes are receiver where bandwidth and queue
This leads to the creation of the 4-node including hub point-to-point network topology.
Save this topology as a .tpl file.
Step 5: Double-click on host(node 2) -sender, a host dialog box will open up. Click on the
add and type the following Command.
Stg –u 1024 100 1.0.1.2 click ok.
Here, 1.0.1.2 is IP address of the host 2 (Node 3), and 3is the port no.
Click on Node editor and you can see the different layers - interface, ARP, FIFO, MAC,
TCPDUMP, Physical layers.

Select MAC and then select full-duplex and in log Statistics, select Throughput of
incoming packets for receiver and Throughput of outgoing packets for sender.
select FIFO to change queue size, and select PHY to change bandwidth (AT RECEIVER
NODE)
Step 6: Double-click on host (node 3),host (node 4),host(node5) and follow thesame step
as above with only change in command according to the following syntax:
T
I

rtg –u –w log1 and click OK.


E
I

here node 2 is considered as sender, node 3 and node 4 as receiver.


N

Step 7: Click on the E button (Edit Property) present on the toolbar in order tosave the
changes made to the topology. Now click on the R button (Run Simulation).By doing so a
user can
run/pause/continue/stop/abort/disconnect/reconnect/submit a simulation. Nosettings in
the simulation can be changed in this mode.
Step 8: Now go to Menu->Simulation->Run. Executing this command will submitthe
current Simulation job to one available simulation server managed by the 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
simulation case.
Step 9:After the simulation is completed, click on the play button and plot the graphs of
the drop pockets and throughput input and throughput output. These log files are created
in filename. Results fold r.
Step 10: Now click on the link (connecting the hub and host2) and change thebandwidth
say, 9 Mbps, and run the simulation and compare the two results
Graph Sheets:

13
N
E
I
T
I

14
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.
STEPS:
Step1:Create a topology as shown in the below figure

T
I
E
I
N

Step 2: Select 4 Nodes (2,3,4,5) and connect them using a hub as shown
Step 3: Go to mode edit and save the topology.
Step 4a: Double click on host (Node 2) and goto node editor, and click on MAC8023 and
put a check on the Throughput of Outgoing Packets. Click ok. Then click on ADD and type
the following command.
stcp –p 3000 –l 1024 1.0.1.3 and click OK. Here 1.0.1.3 is the IP address of the Host 3
(Receiver) and 3000 is the port no.
Step 4b: Double-click on host (node 4), and follow the same step as above withonly

15
change in command according to the following syntax:
stg –u 1024 100 1.0.1.3 and click OK. Here, 1.0.1.3 is Receiver IP and 100 is the
bandwidth. This forms theUDP connection.
Step 5: Double-click on host (node 3), and follow the same step as above and checkon
Throughput of Incoming Packets. And type the following commands:
rtcp –p 3000 –l 1024 click ok ( for TCP)
rtg –u –w log1 (node5) click ok ( for UDP),
Here, w is bandwidth and log1 is the name of the file.
Step 6: Click R Button and then go to Menu->Simulation - >Run.
Step 7: After the simulation is completed, click on heplay button and mean whileplot the
graphs of the Throughput Input and Through ut Output. These log files are created in
filename.results folder.
Graphs Sheet:

T
I
E
I
N

EXAMPLE AND RESULTS OF EXPT 2

16
N
E
I
T
I

17
3. Simulate an Ethernet LAN using N nodes (6-10), compare throughput by changing error
rate and data rate.
Step 1: Create a Host Subnet and select number of Nodes

Step2: Create a topology as shown in the above figure.


T
I
E
I
N

Step 3: Select host subnet option in the pop up window enter nodes = 6 andradius = 100
or select 6 Nodes (2-7) and connect them using a hub(1).

18
Step 4: Go to edit mode and save the topology.
Step 5: Let us say, Node 3, 2 and node 5 are source and destination respectively.
Double click on host (Node 3 and 2) and goto node editor, and click on MAC 8023
and put a check on the Throughput of Outgoing Packets. Click ok. Then click on ADD
and type the following command.
stcp –p 3000 –l 1024 1.0.1.4
Here 1.0.1.6 is the IP address of the Host (Receiver) and 3000 is the port no.Step5:
Double-click on host/receiver (node 5), and follow the same steps as aboveand check on
Throughput of Incoming Packets. And type the following commands:
rtcp –p 3000 –l 1024
Step 6: Click on R Button and then goto M nu->Simulation->Run.
Step 7: After the simulation is completed, click on the play button and meanwhile plot
the graphs of the Throughput Input and Throughput Output. These log files are created
in filename.results folder
Step 8: Change error rate (Bit error rate) and data rate (Bandwidth) in Physicallayer or on
the point to point link connecting any one of sender and receiver and then run the
T
I

simulation again and compare the Throughput Input and ThroughputOutput of 1stand
E

2ndreading.
I
N

Graphs Sheet:

19
4. Implement Ethernet LAN using n nodes and assign multiple traffic to the nodes and
obtain congestion window for different sources/destinations. Topology

Step1: Create a topology as shown in the below figure

T
I
E
I
N

Step 2: Go to edit mode and save the topology. IP addresses will be generated forall
hosts.
tcp –p 3000 –l 1024 1.0.1.5Here 1.0.1.5 is the IP address of the Host 5 (Receiver) and
3000 is the port no.Repeat the same step as above for node 2
Step 4: Double-click on host (node 5), and follow the same step as above And typethe
following commands:
rtcp –p 3000 –l 1024
Repeat the same step as above for node 2 and node 3.
Step 5: Click on R Button and then goto Menu->Simulation->Run.
Step 6: After the simulation is completed, click on the play button and mean whileplot
the graphs of the Collision and packets Dropped. These log files are created in
filename.results folder.
Graphs Sheet:

20
5.Implement ESS with transmission nodes in wireless LAN and obtain the
performance parameters.
Topology:
Step1: Create a topology as shown in the below figure

T
I
E

1.Select/click the HOST icon on the toolbar and click the left mouse button on the
I

editor, to place HOST1 on the editor.


N

2.Select/click the ROUTER icon on the toolbar and click the left mouse button on the
editor, to place ROUTER1 on the editor.

3.Select/click the WIRELESS ACCESS POINT(802.11b) icon on the toolbar and click
the left mouse button on the editor, to place ACCESS POINT 1 on the editor.Repeat
this procedure and place ACCESS POINT 2 on the editor.

4. Select/click the MOBILE NODE (infrastructure mode) icon on the toolbar and click
the left mouse button on the editor, to place MOBILE NODE 1 on the editor. Repeat this
procedure and place MOBILE NODE 2, MOBILE NODE3 and MOBILE NODE 4 on the
editor.

5.Click on the LINK icon on the toolbar and connect ACCESS POINT1 to ROUTER1 and
ACCESS POINT2 to ROUT R1.

6.Click on the “Create a moving path” icon on the toolbar and draw moving path
21
across MOBILE NODE 1 and 2, Repeat for MOBILE NODE 3and 4 (Accept the default
speed value 10 and close the window, Click the right to create Subnet

7.select wireless subnet icon in the toolbar now select MOBILE NODE1, MOBILE NODE
5 and ACCESS POINT 3 by clicking on left mouse button, and clicking right mouse
button will create a subnet.
Repeat the above step for MOBILE NODE 6 and ACCESS POINT 4.

Click on the “E” icon on the toolbar to save the current topology

Step2: Configuration
1.Double click the left mouse button while cursor is on HOST1 to open the HOST
window.
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 7000
ttcp –t –u –s –p 5000
T
I

2.Double click the left mouse button Mobile node-3 and click on Application provide
E
I

the following command in the command textbox


N

ttcp –t –u –s –p 7000 1.0.1.1


Select the MAC tab by clicking node editor of WLAN mobile node-3 and Select LOG
STATISTICS and select checkbox for Input and output throughput in the MAC window.
Click OK button on the MAC window to exit.

3.Double click the left mouse button Mobile node-6 and click on Application provide
the following command in the command textbox
ttcp –t –u –s –p 5000 1.0.1.1
Select the MAC tab by clicking node editor of WLAN mobile node-6 and Select LOG
STATISTICS and select checkbox for Input and output throughput in the MAC window.
Click OK button on the MAC window to exit.

Step3: Simulate
1. Click “R” icon on the tool bar
2. Select Simulation in the menu bar and click/ select RUN in the dropdown list to
execute the simulation.
3. To start playback select “►” icon located at the bottom right corner of the editor.

4. MOB LE NODE’s start moving across the paths already drawn.

22
Graphs Sheet:

T
I
E
I
N

23
PART-B: Implement the following in C/C++

THEORY

Topology:

The structure of a network and which is usually described in the form of a diagram
which shows the nodes and links between them.
The term network topology refers to the shape of how the computers and other
network components are connected to each other.
· Node: A node is a device that is connected to the network. For our purposes
here, a node is the same as a computer. Network topology deals with how
the nodes of a network are connected to each other.

· Packet: A packet is a message that is sent over the network from one node to
another node. The packet includes the address of the node that sent the
packet, the address of the node the packet is being sent to, and data.
T
I
E

Network topology:
I
N

Network topology is the geometric arrangement of nodes and cable links in a


LAN. Two general configurations are used, bus and star. These two topologies define
how nodes are connected to one another in a communication network. A node is an
active device connected to the network, such as a computer or a printer. A node can
also be a piece of networking equipment such as a hub, switch or a router.
A bus topology consists of nodes linked together in a series with each node
connected to a long cable or bus. Many nodes can tap into the bus and begin
communication with all other nodes on that cable segment. A break anywhere in the
cable will usually cause the entire segment to be inoperable until the break is
repaired. Examples of bus topology include 10BASE2 and 10BASE5.
LAN topology:
Local area networks are often categorized in terms of the topology which they
employ. The following topologies are commonly encountered; star, ring, tree, and bus
(the latter is a tree which has only one trunk and no branches).
In star topology, a central switching element is used to connect all of the
needs within the network. A node wishing to transmit data to another node must
initiate a request to the central switching element which will then provide a dedicated
path between them, once the circuit has been established; the two nodes may

24
communicate as if they were connected by a dedicated point-to-point path.

Ring topology:
Ring topologyis characterized by a closed loop to which each node is attachedby
means of a repeating element. Data circulates around the ring on a series of
point-to-point links which exist between the repeaters. A node wishing to transmit
must wait for its turn and then send data onto the ring in the form of a packet which
must contain both the source and destination addresses as well as the data itself.
Upon arrival at the destination node, the data is copied into a local buffer. The
packet continues to circulate until it returns to the source node, hence providing a
form of acknowledgement.
Bus and tree topologies both employ a multiple-access broadcast medium and
hence only one device can transmit at any time. As with ring topology, transmission
involves the generation of a packet containing source and destination address field
together with data.
T
I
E
I

Topology, Bus:
N

Bus refers to a physical and a logical topology. As a logical topology, a bus is


distinguished by the fact that packets are broadcast so that every node gets the
message at the same time. Ethernet networks are the best examples of a logical bus
topology.
As a physical topology, a bus describes a network in which each node is
connected to a common line: the backbone, or trunk. A bus usually has the file server
at one end, with the main trunk line extending from this point. (Although the metaphor
of a backbone is useful, it should not be taken literally; just as in the real world, not all
network backbones are straight.) The figure “A bus topology” illustrates this layout.

25
When the signal reaches the end of the trunk line, a terminator absorbs the
packet to keep it from traveling back again along the bus line, possibly interfering
with other messages already on the line. Each end of a trunk line must be terminated
so that signals are removed from the bus when they reach the end.

T
I
E
I
N

26
Thin and thick Ethernet are the best examples of a physical bus topology.
Twisted-pair Ethernet (10Base-T Ethernet) uses a logical bus topology, but a star
for its physical topology.
In a bus topology, nodes should be far enough apart that they do not
interfere with each other. If the backbone cable is long, it may be necessary to
boost the signal strength. The maximum length of the backbone is limited by the
size of the time interval that constitutes “simultaneous” packet reception.
Token Bus:
Token Bus is a network architecture defined in the IEEE 802.4 specifications.
The Token Bus architecture has never been popular for Local-Area Networks (LANs)
of the type found in most offices. It is, however, widely used in manufacturing
contexts.
The Token Bus architecture was inspired, in part, by work relating to the
automation of manufacturing tasks. This architecture has, in turn, become the
basis for the various types of Manufacturing Automation Protocol (MAP) systems
that have been developed to help automate operations in industrial contexts.
The 802.4 specifications include physical layer and Media Access Control
T

(MAC) Sub layer details for networks that use a bus topology and use token passing
I

as the media-access method. The figure “Context and properties of Token Bus”
E

summarizes this architecture.


I
N

27
Topology, Ring:

A ring topology is a logical and a physical topology. As a logical topology, a


ring is distinguished by the fact that packets are transmitted sequentially from node
to node, in a predefined order. Nodes are arranged in a closed loop so that the
initiating node is the last one to receive a packet. Token Ring networks are the most
widely used example of a logical ring topology. As a physical topology, a ring
describes a network in which each node is connected to two other nodes.
Information traverses a one-way path so that a node receives packets from exactly
one node and transmits them to exactly one other node. A packet travels around the
ring until it returns to the node that originally sent the packet. In a ring topology,
T

each node can act as a repeater, boosting the signal before sending it on. The figure
I

“A ring topology” illustrates this layout.


E
I
N

Each node checks whether the packet’s destination node matches the node’s
address. When the packet reaches its destination, the node accepts the message,
and then sends it back to the sender to acknowledge receipt. Since ring topologies
use token passing to control access to the network, the token is returned to sender
with the acknowledgment.
28
The sender then releases the token to the next node on the network. If this
node has nothing to say, the node passes the token on to the next node, and so on.
When the token reaches a node with a packet to send, that node sends its packet.
Physical ring networks are rare because this topology has considerable
disadvantages compared to a more practical star wired ring hybrid, which is
described in a separate article. The advantages of a ring topology are that the cable
requirements are fairly minimal and no wiring center or closet is needed.

The disadvantages of this topology include the following:


l If any node goes down, the entire ring goes down.

l Diagnosis/troubleshooting (fault isolation) is difficult because


communication is only one-way.
T
I

l Adding or removing nodes disrupts the network.


E
I
N

Token Ring:
Token Ring is a network architecture that uses a ring network topology
and a token passing strategy to control access to the network. This type of
architecture works best with networks that handle heavy data traffic from many
users, because of inherent fairness rules in token passing as an access method.
The figure “Context and properties of Token Ring” summarizes this
architecture.

29
With token passing as the media-access method, the node that has the token gets
to access the network, provided the token is available (not being used to transport a
packet) when the node receives it. Unlike the CSMA/CD media-access method that
Ethernet networks use, token passing is deterministic.
This means each node is guaranteed to get a turn sending packets within a
predefined time or number of cycles. Token Ring networks have the following
feature
T
I
E
I
N

30
Topology, Star:

A star topology is a physical topology in which multiple nodes are connected to a


central component, generally known as a hub. The figure “A star topology” illustrates this
layout. Despite appearances, such a wiring scheme actually implements a logical bus
topology.
The hub of a star generally is just a wiring center; that is, a common termination
point for the nodes, with a single connection continuing from the hub. In rare cases, the
hub may actually be a file server, with all its nodes attached directly to the server.
As a wiring center, a hub may, in turn, be connected to a file server, a wall plate, or to
another hub. All signals, instructions, and data going to and from each node must pass
through the hub to which the node is connected.

T
I
E
I
N

One advantage of a star topology is that troubleshooting and fault isolation are
easy. Also, it is easy to add or remove nodes and to modify the cable layout.
A disadvantage of this topology is that if the hub fails, the entire network fails.
Sometimes a backup central machine is included to make it possible to deal with such a
failure. Also, a star topology requires a lot of cable.
The central point of a star topology plays the role of traffic cop in that it directs
traffic to its intended destination rather than to everyone on the network. In a LAN

31
implementation, the traffic cop is often the switch. A star topology with a single switch
at its central point might look something like the illustration in Figure.

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.
What is Framing?

Since the physical layer merely accepts and transmits a stream of bits without any
regard to meaning or structure, it is upto the data link layer to create and recognize
frame boundaries. This can be accomplished by attaching special bit patterns to the
beginning and end of the frame. If these bit patterns can accidentally occur in data,
special care must be taken to make sure these patterns are not incorrectly interpreted as
frame delimiters. The four framing methods that are widely used are
T
I

· Character count
E

· Starting and ending characters, with character stuffing


I

· Starting and ending flags, with bit stuffing


N

· Physical layer coding violations

a. Bit Stuffing
Bit stuffing is the process of inserting non -information bits into data to break up
bit patterns to affect the synchronous transmission of information. It is widely used in
network and communication protocols, in which bit stuffing is a required part of the
transmission process. Bit stuffing is commonly used to bring bit streams up to a
common transmission rate or to fill frames. Bit stuffing is also used for run-length
limited coding.
In order to fill bit frames, the position where the new bits are stuffed is
communicated to the receiving end of the data link. The receiver removes the extra bits
to return the bit streams to their original bit rate. This is used when a communication
protocol requires a fixed frame size. Bits are inserted to make the frame size equal to
the defined frame size.

32
Bit stuffing also works to limit the number of consecutive bits of the same value
included in the transmitted data for run-length limited coding. This procedure includes a
bit of the opposite value after the maximum allowed number of consecutive bits of the
same value. For instance, if a number of zero bits are transmitted consecutively, the
receiving end loses synchronization because a lot of time has passed without voltage
sensing. Using bit stuffing, sets of bits beginning with the number one are stuffed into
streams of zeros at specific intervals. The receiver does not require any extra
information regarding the bit location when the extra bits are removed. Such bit stuffing
is done to ensure reliable data transmission and ensure that transmissions start and end
at the right places, among other purposes.

T
I
E
I
N

33
a.BIT stuffing Code
#include<stdio.h>
#include <curses.h>
#include<string.h>
void main()
{
intn,a[20],b[30],i,j,k,count;
printf("Enter frame size (Example: 8):");
scanf("%d",&n);
printf("Enter the frame in the form of 0 and 1 :");
for(i=0; i<n; i++) scanf("%d",&a[i]);
i=0;
count=1;
j=0;
while(i<n)
{
T

if(a[i]==1)
I

{
E

b[j]=a[i];
I
N

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];
}

34
i++;
j++;
}
printf("After Bit Stuffing :");
for(i=0; i<j; i++)
printf("%d",b[i]);
}
Output:

T
I
E
I
N

bit sequence: 110101111101011111101011111110 (without bit stuffing)

bit sequence: 110101111100101111101010111110110 (with bit stuffing)

after 5 consecutive 1-bits, a 0-bit is stuffed, stuffed bits are marked bold
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.

35
N
E
I
T
I

36
b.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.

Character Count
This method uses a field in the header to specify the number of characters in the
T

frame. When the data link layer at the destination sees the character count,it knows how
I

many characters follow, and hence where the end of the frame is. The disadvantage is
E
I

that if the count is garbled by a transmission error, the destination will lose
N

synchronization and will be unable to locate the start of the next frame. So, this method
is rarely used.

Although using characters to mark the beginning and end of each frame has
advantages, most computer networks cannot afford to reserve characters for use by the
network. Instead, the network permits anapplicationto transfer arbitrary data values
across the network. In particular, an application may choose to send data that contains
one or more occurrences of characters like soh and eot that are used for framing.
Ingeneral, to distinguish between data being sent and control information such as frame
delimiters, network systems arrange for the sending side to change the data slightly
before it is sent, and then arrange for thereceiving side to restore the original data before
passing it to the receiving application.
Thus, although applications using the network can transfer arbitrary data, the
network system never confuses data with control information. Because network systems
usually insert bits or bytes to change data for transmission, the technique is known as
data stuffing. The terms character stuffing and byte stuffing refer to data stuffing
used with character orientedhardware, and bit stuffing which is more common, refers to

37
data stuffing used with bit oriented hardware. To implement byte stuffing, a sender must
scan an entire data block and perform the mapping before any data is sent. Byte stuffing
can solve the problem by reserving a third character to mark occurrences of special
characters in the data.
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 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 DLEDLEETX''.Disadvantage:
character is the smallest unit that can be operated on; not all architectures are byte
T

oriented
I
E

Character stuffing-code
I
N

#include<stdio.h>
#include<string.h>
void main()
{
inti=0,j=0,n,pos;
char a[20],b[50],ch;

printf("enter string\n");
scanf("%s",&a);
n=strlen(a);

b[0]='d';
b[1]='l';
b[2]='e';
b[3]='s';
b[4]='t';

38
b[5]='x';
j=6;

while(i<n)
{
if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e')
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
j=j+3;
}

b[j]=a[i];
i++;
j++;
T

}
I
E

b[j]='d';
I
N

b[j+1]='l';
b[j+2]='e';
b[j+3]='e';
b[j+4]='t';
b[j+5]='x';
b[j+6]='\0';
printf("\nframe after stuffing:\n");
printf("%s\n",b);
}
Conclusion :
After observing the above program what we notice is that , our original data to
be transmitted is hasDLESTX as the part of data at the start and end while transmitting ,
and then at the receiving side these stuffed characters are removed and original data is
recovered back . Also if data contains those characters which are being stuffed then like
DLE then it is inserted before those characters and then transmitted, and at the receiving
side original data is recovered.

39
Output:

T
I
E
I

2.Write a program for distance vector algorithm to find suitable path for transmission.
N

A distance-vector routing (DVR) protocol requires that a router inform its


neighbors of topology changes periodically. Historically known as the old ARPANET
routing algorithm (or known as Bellman-Ford algorithm).
Bellman Ford Basics – Each router maintains a Distance Vector table containing the
distance between itself and ALL possible destination nodes. Distances based on a
chosen metric, are computed using information from the neighbors’ distance vectors.

Distance vector routing is a simple distributed routing protocol. Distance vector


routing allows routers to automatically discover the destinations reachable inside the
network as well as the shortest path to reach each of these destinations. The shortest
path is computed based on metrics  or costs  that are associated to each link. We
use l.cost  to represent the metric that has been configured for link l  on a router.

Information kept by DV router -

§ Each router has an ID

40
§ Associated with each link connected to a router,
§ there is a link cost (static or dynamic).
§ Intermediate hops

Distance Vector Table Initialization -

§ Distance to itself = 0
§ Distance to ALL other routers = infinity number.

Distance Vector Algorithm –


1. A router transmits its distance vector to each of its neighbors in a routing packet.
2. Each router receives and saves the most recently received distance vector from
each of its neighbors.
3. A router recalculates its distance vector when:
§ It receives a distance vector from a neighbor containing different information
than before.
§ It discovers that a link to a neighbor has gone down.
T

The DV calculation is based on minimizing the cost to each destination


I
E

Dx(y) = Estimate of least cost from x to y


I
N

C(x,v) = Node x knows cost to each neighbor v

Dx= [Dx(y): y∈ N ] = Node x maintains distance vector

Node x also maintains its neighbors' distance vectors

– For each neighbor v, x maintains Dv = [Dv(y): y∈N ]

Advantages of Distance Vector routing –


§ It is simpler to configure and maintain than link state routing.
Disadvantages of Distance Vector routing –
§ It is slower to converge than link state.
§ It is at risk from the count-to-infinity problem.
§ It creates more traffic than link state since a hop count change must be propagated
to all routers and processed on each router. Hop count updates take place on a
periodic basis, even if there are no changes in the network topology, so

41
bandwidth-wasting broadcasts still occur.
§ For larger networks, distance vector routing results in larger routing tables than link
state since each router must know about all other routers. This can also lead to
congestion on WAN links.

DISTANCE VECTOR ALGORITHM-CODE


#include<stdio.h>
#include<stdlib.h>
intn,cost[10][10],via[10][10],i,j,k;
intmain()
{
printf("Enter the number of nodes(less than 10)\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nThe cost from %c:(999 for no connection)\n",65+i);
T

for(j=0;j<n;j++)
I

{
E

if(i!=j) // To find the distance from vertex to same vertex


I
N

{
printf("To %c:",65+j);
scanf("%d",&cost[i][j]);
}
else
cost[i][j]=0;
}
}
for(i=0;i<n;i++) // calculation for finding the shortest path for
the given cost
for(j=0;j<n;j++)
via[i][j]=i;

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{

42
if(cost[i][j]<999)
{
for(k=0;k<n;k++)
{
if(cost[i][k]>cost[i][j]+cost[j][k]) // To find shortest path from various
nodes
{

cost[i][k]=cost[i][j]+cost[j][k];
via[i][k]=j;
}
}
}
}
}
for(i=0;i<n;i++)
T

{
I

printf("The preferred path from %c to:\n",65+i);


E

for(j=0;j<n;j++)
I
N

{
if(cost[i][j]!=999)
printf("%c:%d via %c\n",65+j,cost[i][j],65+via[i][j]);
else
printf("%c:No connection\n,65+j");
}
}
return 0;
}

43
Output
nieit@localhostpawan]$ ./a.out
Enter the number of nodes(less than 10)
4
T

The cost from A:(999 for no connection)


I

To B:3
E

To C:7
I
N

To D:6

The cost from B:(999 for no connection)


To A:3
To C:1
To D:999

The cost from C:(999 for no connection)


To A:7
To B:1
To D:5

The cost from D:(999 for no connection)


To A:6
To B:999
To C:5
The preferred path from A to:

44
A:0 via A
B:3 via A
C:4 via B
D:6 via A
The preferred path from B to:
A:3 via B
B:0 via B
C:1 via B
D:6 via C
The preferred path from C to:
A:4 via B
B:1 via C
C:0 via C
D:5 via C
The preferred path from D to:
A:6 via D
T

B:6 via C
I

C:5 via D
E

D:0 via D
I
N

[nieit@localhostpawan]$

45
4.Implement Dijkstra’s algorithm to compute the shortest routing path.

Theory:

One algorithm for finding the shortest path from a starting node to a target node in a
weighted graph is Dijkstra’s algorithm. The algorithm creates a tree of shortest paths
from the starting vertex, the source, to all other points in the graph.

Dijkstra’s algorithm, published in 1959 and named after its creator Dutch computer
scientist Edsger Dijkstra, can be applied on a weighted graph. The graph can either be
directed or undirected. One stipulation to using the algorithm is that the graph needs to
have a nonnegative weight on every edge.

Suppose a student wants to go from home to school in the shortest possible way. She
knows some roads are heavily congested and difficult to use. In Dijkstra's algorithm, this
means the edge has a large weight--the shortest path tree found by the algorithm will try
to avoid edges with larger weights. If the student looks up directions using a map
T
I

service, it is likely they may use Dijkstra's algorithm, as well as others.


E
I

Example:
N

Find the shortest path from home to school in the following graph:

The shortest path, which could be found using Dijkstra's algorithm, is

46
Home(B(D(F(school. T
I
E
I
N

47
Dijkstra’s algorithm-Code

#include<stdio.h>
#include<conio.h>
#define INFINITY 9999
#define MAX 10

void dijkstra(int G[MAX][MAX],intn,intstartnode);

intmain()
{
int G[MAX][MAX],i,j,n,u;
printf("Enter no. of vertices:");
scanf("%d",&n);
printf("\nEnter the adjacency matrix:\n"); T

for(i=0;i<n;i++)
I

for(j=0;j<n;j++)
E

scanf("%d",&G[i][j]);
I
N

printf("\nEnter the starting node:");


scanf("%d",&u);
dijkstra(G,n,u);

return 0;
}

void dijkstra(int G[MAX][MAX],intn,intstartnode)


{

int cost[MAX][MAX],distance[MAX],pred[MAX];
int visited[MAX],count,mindistance,nextnode,i,j;

//pred[] stores the predecessor of each node


//count gives the number of nodes seen so far
//create the cost matrix

48
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(G[i][j]==0)
cost[i][j]=INFINITY;
else
cost[i][j]=G[i][j];

//initialize pred[],distance[] and visited[]


for(i=0;i<n;i++)
{
distance[i]=cost[startnode][i];
pred[i]=startnode;
visited[i]=0;
}
distance[startnode]=0;
visited[startnode]=1;
T

count=1;
I

while(count<n-1)
E

{
I
N

mindistance=INFINITY;

//nextnode gives the node at minimum distance


for(i=0;i<n;i++)
if(distance[i]<mindistance&&!visited[i])
{
mindistance=distance[i];
nextnode=i;
}

//check if a better path exists through nextnode


visited[nextnode]=1;
for(i=0;i<n;i++)
if(!visited[i])
if(mindistance+cost[nextnode][i]<distance[i])
{
distance[i]=mindistance+cost[nextnode][i];

49
pred[i]=nextnode;
}
count++;
}
//print the path and distance of each node
for(i=0;i<n;i++)
if(i!=startnode)
{
printf("\nDistance of node%d=%d",i,distance[i]);
printf("\nPath=%d",i);

j=i;
do
{
j=pred[j];
printf("<-%d",j);
T

}while(j!=startnode);
I

}
E

}
I
N

Output:

50
5.For the given data, use CRC-CCITT polynomial to obtain CRC code. Verify the program
T
I

for the cases a. Without error b. With error.


E
I

Theory:-Physical layer coding violations


N

The final framing method is physical layer coding violations and is applicable to
networks in which the encoding on the physical medium contains some redundancy. In
such cases normally, a 1 bit is a high-low pair and a 0 bit is a low-high pair. The
combinations of low-low and high-high which are not used for data may be used for
marking frame boundaries.

Error Control
The bit stream transmitted by the physical layer is not guaranteed to be error free.
The data link layer is responsible for error detection and correction. The most common
error control method is to compute and append some form of a checksum to each
outgoing frame at the sender's data link layer and to recomputed the checksum and
verify it with the received checksum at the receiver's side. If both of them match, then the
frame is correctly received; else it is erroneous. The checksums may be of two types:
# Error detecting : Receiver can only detect the error in the frame and inform the sender
about it. # Error detecting and correcting : The receiver can not only detect the error but
also correct it.

51
Examples of Error Detecting methods:

· Parity-bit:

Simple example of error detection technique is parity bit. The parity bit is chosen
that the number of 1 bits in the code word is either even( for even parity) or odd (for odd
parity). For example when 10110101 is transmitted then for even parity an 1 will be
appended to the data and for odd parity a 0 will be appended. This scheme can detect
only single bits. So if two or more bits are changed then that can not be detected.

· Longitudinal Redundancy Checksum:


Longitudinal Redundancy Checksum is an error detecting scheme which
overcomes the problem of two erroneous bits. In this conceptof parity bit is used but
with slightly more intelligence. With each byte we send one parity bit then send one
additional byte which have the parity corresponding to the each bit position of the sent
bytes. So the parity bit is set in both horizontal and vertical direction. If one bit get
flipped we can tell which row and column have error then we find the intersection of the
T

two and determine the erroneous bit. If 2 bits are in error and they are in the different
I

column and row then they can be detected. If the error are in the same column then the
E
I

row will differentiate and vice versa. Parity can detect the only odd number of errors. If
N

they are even and distributed in a fashion that in all direction then LRC may not be able to
find the error.

52
· Cyclic Redundancy Checksum (CRC):

Whenever digital data is stored or interfaced, data corruption might occur. Since the
beginning of computer science, developers have been thinking of ways to deal with this
type of problem. For serial data they came up with the solution to attach a parity bit to
each sent byte. This simple detection mechanism works if an odd number of bits in a
byte changes, but an even number of false bits in one byte will not be detected by the
parity check. To overcome this problem developers have searched for mathematical
sound mechanisms to detect multiple false bits. The CRC calculation or cyclic
redundancy check was the result of this. Nowadays CRC calculations are used in all
types of communications. All packets sent over a network connection are checked with
a CRC. Also each data block on your hard disk has a CRC value attached to it. Modern
computer world cannot do without these CRC calculations. So let's see why they are so
widely used. The answer is simple; they are powerful, detect many types of errors and
are extremely fast to calculate especially when dedicated hardware chips are used.
The idea behind CRC calculation is to look at the data as one large binary number.
T
I

This number is divided by a certain value and the remainder of the calculation is called
E

the CRC. Dividing in the CRC calculation at first looks to cost a lot of computing power,
I

but it can be performed very quickly if we use a method similar to the one learned at
N

school. We will as an example calculate the remainder for the character 'm'—which is
1101101 in binary notation—by dividing it by 19 or 10011. Please note that 19 is an odd
number. This is necessary as we will see further on. Please refer to your schoolbooks as
the binary calculation method here is not very different from the decimal method you
learned when you were young. It might only look a little bit strange. Also notations differ
between countries, but the method is similar.
With decimal calculations you can quickly check that 109 divided by 19 gives a
quotient of 5 with 14 as the remainder. But what we also see in the scheme is that every
bit extra to check only costs one binary comparison and in 50% of the cases one binary
subtraction. You can easily increase the number of bits of the test data string—for
example to 56 bits if we use our example value "Lammert"—and the result can be
calculated with 56 binary comparisons and an average of 28 binary subtractions. This
can be implemented in hardware directly with only very few transistors involved. Also
software algorithms can be very efficient.
All of the CRC formulas you will encounter are simply checksum algorithms based

53
on modulo-2 binary division where we ignore carry bits and in effect the subtraction will
be equal to an exclusive or operation. Though some differences exist in the specifics
across different CRC formulas, the basic mathematical process is always the same:
The message bits are appended with c zero bits; this augmented message is the
dividend A predetermined c+1-bit binary sequence, called the generator polynomial, is
the divisor The checksum is the c-bit remainder that results from the division
operation
Table 1 lists some of the most commonly used generator polynomials for 16- and
32-bit CRCs. Remember that the width of the divisor is always one bit wider than the
remainder. So, for example, you’d use a 17-bit generator polynomial whenever a 16-bit
checksum is required.
1) Error detection with CRC
Consider a message represented by the polynomial M(x) .Consider a generating
polynomial G(x) This is used to generate a CRC = C(x) to be appended to M(x). Note this
G(x) is prime.
T
I

Steps:1. Multiply M(x) by highest power in G(x). i.e. Add So much zeros to M(x). 2. Divide
E

the result by G(x). The remainder = C(x). Special case: This won't work if bitstring =all
I

zeros. We don't allow such an M(x).But M(x) bitstring = 1 will work, for example. Can
N

divide 1101 into 1000. 3. If: x div y gives remainder c that means: x = n y + c Hence (x-c)
= n y (x-c) div y gives remainder 0 Here (x-c) = (x+c) Hence (x+c) div y gives remainder
0 4. Transmit: T(x) = M(x) + C(x) 5. Receiver end: Receive T(x). Divide by G(x), should
have remainder 0. Note if G(x) has order n - highest power is xn, then G(x) will cover
(n+1) bits and the remainder will cover n bits. i.e. Add n bits (Zeros) to message.
We have an n-bit message. The sender adds a k-bit Frame Check Sequence (FCS)
to this message before sending. The resulting (n+k) bit message is divisible by some
(k+1) bit number. The receiver divides the message ((n+k)-bit) by the same (k+1)-bit
number and if there is no remainder, assumes that there was no error. How do we
choose this number?
For example, if k=12 then 1000000000000 (13-bit number) can be chosen, but this is a
pretty crappy choice. Because it will result in a zero remainder for all (n+k) bit messages
with the last 12 bits zero. Thus, any bits flipping beyond the last 12 go undetected. If
k=12, and we take 1110001000110 as the 13-bit number (incidentally, in decimal
representation this turns out to be 7238). This will be unable to detect errors only if the
corrupt message and original message have a difference of a multiple of 7238. The

54
probability of this is low, much lower than the probability that anything beyond the last
12-bits flips. In practice, this number is chosen after analyzing common network
transmission errors and then selecting a number which is likely to detect these common
errors.

Cyclic Redundancy Checksum (CRC)-Code.

#include<stdio.h>

#include<string.h>

#define N strlen(g)char t[128], cs[128], g[]="1011";

int a, e, c;voidxor()

for(c=1;c<N;c++) cs[c]=((cs[c]==g[c])?'0':'1');

void crc()
T
I

{
E
I

for(e=0;e<N;e++) cs[e]=t[e];//copying msg to checksum to division


N

do {

if(cs[0]=='1') xor();//check for 1 and then go to xor

for(c=0;c<N-1;c++) cs[c]=cs[c+1];//increment the value for remainder

cs[c]=t[e++];//updating checksum if not equal to zero

while(e<=a+N-1);

void main()

printf("\n Enter Message: ");

scanf("%s",t);

printf("\n Generating Polynomial is : %s",g);

55
a=strlen(t);

for(e=a;e<a+N-1;e++) t[e]='0';// appending zeros to the msg

printf("\n Modified t[u] is : %s",t);// modified message

crc();

printf("\nChecksum is : %s",cs);

for(e=a;e<a+N-1;e++) t[e]=cs[e-a];//appending syndrome to message

printf("\nFinalCodeword is : %s",t);

printf("\n Introduce error 0(yes) 1(no) ? : ");

scanf("%d",&e);

if(e==0)

printf("Enter position where error is to inserted : ");


T
I

scanf("%d",&e);
E

t[e]=(t[e]=='0')?'1':'0';
I
N

printf("Errorneous data : %s\n",t);

crc();//receiver end checking by division

for(e=0;(e<N-1)&&(cs[e]!='1');e++);//check for both msg and sydrome for 0s.

if(e<N-1) printf("Error detected.");

else printf("No Error Detected.");

Output:

56
N
E
I
T
I

57
5. Implementation of Stop and Wait Protocol and Sliding Window Protocol

Flow Control

Consider a situation in which the sender transmits frames faster than the receiver
can accept them. If the sender keeps pumping out frames at high rate, at some point the
receiver will be completely swamped and will start losing some frames. This problem
may be solved by introducing flow control. Most flow control protocols contain a
feedback mechanism to inform the sender when it should transmit the next frame.

Mechanisms For Flow Control:

· Stop and Wait Protocol: This is the simplest file control protocol in which the sender
transmits a frame and then waits for an acknowledgement, either positive or negative,
from the receiver before proceeding. If a positive acknowledgement is received, the
sender transmits the next packet; else it retransmits the same frame. However, this
protocol has one major flaw in it. If a packet or an acknowledgement is completely
destroyed in transit due to a noise burst, a deadlock will occur because the sender
T
I

cannot proceed until it receives an acknowledgement. This problem may be solved using
timers on the sender's side. When the frame is transmitted, the timer is set. If there is no
E
I

response from the receiver within a certain time interval, the timer goes off and the
N

frame may be retransmitted.


· Stop and Wait Protocol-Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main()
{
inti,j,noframes,x,x1=10,x2;
srand(time(NULL));
noframes=rand()%100;
printf("number of frames is %d ",noframes);
i=1;
while(noframes>0)
{
printf("sending frame no. %d\n",i);
srand(x1++);

58
x=rand()%15;
if(x%5==0)
{
for(x2=1;x2<2;x2++)
{
printf("Timer out after waiting for %d seconds\n",x2);
sleep(x2);
}
printf("resending frame %d\n",i);
}
printf("ACK for frame %d is received\n",i);
printf("---------------------------------------------\n");
noframes=noframes-1;
i++;
}
printf("End of stop and wait protocol\n");
T

}
I

#include<stdio.h>
E

#include<stdlib.h>
I
N

#include<time.h>
int main ()
{
printf ("Our first number: %d\n", rand() % 100);
srand( time(NULL) );
printf ("Some random number: %d\n", rand() % 100);
srand( 1 );
printf ("The first number again: %d\n", rand() %100);
return 0;
}
output of the srand example program above:
Our first number: 41
Some random number: 4
The first number again: 41

59
· Sliding Window Protocols:

In spite of the use of timers, the stop and wait protocol still suffers from a few
drawbacks. Firstly, if the receiver had the capacity to accept more than one frame, its
resources are being underutilized. Secondly, if the receiver was busy and did not wish to
receive any more packets, it may delay the acknowledgement. However, the timer on the
T

sender's side may go off and cause an unnecessary retransmission. These drawbacks
I

are overcome by the sliding window protocols.


E

In sliding window protocols the sender's data link layer maintains a 'sending window'
I
N

which consists of a set of sequence numbers corresponding to the frames it is permitted


to send. Similarly, the receiver maintains a 'receiving window' corresponding to the set of
frames it is permitted to accept. The window size is dependent on the retransmission
policy and it may differ in values for the receiver's and the sender's window. The
sequence numbers within the sender's window represent the frames sent but as yet not
acknowledged. Whenever a new packet arrives from the network layer, the upper edge of
the window is advanced by one. When an acknowledgement arrives from the receiver the
lower edge is advanced by one. The receiver's window corresponds to the frames that
the receiver's data link layer may accept. When a frame with sequence number equal to
the lower edge of the window is received, it is passed to the network layer, an
acknowledgement is generated and the window is rotated by one. If however, a frame
falling outside the window is received, the receiver's data link layer has two options. It
may either discard this frame and all subsequent frames until the desired frame is
received or it may accept these frames and buffer them until the appropriate frame is
received and then pass the frames to the network layer in sequence.

In this simple example, there is a 4-byte sliding window. Moving from left to right,

60
the window "slides" as bytes in the stream are sent and acknowledged.
Most sliding window protocols also employ ARQ ( Automatic Repeat reQuest )
mechanism. In ARQ, the sender waits for a positive acknowledgement before proceeding
to the next frame. If no acknowledgement is received within a certain time interval it
retransmits the frame. ARQ is of two types :

1. Go Back 'n': If a frame is lost or received in error, the receiver may simply discard
all subsequent frames, sending no acknowledgments for the discarded frames. In this
case the receive window is of size 1. Since no acknowledgements are being received
the sender's window will fill up, the sender will eventually time out and retransmit all the
unacknowledged frames in order starting from the damaged or lost frame. The
maximum window size for this protocol can be obtained as follows. Assume that the
window size of the sender is n. So the window will initially contain the frames with
sequence numbers from 0 to (w-1). Consider that the sender transmits all these frames
and the receiver's data link layer receives all of them correctly. However, the sender's
data link layer does not receive any acknowledgements as all of them are lost. So the
T

sender will retransmit all the frames after its timer goes off. However the receiver
I

window has already advanced to w. Hence to avoid overlap , the sum of the two
E

windows should be less than the sequence number space.


I
N

w-1 + 1 < Sequence Number Space


i.e., w < Sequence Number Space
Maximum Window Size = Sequence Number Space - 1

Selective Repeat: In this protocol rather than discard all the subsequent frames
following a damaged or lost frame, the receiver's data link layer simply stores them in
buffers. When the sender does not receive an acknowledgement for the first frame it's
timer goes off after a certain time interval and it retransmits only the lost frame.
Assuming error - free transmission this time, the sender's data link layer will have a
sequence of a many correct frames which it can hand over to the network layer. Thus
there is less overhead in retransmission than in the case of go back protocol.
In case of selective repeat protocol the window size may be calculated as follows.
Assume that the size of both the sender's and the receiver's window is w. So initially
both of them contain the values 0 to (w-1). Consider that sender's data link layer
transmits all the w frames, the receiver's data link layer receives them correctly and
sends acknowledgements for each of them. However, all the acknowledgements are
lost and the sender does not advance it's window. The receiver window at this point

61
contains the values w to (2w-1). To avoid overlap when the sender's data link layer
retransmits, we must have the sum of these two windows less than sequence number
space. Hence, we get the condition

Maximum Window Size = Sequence Number Space / 2

Sliding Window Protocols-Code

#include<stdio.h>

intmain()

intw,i,f,frames[50];

printf("Enter window size: ");

scanf("%d",&w);

printf("\nEnter number of frames to transmit: ");


T
I

scanf("%d",&f);
E

printf("\nEnter %d frames: ",f);


I
N

for(i=1;i<=f;i++)

scanf("%d",&frames[i]);

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");

62
}

else

printf("%d ",frames[i]);

if(f%w!=0)

printf("\nAcknowledgement of above frames sent is received by sender\n");

return 0;

Output:

T
I
E
I
N

63
6. 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 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
T

resources (in part of the system) can handle. For subnets that use virtual circuits
I

internally, these methods can be used at the network layer.


E
I

Another open loop method to help manage congestion is forcing the packet to be
N

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.

64
leaky bucket algorithm-code
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
intmain()
{
intsz,i,j,otr,timer,c=0,n;
intpcksz[10];
T

printf("enter the bucket size\n");


I
E

scanf("%d",&sz);
I
N

printf("enter the output rate\n");


scanf("%d",&otr);
printf("enter the no of packets\n");
scanf("%d",&n);
printf("enter the timer value\n");
scanf("%d",&timer);
printf("enter the packet size\n");
for(i=0;i<n;i++)
{
printf("size of packet%d\n",i+1);
scanf("%d",&pcksz[i]);
}
for(i=0;i<n;i++)

65
{
printf("no of packets %d\n,packet size %d\n",i+1,pcksz[i]);
c=c+pcksz[i];
if(c>sz)
{
printf("packet %d discarded\n",i+1);
c=c-pcksz[i];
}
for(j=1;j<=timer;j++)
{
if(c>otr)
{
T

c=c-otr;
I

printf("%d bytes sent\n",otr);


E
I

sleep(1);
N

}
else if(c==0)
{
printf("bucket is empty\n");
sleep(1);
}
else
{
printf("%d bytes sent\n",c);
sleep(1);
c=0;
}

66
pcksz[i]=0;
}
printf("time expired\n");
}
printf(" %d bytes in leaky bucket to be sent\n",c);
while(c>otr)
{
printf("%d byte sent \n",otr);
c=c-otr;
}
if(c!=0)
{
T

printf("last %d bytes sent\n",c);


I

printf("transfer complete bucket is empty\n");


E
I

}
N

Output enter the timer value size of packet4


[nieit@localhostpawan] 5 6
$ ./a.out enter the packet size size of packet5
enter the bucket size size of packet1 5
10 2 size of packet6
enter the output rate size of packet2 3
2 4 size of packet7
enter the no of packets size of packet3 1
10 8 size of packet8

67
2 bucket is empty ,packet size 1
size of packet9 time expired 1 bytes sent
3 no of the packet 4 bucket is empty
size of packet10 ,packet size 6 bucket is empty
1 2 bytes sent bucket is empty
no of the packet 1 2 bytes sent bucket is empty
,packet size 2 2 bytes sent time expired
2 bytes sent bucket is empty no of the packet 8
bucket is empty bucket is empty ,packet size 2
bucket is empty time expired 2 bytes sent
bucket is empty no of the packet 5 bucket is empty
bucket is empty ,packet size 5 bucket is empty
T

time expired 2 bytes sent bucket is empty


I

no of the packet 2 2 bytes sent bucket is empty


E
I

,packet size 4 1 bytes sent time expired


N

2 bytes sent bucket is empty no of the packet 9


2 bytes sent bucket is empty ,packet size 3
bucket is empty time expired 2 bytes sent
bucket is empty no of the packet 6 1 bytes sent
bucket is empty ,packet size 3 bucket is empty
time expired 2 bytes sent bucket is empty
no of the packet 3 1 bytes sent bucket is empty
,packet size 8 bucket is empty time expired
2 bytes sent bucket is empty no of the packet 10
2 bytes sent bucket is empty ,packet size 1
2 bytes sent time expired 1 bytes sent
2 bytes sent no of the packet 7 bucket is empty

68
bucket is empty size of packet4 2 bytes sent
bucket is empty 6 time expired
bucket is empty size of packet5 no of the packet 4
time expired 5 ,packet size 6
0 bytes in leaky bucket size of packet6 2 bytes sent
to be sent 3 2 bytes sent
[nieit@localhostpawan]$ size of packet7 time expired
1 no of the packet 5
size of packet8 ,packet size 5
------ 2 packet 5 discarded
[nieit@localhostpawan] size of packet9 2 bytes sent
$ ./a.out
3 2 bytes sent
enter the bucket size
T

size of packet10 time expired


I

10
7 no of the packet 6
E

enter the output rate


I

no of the packet 1 ,packet size 3


N

2
,packet size 2 2 bytes sent
enter the no of packets
2 bytes sent 2 bytes sent
10
bucket is empty time expired
enter the timer value
time expired no of the packet 7
2
no of the packet 2 ,packet size 1
enter the packet size
,packet size 4 2 bytes sent
size of packet1
2 bytes sent bucket is empty
2
2 bytes sent time expired
size of packet2
time expired no of the packet 8
4
no of the packet 3 ,packet size 2
size of packet3
,packet size 8 2 bytes sent
8
2 bytes sent bucket is empty

69
time expired enter the timer value bucket is empty
no of the packet 9 5 bucket is empty
,packet size 3 enter the packet size bucket is empty
2 bytes sent size of packet1 time expired
1 bytes sent 2 no of the packet 2
time expired size of packet2 ,packet size 4
no of the packet 10 4 2 bytes sent
,packet size 7 size of packet3 2 bytes sent
2 bytes sent 15 bucket is empty
2 bytes sent size of packet4 bucket is empty
time expired 6 bucket is empty
3 bytes in leaky bucket size of packet5 time expired
to be sent
T

5 no of the packet 3
I

2 byte sent size of packet6 ,packet size 15


E
I

last 1 bytes sent 3 packet 3 discarded


N

transfer complete size of packet7 bucket is empty


bucket is empty
1 bucket is empty
[nieit@localhostpawan]$
size of packet8 bucket is empty
2 bucket is empty
-----
size of packet9 bucket is empty
[nieit@localhostpawan]
$ ./a.out 3 time expired

enter the bucket size size of packet10 no of the packet 4

10 6 ,packet size 6

enter the output rate no of the packet 1 2 bytes sent

2 ,packet size 2 2 bytes sent

enter the no of packets 2 bytes sent 2 bytes sent

10 bucket is empty bucket is empty

70
bucket is empty no of the packet 7 2 bytes sent
time expired ,packet size 1 1 bytes sent
no of the packet 5 1 bytes sent bucket is empty
,packet size 5 bucket is empty bucket is empty
2 bytes sent bucket is empty bucket is empty
2 bytes sent bucket is empty time expired
1 bytes sent bucket is empty no of the packet 10
bucket is empty time expired ,packet size 6
bucket is empty no of the packet 8 2 bytes sent
time expired ,packet size 2 2 bytes sent
no of the packet 6 2 bytes sent 2 bytes sent
,packet size 3 bucket is empty bucket is empty
T

2 bytes sent bucket is empty bucket is empty


I

1 bytes sent bucket is empty time expired


E
I

bucket is empty bucket is empty 0 bytes in leaky bucket


N

to be sent
bucket is empty time expired
[nieit@localhostpawan]$
bucket is empty no of the packet 9
time expired ,packet size 3

Computer Network Lab Viva Questions

1. Define Network?
A network is a set of devices connected by physical media links. A network is recursively

71
is a connection of two or more nodes by a physical link or two or more networks
connected by one or more nodes.
2. What is a Link?
At the lowest level, a network can consist of two or more computers directly connected
by some physical medium such as coaxial cable or optical fiber. Such a physical
medium is called as Link.
3. What is a node?
A network can consist of two or more computers directly connected by some physical
medium such as coaxial cable or optical fiber. Such a physical medium is called as Links
and the computer it connects is called as Nodes.
4. What is a gateway or Router?
A node that is connected to two or more networks is commonly called as router or
Gateway. It generally forwards message from one network to another.
5. What is point-point link?
If the physical links are limited to a pair of nodes it is said to be point-point link.
6. What is Multiple Access?
T

If the physical links are shared by more than two nodes, it is said to be Multiple Access.
I

7. What are the advantages of Distributed Processing?


E

a. Security/Encapsulation
I
N

b. Distributed database
c. Faster Problem solving
d. Security through redundancy
e. Collaborative Processing
8. What are the criteria necessary for an effective and efficient network?
a. Performance
   It can be measured in many ways, including transmit time and response time. b.
Reliability
   It is measured by frequency of failure, the time it takes a link to recover from a failure,
and the network's robustness.
c. Security
   Security issues includes protecting data from unauthorized access and virues.
9. Name the factors that affect the performance of the network?
a. Number of Users
b. Type of transmission medium
c. Hardware
d. Software

72
10. Name the factors that affect the reliability of the network?
a. Frequency of failure
b. Recovery time of a network after a failure
11. Name the factors that affect the security of the network?
a. Unauthorized Access
b. Viruses
12. What is Protocol?
A protocol is a set of rules that govern all aspects of information communication.
13. What are the key elements of protocols?
The key elements of protocols are
a. Syntax
   It refers to the structure or format of the data, that is the order in which they are
presented.
b. Semantics
   It refers to the meaning of each section of bits.
c. Timing
T

   Timing refers to two characteristics: When data should be sent and how fast they can
I

be sent.
E

14. What are the key design issues of a computer Network?


I
N

a. Connectivity
b. Cost-effective Resource Sharing
c. Support for common Services
d. Performance
15. Define Bandwidth and Latency?
Network performance is measured in Bandwidth (throughput) and Latency (Delay).
Bandwidth of a network is given by the number of bits that can be transmitted over the
network in a certain period of time. Latency corresponds to how long it t5akes a
message to travel from one end off a network to the other. It is strictly measured in
terms of time.
16. Define Routing?
The process of determining systematically hoe to forward messages toward the
destination nodes based on its address is called routing.
17. What is a peer-peer process?
The processes on each machine that communicate at a given layer are called peer-peer
process.
18. When a switch is said to be congested?

73
It is possible that a switch receives packets faster than the shared link can
accommodate and stores in its memory, for an extended period of time, then the switch
will eventually run out of buffer space, and some packets will have to be dropped and in
this state is said to congested state.
19. What is semantic gap?
Defining a useful channel involves both understanding the applications requirements and
recognizing the limitations of the underlying technology. The gap between what
applications expects and what the underlying technology can provide is called semantic
gap.
20. What is Round Trip Time?
The duration of time it takes to send a message from one end of a network to the other
and back, is called RTT.
21. Define the terms Unicasting, Multiccasting and Broadcasting?
If the message is sent from a source to a single destination node, it is called Unicasting.
If the message is sent to some subset of other nodes, it is called Multicasting.
If the message is sent to all the m nodes in the network it is called Broadcasting.
T

22. What is Multiplexing?


I

Multiplexing is the set of techniques that allows the simultaneous transmission of


E

multiple signals across a single data link.


I
N

23. Name the categories of Multiplexing?


a. Frequency Division Multiplexing (FDM)
b. Time Division Multiplexing (TDM)
   i. Synchronous TDM
   ii. ASynchronous TDM Or Statistical TDM.
c. Wave Division Multiplexing (WDM)
24. 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.
25. What is WDM?
WDM is conceptually the same as FDM, except that the multiplexing and demultiplexing
involve light signals transmitted through fiber optics channel.
26. 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.
27. What is Synchronous TDM?

74
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.
28. List the layers of OSI
a. Physical Layer
b. Data Link Layer
c. Network Layer
d. Transport Layer
e. Session Layer
f. Presentation Layer
g. Application Layer
29. Which layers are network support layers?
a. Physical Layer
b. Data link Layer and 
c. Network Layers
30. Which layers are user support layers?
a. Session Layer
T

b. Presentation Layer and 


I

c. Application Layer
E

31. Which layer links the network support layers and user support layers?
I
N

The Transport layer links the network support layers and user support layers.
32. What are the concerns of the Physical Layer?
Physical layer coordinates the functions required to transmit a bit stream over a physical
medium.
a. Physical characteristics of interfaces and media
b. Representation of bits
c. Data rate
d. Synchronization of bits
e. Line configuration
f. Physical topology
g. Transmission mode
33. What are the responsibilities of Data Link Layer?
The Data Link Layer transforms the physical layer, a raw transmission facility, to a
reliable link and is responsible for node-node delivery.
a. Framing
b. Physical Addressing
c. Flow Control

75
d. Error Control
e. Access Control
34. What are the responsibilities of Network Layer?
The Network Layer is responsible for the source-to-destination delivery of packet
possibly across multiple networks (links).
a. Logical Addressing
b. Routing
35. What are the responsibilities of Transport Layer?
The Transport Layer is responsible for source-to-destination delivery of the entire
message.
a. Service-point Addressing
b. Segmentation and reassembly
c. Connection Control
d. Flow Control
e. Error Control
36. What are the responsibilities of Session Layer?
T

The Session layer is the network dialog Controller. It establishes, maintains and
I

synchronizes the interaction between the communicating systems.


E

a. Dialog control
I
N

b. Synchronization
37. What are the responsibilities of Presentation Layer?
The Presentation layer is concerned with the syntax and semantics of the information
exchanged between two systems.
a. Translation
b. Encryption
c. Compression
38. What are the responsibilities of Application Layer?
The Application Layer enables the user, whether human or software, to access the
network. It provides user interfaces and support for services such as e-mail, shared
database management and other types of distributed information services.
a. Network virtual Terminal
b. File transfer, access and Management (FTAM)
c. Mail services
d. Directory Services
39. What are the two classes of hardware building blocks?
Nodes and Links.

76
40. What are the different link types used to build a computer network?
a. Cables
b. Leased Lines
c. Last-Mile Links
d. Wireless Links
41. What are the categories of Transmission media?
a. Guided Media
  i. Twisted - Pair cable
    1. Shielded TP
    2. Unshielded TP
  ii. Coaxial Cable
  iii. Fiber-optic cable
b. Unguided Media
  i. Terrestrial microwave
  ii. Satellite Communication
42. What are the types of errors?
T

a. Single-Bit error
I

  In a single-bit error, only one bit in the data unit has changed
E

b. Burst Error
I
N

  A Burst error means that two or more bits in the data have changed.
43. What is Error Detection? What are its methods?
Data can be corrupted during transmission. For reliable communication errors must be
deducted and Corrected. Error Detection uses the concept of redundancy, which means
adding extra bits for detecting errors at the destination. The common Error Detection
methods are 
  a. Vertical Redundancy Check (VRC)
  b. Longitudinal Redundancy Check (VRC)
  c. Cyclic Redundancy Check (VRC)
  d. Checksum
44. What is Redundancy?
The concept of including extra information in the transmission solely for the purpose of
comparison. This technique is called redundancy.
45. What is VRC?
It is the most common and least expensive mechanism for Error Detection. In VRC, a
parity bit is added to every data unit so that the total number of 1s becomes even for
even parity. It can detect all single-bit errors. It can detect burst errors only if the total

77
number of errors in each data unit is odd.
46. What is LRC?
In LRC, a block of bits is divided into rows and a redundant row of bits is added to the
whole block. It can detect burst errors. If two bits in one data unit are damaged and bits
in exactly the same positions in another data unit are also damaged, the LRC checker will
not detect an error. In LRC a redundant data unit follows n data units.
47. What is CRC?
CRC, is the most powerful of the redundancy checking techniques, is based on binary
division.
48. What is Checksum?
Checksum is used by the higher layer protocols (TCP/IP) for error detection
49. List the steps involved in creating the checksum.
a. Divide the data into sections
b. Add the sections together using 1's complement arithmetic
c. Take the complement of the final sum, this is the checksum.
50. What are the Data link protocols?
T

Data link protocols are sets of specifications used to implement the data link layer. The
I

categories of Data Link protocols are 1. Asynchronous Protocols


E

2. Synchronous Protocols
I
N

  a. Character Oriented Protocols


  b. Bit Oriented protocols
51. Compare Error Detection and Error Correction:
The correction of errors is more difficult than the detection. In error detection, checks
only any error has occurred. In error correction, the exact number of bits that are
corrupted and location in the message are known. The number of the errors and the size
of the message are important factors.
52. What is Forward Error Correction?
Forward error correction is the process in which the receiver tries to guess the message
by using redundant bits.
53. Define Retransmission?
Retransmission is a technique in which the receiver detects the occurrence of an error
and asks the sender to resend the message. Resending is repeated until a message
arrives that the receiver believes is error-freed.
54. What are Data Words?
In block coding, we divide our message into blocks, each of k bits, called datawords. The
block coding process is one-to-one. The same dataword is always encoded as the same

78
codeword.
55. What are Code Words?
"r" redundant bits are added to each block to make the length n = k + r. The resulting n-bit
blocks are called codewords. 2n - 2k codewords that are not used. These codewords are
invalid or illegal.
56. What is a Linear Block Code?
A linear block code is a code in which the exclusive OR (addition modulo-2) of two valid
codewords creates another valid codeword.
57. What are Cyclic Codes?
Cyclic codes are special linear block codes with one extra property. In a cyclic code, if a
codeword is cyclically shifted (rotated), the result is another codeword.
58. Define Encoder?
A device or program that uses predefined algorithms to encode, or compress audio or
video data for storage or transmission use. A circuit that is used to convert between
digital video and analog video.
59. Define Decoder?
T

A device or program that translates encoded data into its original format (e.g. it decodes
I

the data). The term is often used in reference to MPEG-2 video and sound data, which
E

must be decoded before it is output.


I
N

60. What is Framing?


Framing in the data link layer separates a message from one source to a destination, or
from other messages to other destinations, by adding a sender address and a
destination address. The destination address defines where the packet has to go and the
sender address helps the recipient acknowledge the receipt.
61. What is Fixed Size Framing?
In fixed-size framing, there is no need for defining the boundaries of the frames. The size
itself can be used as a delimiter.
62. Define Character Stuffing?
In byte stuffing (or character stuffing), a special byte is added to the data section of the
frame when there is a character with the same pattern as the flag. The data section is
stuffed with an extra byte. This byte is usually called the escape character (ESC), which
has a predefined bit pattern. Whenever the receiver encounters the ESC character, it
removes it from the data section and treats the next character as data, not a delimiting
flag.
63. What is Bit Stuffing?
Bit stuffing is the process of adding one extra 0 whenever five consecutive Is follow a 0

79
in the data, so that the receiver does not mistake the pattern 0111110 for a flag.
64. What is Flow Control?
Flow control refers to a set of procedures used to restrict the amount of data that the
sender can send before waiting for acknowledgment.
65. What is Error Control ?
Error control is both error detection and error correction. It allows the receiver to inform
the sender of any frames lost or damaged in transmission and coordinates the
retransmission of those frames by the sender. In the data link layer, the term error
control refers primarily to methods of error detection and retransmission.
66. What Automatic Repeat Request (ARQ)?
Error control is both error detection and error correction. It allows the receiver to inform
the sender of any frames lost or damaged in transmission and coordinates the
retransmission of those frames by the sender. In the data link layer, the term error
control refers primarily to methods of error detection and retransmission. Error control in
the data link layer is often implemented simply: Any time an error is detected in an
exchange, specified frames are retransmitted. This process is called automatic repeat
T

request (ARQ).
I

67. What is Stop-and-Wait Protocol?


E

In Stop and wait protocol, sender sends one frame, waits until it receives confirmation
I
N

from the receiver (okay to go ahead), and then sends the next frame.
68. What is Stop-and-Wait Automatic Repeat Request?
Error correction in Stop-and-Wait ARQ is done by keeping a copy of the sent frame and
retransmitting of the frame when the timer expires.
69. What is usage of Sequence Number in Relaible Transmission?
The protocol specifies that frames need to be numbered. This is done by using sequence
numbers. A field is added to the data frame to hold the sequence number of that frame.
Since we want to minimize the frame size, the smallest range that provides
unambiguous communication. The sequence numbers can wrap around.
70. What is Pipelining ?
In networking and in other areas, a task is often begun before the previous task has
ended. This is known as pipelining.
71. What is Sliding Window?
The sliding window is an abstract concept that defines the range of sequence numbers
that is the concern of the sender and receiver. In other words, he sender and receiver
need to deal with only part of the possible sequence numbers.
72. What is Piggy Backing?

80
A technique called piggybacking is used to improve the efficiency of the bidirectional
protocols. When a frame is carrying data from A to B, it can also carry control
information about arrived (or lost) frames from B; when a frame is carrying data from B
to A, it can also carry control information about the arrived (or lost) frames from A.
73. What are the two types of transmission technology available?
(i) Broadcast and (ii) point-to-point
74. What is subnet?
A generic term for section of a large networks usually separated by a bridge or router.
75. Difference between the communication and transmission.
Transmission is a physical movement of information and concern issues like bit polarity,
synchronisation, clock etc.
Communication means the meaning full exchange of information between two
communication media.
76. What are the possible ways of data exchange?
(i) Simplex (ii) Half-duplex (iii) Full-duplex.
77. What is SAP?
T

Series of interface points that allow other computers to communicate with the other
I

layers of network protocol stack.


E

78. What do you meant by "triple X" in Networks?


I
N

The function of PAD (Packet Assembler Disassembler) is described in a document


known as X.3. The standard protocol has been defined between the terminal and the
PAD, called X.28; another standard protocol exists between hte PAD and the network,
called X.29. Together, these three recommendations are often called "triple X".
79. What is frame relay, in which layer it comes?
Frame relay is a packet switching technology. It will operate in the data link layer.
80. What is terminal emulation, in which layer it comes?
Telnet is also called as terminal emulation. It belongs to application layer.
81. What is Beaconing?
The process that allows a network to self-repair networks problems. The stations on the
network notify the other stations on the ring when they are not receiving the
transmissions. Beaconing is used in Token ring and FDDI networks.
82. What is redirector?
Redirector is software that intercepts file or prints I/O requests and translates them into
network requests. This comes under presentation layer.
83. What is NETBIOS and NETBEUI?
NETBIOS is a programming interface that allows I/O requests to be sent to and received

81
from a remote computer and it hides the networking hardware from applications.
NETBEUI is NetBIOS extended user interface. A transport protocol designed by microsoft
and IBM for the use on small subnets.
84. What is RAID?
A method for providing fault tolerance by using multiple hard disk drives.
85. What is passive topology?
When the computers on the network simply listen and receive the signal, they are
referred to as passive because they don't amplify the signal in any way. Example for
passive topology -linear bus.
86. What is router?
Hybrid devices that combine the features of both bridges and routers.
87. What is cladding?
A layer of a glass surrounding the center fiber of glass inside a fiber-optic cable.
88. What is point-to-point protocol?
A communications protocol used to connect computers to remote networking services
including Internet service providers.
T

89. How Gateway is different from Routers?


I

A gateway operates at the upper levels of the OSI model and translates information
E

between two completely different network architectures or data formats.


I
N

90. What is attenuation?


The degeneration of a signal over distance on a network cable is called attenuation.
91. What is MAC address?
The address for a device as it is identified at the Media Access Control (MAC) layer in
the network architecture. MAC address is usually stored in ROM on the network adapter
card and is unique.
92. Difference between bit rate and baud rate.
Bit rate is the number of bits transmitted during one second whereas baud rate refers to
the number of signal units per second that are required to represent those bits.
  baud rate = (bit rate / N)
  where N is no-of-bits represented by each signal shift.
93. What is Bandwidth?
Every line has an upper limit and a lower limit on the frequency of signals it can carry.
This limited range is called the bandwidth.
94. What are the types of Transmission media?

82
Signals are usually transmitted over some transmission media that are broadly
classified in to two categories.
a.) Guided Media: These are those that provide a conduit from one device to another that
include twisted-pair, coaxial cable and fiber-optic cable. A signal traveling along any of
these media is directed and is contained by the physical limits of the medium.
Twisted-pair and coaxial cable use metallic that accept and transport signals in the form
of electrical current. Optical fiber is a glass or plastic cable that accepts and transports
signals in the form of light.
b.) Unguided Media: This is the wireless media that transport electromagnetic waves
without using a physical conductor. Signals are broadcast either through air. This is
done through radio communication, satellite communication and cellular telephony.
95. What is Project 802?
It is a project started by IEEE to set standards to enable intercommunication between
equipment from a variety of manufacturers. It is a way for specifying functions of the
physical layer, the data link layer and to some extent the network layer to allow for
T

interconnectivity of major LAN protocols.


I

It consists of the following:


E
I

1.    802.1 is an internetworking standard for compatibility of different LANs and MANs
N

across protocols.
2.    802.2 Logical link control (LLC) is the upper sublayer of the data link layer which is
non-architecture-specific, that is remains the same for all IEEE-defined LANs.
3.    Media access control (MAC) is the lower sublayer of the data link layer that contains
some distinct modules each carrying proprietary information specific to the LAN product
being used. The modules are Ethernet LAN (802.3), Token ring LAN (802.4), Token bus
LAN (802.5).
4.    802.6 is distributed queue dual bus (DQDB) designed to be used in MANs.
96. What is Protocol Data Unit?
The data unit in the LLC level is called the protocol data unit (PDU). The PDU contains of
four fields a destination service access point (DSAP), a source service access point
(SSAP), a control field and an information field. DSAP, SSAP are addresses used by the
LLC to identify the protocol stacks on the receiving and sending machines that are
generating and using the data. The control field specifies whether the PDU frame is a
information frame (I - frame) or a supervisory frame (S - frame) or a unnumbered frame

83
(U - frame).
97. What are the different type of networking / internetworking devices?
1.    Repeater: Also called a regenerator, it is an electronic device that operates only at
physical layer. It receives the signal in the network before it becomes weak, regenerates
the original bit pattern and puts the refreshed copy back in to the link.
2.    Bridges: These operate both in the physical and data link layers of LANs of same
type. They divide a larger network in to smaller segments. They contain logic that allow
them to keep the traffic for each segment separate and thus are repeaters that relay a
frame only the side of the segment containing the intended recipent and control
congestion.
3.    Routers: They relay packets among multiple interconnected networks (i.e. LANs of
different type). They operate in the physical, data link and network layers. They contain
software that enable them to determine which of the several possible paths is the best
for a particular transmission.
4.    Gateways: They relay packets among networks that have different protocols (e.g.
T

between a LAN and a WAN). They accept a packet formatted for one protocol and
I

convert it to a packet formatted for another protocol before forwarding it. They operate
E
I

in all seven layers of the OSI model.


N

98. What is ICMP?


ICMP is Internet Control Message Protocol, a network layer protocol of the TCP/IP suite
used by hosts and gateways to send notification of datagram problems back to the
sender. It uses the echo test / reply to test whether a destination is reachable and
responding. It also handles both control and error messages.
99. What are the data units at different layers of the TCP / IP protocol suite?
The data unit created at the application layer is called a message, at the transport layer
the data unit created is called either a segment or an user datagram, at the network layer
the data unit created is called the datagram, at the data link layer the datagram is
encapsulated in to a frame and finally transmitted as signals along the transmission
media.
100. What is difference between ARP and RARP?
The address resolution protocol (ARP) is used to associate the 32 bit IP address with the
48 bit physical address, used by a host or a router to find the physical address of another
host on its network by sending a ARP query packet that includes the IP address of the

84
receiver.
The reverse address resolution protocol (RARP) allows a host to discover its Internet
address when it knows only its physical address.
101. What is the minimum and maximum length of the header in the TCP segment and IP
datagram?
The header should have a minimum length of 20 bytes and can have a maximum length
of 60 bytes.
102. What is the range of addresses in the classes of internet addresses?
Class A   -       0.0.0.0   -   127.255.255.255
Class B   -   128.0.0.0   -   191.255.255.255
Class C   -   192.0.0.0   -   223.255.255.255
Class D   -   224.0.0.0   -   239.255.255.255
Class E   -   240.0.0.0   -   247.255.255.255
103. What is the difference between TFTP and FTP application layer protocols?
The Trivial File Transfer Protocol (TFTP) allows a local host to obtain files from a remote
T
I

host but does not provide reliability or security. It uses the fundamental packet delivery
E

services offered by UDP.


I
N

The File Transfer Protocol (FTP) is the standard mechanism provided by TCP / IP for
copying a file from one host to another. It uses the services offer by TCP and so is
reliable and secure. It establishes two connections (virtual circuits) between the hosts,
one for data transfer and another for control information.
104. What are major types of networks and explain?
1.    Server-based network: provide centralized control of network resources and rely on
server computers to provide security and network administration
2.    Peer-to-peer network: computers can act as both servers sharing resources and as
clients using the resources.
105. What are the important topologies for networks?
1.    BUS topology: In this each computer is directly connected to primary network cable in a
single line.
Advantages: Inexpensive, easy to install, simple to understand, easy to extend.
2.    STAR topology: In this all computers are connected using a central hub.
Advantages: Can be inexpensive, easy to install and reconfigure and easy to trouble

85
shoot physical problems.
3.    RING topology: In this all computers are connected in loop. Advantages: All computers
have equal access to network media, installation can be simple, and signal does not
degrade as much as in other topologies because each computer regenerates it.
106. What is mesh network?
A network in which there are multiple network links between computers to provide
multiple paths for data to travel.
107. What is difference between baseband and broadband transmission?
In a baseband transmission, the entire bandwidth of the cable is consumed by a single
signal. In broadband transmission, signals are sent on multiple frequencies, allowing
multiple signals to be sent simultaneously.
108. Explain 5-4-3 rule?
In a Ethernet network, between any two points on the network ,there can be no more than
five network segments or four repeaters, and of those five segments only three of
segments can be populated.
T
I

109. What MAU?


E

In token Ring , hub is called Multistation Access Unit(MAU).


I

110. What is the difference between routable and non- routable protocols?
N

Routable protocols can work with a router and can be used to build large networks.
Non-Routable protocols are designed to work on small, local networks and cannot be
used with a router.
111. Why should you care about the OSI Reference Model?
It provides a framework for discussing network operations and design.
112. What is logical link control?
One of two sub layers of the data link layer of OSI reference model, as defined by the
IEEE 802 standard. This sub layer is responsible for maintaining the link between
computers when they are sending data across the physical network connection.
113. What is virtual channel?
Virtual channel is normally a connection from one source to one destination, although
multicast connections are also permitted. The other name for virtual channel is virtual
circuit.
114. What is virtual path?
Along any transmission path from a given source to a given destination, a group of
virtual circuits can be grouped together into what is called path.

86
115. What is packet filter?
Packet filter is a standard router equipped with some extra functionality. The extra
functionality allows every incoming or outgoing packet to be inspected. Packets meeting
some criterion are forwarded normally. Those that fail the test are dropped.
116. What is traffic shaping?
One of the main causes of congestion is that traffic is often busy. If hosts could be made
to transmit at a uniform rate, congestion would be less common. Another open loop
method to help manage congestion is forcing the packet to be transmitted at a more
predictable rate. This is called traffic shaping.
117. What is multicast routing?
Sending a message to a group is called multicasting, and its routing algorithm is called
multicast routing.
118. What is region?
When hierarchical routing is used, the routers are divided into what we will call regions,
with each router knowing all the details about how to route packets to destinations
within its own region, but knowing nothing about the internal structure of other regions.
T

119. What is silly window syndrome?


I

It is a problem that can ruin TCP performance. This problem occurs when data are
E

passed to the sending TCP entity in large blocks, but an interactive application on the
I
N

receiving side reads 1 byte at a time.


120. What are Digrams and Trigrams?
The most common two letter combinations are called as digrams. e.g. th, in, er, re and
an. The most common three letter combinations are called as trigrams. e.g. the, ing, and,
and ion.
121. Expand IDEA.
IDEA stands for International Data Encryption Algorithm.
122. What is wide-mouth frog?
Wide-mouth frog is the simplest known key distribution center (KDC) authentication
protocol.
123. What is Mail Gateway?
It is a system that performs a protocol translation between different electronic mail
delivery protocols.
124. What is IGP (Interior Gateway Protocol)?
It is any routing protocol used within an autonomous system.
125. What is EGP (Exterior Gateway Protocol)?
It is the protocol the routers in neighboring autonomous systems use to identify the set

87
of networks that can be reached within or via each autonomous system.
126. What is autonomous system?
It is a collection of routers under the control of a single administrative authority and that
uses a common Interior Gateway Protocol.

127. What is BGP (Border Gateway Protocol)?


It is a protocol used to advertise the set of networks that can be reached with in an
autonomous system. BGP enables this information to be shared with the autonomous
system. This is newer than EGP (Exterior Gateway Protocol).
128. What is Gateway-to-Gateway protocol?
It is a protocol formerly used to exchange routing information between Internet core
routers.
129. What is NVT (Network Virtual Terminal)?
It is a set of rules defining a very simple virtual terminal interaction. The NVT is used in
the start of a Telnet session.
T

130. What is a Multi-homed Host?


I

It is a host that has a multiple network interfaces and that requires multiple IP addresses
E

is called as a Multi-homed Host.


I
N

131. What is Kerberos?


It is an authentication service developed at the Massachusetts Institute of Technology.
Kerberos uses encryption to prevent intruders from discovering passwords and gaining
unauthorized access to files.
132. What is OSPF?
It is an Internet routing protocol that scales well, can route traffic along multiple paths,
and uses knowledge of an Internet's topology to make accurate routing decisions.
133. What is Proxy ARP?
It is using a router to answer ARP requests. This will be done when the originating host
believes that a destination is local, when in fact is lies beyond router.
134. What is SLIP (Serial Line Interface Protocol)?
It is a very simple protocol used for transmission of IP datagrams across a serial line.
135. What is RIP (Routing Information Protocol)?
It is a simple protocol used to exchange information between the routers.
136. What is source route?
It is a sequence of IP addresses identifying the route a datagram must follow. A source
route may optionally be included in an IP datagram header.

88
N
E
I
T
I

89
Sample Questions

1. Write a program for a HLDC frame to perform the following and execute with example.
i) Bit stuffing
ii) Character stuffing.

2. Write a program for distance vector algorithm to find suitable path for
Transmission execute with example using graph below.

T
I

3. Implement Dijkstra’s algorithm to compute the shortest routing path AND execute with
E
I

example using Network-graph below.


N

4. For the given data, use CRC-CCITT polynomial to obtain CRC code. Verify the
program for the cases execute with example.
a. Without error
b. With error

90
5. Implementation of Stop and Wait Protocol and Sliding Window Protocol execute with
example.

6. Write a program for congestion control using leaky bucket algorithm execute with
example.
7.Implement a point to point network with four nodes and duplex links between them.
Analyse the network performance by setting the queue size and varying the bandwidth
and simulate.

8. 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 and simulate.

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


T
I

changing the error rate and data rate and simulate.


E
I

10. Implement Ethernet LAN using n nodes and assign multiple traffic to the nodes and
N

obtain congestion window for different sources/ destinations and simulate.

11. Implement ESS with transmission nodes in Wireless LAN and obtain the
performance parameters and simulate.

12. Implementation of Link state routing algorithm and simulate.

91

You might also like