0% found this document useful (0 votes)
23 views8 pages

Network Lab Exp 5

The document outlines a practical lab exercise focused on creating a ring topology using NS2, detailing the characteristics, advantages, and disadvantages of ring topology in computer networking. It includes a simulation script in Tcl that sets up six nodes in a ring configuration, facilitating TCP traffic between them. The lab concludes with a summary of outcomes and a series of post-lab exercises to reinforce understanding of ring topology concepts.

Uploaded by

mrunmayee botale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views8 pages

Network Lab Exp 5

The document outlines a practical lab exercise focused on creating a ring topology using NS2, detailing the characteristics, advantages, and disadvantages of ring topology in computer networking. It includes a simulation script in Tcl that sets up six nodes in a ring configuration, facilitating TCP traffic between them. The lab concludes with a summary of outcomes and a series of post-lab exercises to reinforce understanding of ring topology concepts.

Uploaded by

mrunmayee botale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Practical No.

Name of the Student: Mrunmayee Botale

Roll No.: A53


Batch: A3

Module Name: Network Lab Module Code: ITL402

Aim: Creation of Ring Topology using NS2

Lab Objective: To implement client server socket programming

Resources Used: Ubuntu Command Prompt

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.

Here's a breakdown of the key aspects and characteristics of ring topology:

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:

Set ns [new Simulator]


set nf [open out.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit 0
}

set no [$ns node]


set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

$ns duplex-link $no $n1 1Mb 10ms DropTail


$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n2 $n3 1Mb 10ms DropTail
$ns duplex-link $n3 $n4 1Mb 10ms DropTail
$ns duplex-link $n4 $n5 1Mb 10ms DropTail
$ns duplex-link $n5 $n0 1Mb 10ms DropTail

set tcp0 [new Agent/TCP]


$tcp0 set class_ 1
$ns attach-agent $n1 $tcp0
set sink0 [new Agent/TCPSink]
$ns attach-agent $n4 $sinko
$ns connect $tcpo $sinko
set cbr0 [new Application/Traffic/CBR]
$cbro set packetsize_ 500
$cbro set interval_0.01
$cbro attach-agent $tcpo
$ns at 0.5 "$cbro start"
$ns at 4.5 "$cbr0 stop"
$ns at 5.0 "finish"
$ns run

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.

Let’s break down the script step by step:

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.

13.Running Simulation: The simulation is initiated using the ”run” command.

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:

Lab Outcome: To implement socket programming for server architecture


Conclusion: After completing this experiment, we learnt about node creation and making link between
them.

Post lab Exercise:


1. What is the primary characteristic of a ring topology?
a) Each device is connected to every other device
b) Each device is connected to two other devices, forming a circle
c) Each device is connected to a central device
d) Each device is connected to a bus

Answer: b) Each device is connected to two other devices, forming a circle


2. What is the main advantage of a ring topology?
a) Easy to install and maintain
b) High-speed data transfer
c) Fault tolerance
d) All of the above

Answer: b) High-speed data transfer

3. What happens when a device in a ring topology fails?


a) The entire network goes down
b) The network continues to function, but with reduced performance
c) The failed device is bypassed, and the network continues to function
d) The network is automatically reconfigured to bypass the failed device

Answer: a) The entire network goes down

4. Which of the following is a disadvantage of a ring topology?


a) Difficult to install and maintain
b) Expensive to implement
c) Limited scalability
d) All of the above

Answer: d) All of the above

5. What type of cable is commonly used in a ring topology?


a) Twisted pair
b) Coaxial
c) Fiber optic
d) Ethernet

Answer: c) Fiber optic

6. Which protocol is commonly used in ring topologies?


a) TCP/IP
b) HTTP
c) Token Ring
d) FTP

Answer: c) Token Ring

7. What is the purpose of a token in a ring topology?


a) To prioritize data packets
b) To manage network traffic
c) To prevent data collisions
d) To grant access to the network

Answer: d) To grant access to the network

8. How does data transmission occur in a ring topology?


a) Data is transmitted in a linear sequence
b) Data is transmitted in a circular sequence
c) Data is transmitted through a central device
d) Data is transmitted through a switch

Answer: b) Data is transmitted in a circular sequence

You might also like