Network Lab Exp 5
Network Lab Exp 5
Theory:
In computer networking, a ring topology is a type of network configuration where each network
device is connected to exactly two other devices, forming a continuous loop or ring. Data travels
around the ring in one direction, passing through each device until it reaches its destination. Ring
topologies were popular in the past but are less common today due to the prevalence of other
topologies like star and mesh.
1. Physical Layout: In a ring topology, devices are connected in a closed loop or ring. Each
device is connected directly to two other devices, forming a continuous pathway for data
transmission.
2. Unidirectional Data Flow: Data travels around the ring in one direction only. Each device in the
ring receives data from one neighbor and forwards it to the next until it reaches its destination.
This unidirectional flow helps to prevent collisions and ensures orderly data transmission.
3. Token Passing: In many ring topologies, a special token is circulated around the ring. Only
the device that holds the token is allowed to transmit data onto the network. This mechanism
helps regulate data flow and prevent data collisions.
4. Reliability: Ring topologies can offer high reliability because data can still flow through the
network even if one device fails. However, if the central connecting cable (the ring) is severed or
a device malfunctions, the entire network can be disrupted.
5. Scalability: Ring topologies can be less scalable compared to other topologies like star or
mesh. Adding or removing devices can be more complicated, as it requires reconfiguring the
entire ring.
6. Performance: Ring topologies can offer good performance under light to moderate network
loads. However, as the number of devices increases or network traffic becomes heavy,
performance can degrade due to the token passing mechanism and the shared bandwidth of the
ring.
7. Examples: Token Ring, developed by IBM, is a well-known example of a ring topology network
protocol. It was widely used in the past but has largely been replaced by Ethernet and other
technologies.
In summary, a ring topology provides a simple and reliable network configuration with orderly
data transmission. However, it may not be as flexible or scalable as other topologies, and its
performance can be impacted under heavy network loads.
Program:
This program is a simulation script written in the Tcl (Tool Command Language) programming
language using the ns (Network Simulator) tool. It simulates a simple network scenario with six
nodes connected in a ring topology, where TCP traffic is generated from one node and received
by another node.
1. Creating Simulator Object: The script starts by creating a new simulator object named "ns"
using the "new Simulator" command.
2. Opening Trace File: It then opens a trace file named "out.nam" in write mode using the
"open" command.
3. Configuring Nam Trace: The "namtrace-all" command is used to instruct the simulator to
trace all events to the opened trace file.
4. Defining Finish Procedure: A Tcl procedure named "finish” is defined. This procedure is
responsible for flushing the trace, closing the trace file, executing the nam visualization tool
('nam') on the trace file, and exiting the simulation.
5. Creating Nodes: Six nodes (n0 to n5) are created using the "node" command.
6. Creating Links: Duplex links are established between each pair of adjacent nodes using the
"duplex-link" command. Each link has a bandwidth of 1Mb and a delay of 10ms.
7. Creating TCP Agent: An instance of the TCP agent ("Agent/TCP") is created and attached
to node n1 using the "attach-agent" command.
8. Creating TCP Sink Agent: An instance of the TCP Sink agent ("Agent/TCPSink") is created and
attached to node n4.
9. Connecting Traffic Sources with Sink: The TCP agent created earlier is connected to the
TCP Sink agent using the "connect" command.Creating CBR Traffic Source: A Constant Bit
Rate (CBR) traffic source ('Application/Traffic/CBR') is created and attached to the TCP
agent.
10.Configuring CBR Traffic Source: The packet size and interval of the CBR traffic source are
set using the ”set” command.
11.Scheduling Events: Events for starting and stopping the CBR traffic source are scheduled
using the ”at” command.
12.Calling Finish Procedure: The ”finish” procedure is scheduled to be called after 5 seconds of
simulation time.
Overall, this script sets up a simple network simulation with TCP traffic generated from one node
and received by another node, while capturing simulation events in a trace file for visualization
using the nam tool.
INPUT:-
Output: