Computer network lab manual
Computer network lab manual
Objective:
Software Requirements:
1. Open Terminal
2. Install Required Dependencies:
❖ bash
❖ CopyEdit
❖ sudo apt-get update
sudo apt-get install build-essential autoconf automake libxmu-dev
Then run:
❖ bash
❖ CopyEdit
❖ source ~/.bashrc
7. Verify Installation:
❖ bash
❖ CopyEdit
❖ ns
Note: QualNet is a commercial simulator. Make sure you have a valid license or trial version.
1. Download QualNet:
a. From official site: https://web.scalable-networks.com
2. Install the Software:
a. Run the installer and follow the instructions.
b. Choose the required components (e.g., Developer Mode, GUI, etc.)
3. License Setup:
a. Place the license file in the required directory.
b. Configure the license in the QualNet_License_Manager.
4. Verify Installation:
a. Open QualNet GUI
b. Run sample simulation scenarios to verify successful configuration
Practical-2
Aim: Creating a network: nodes, links and queues, Creating connections, traffic and computing
routers Insertion of errors and analysis of trace file.
# Create simulator object
# Create nodes
# Finish procedure
proc finish {} {
$ns flush-trace
close $tracefile
close $namfile
exit 0
# Schedule finish
# Run simulation
$ns run
Output:
Practical-3
Objective:
To understand and use basic network and configuration commands used for diagnosing and managing network
settings in Linux and Windows operating systems.
Software Requirements:
Tool/OS Version
Windows 10/11
Linux Ubuntu 20.04 or later
Terminal/Command Prompt -
On Linux:
Command Purpose
Enable or disable network
sudo ifconfig eth0 up/down
interface
Get IP address from DHCP
sudo dhclient
server
nmcli or nmtui Manage network connections
ip route View routing table
sudo ip link set eth0 address XX:XX:XX:XX:XX:XX Set MAC address
On Windows:
Command Purpose
netsh interface ip set address Manually configure IP address
netsh interface show interface Show all interfaces
netsh wlan show profile Display saved Wi-Fi profiles
netsh winsock reset Reset TCP/IP stack
route print Show routing table
Procedure:
bash
CopyEdit
ping www.google.com
ifconfig
traceroute www.google.com
nslookup www.example.com
ip route
cmd
CopyEdit
ping www.google.com
ipconfig
tracert www.google.com
nslookup www.example.com
netstat -an
Observations:
Command Output Summary Use
ping google.com Successful response from IP Checks connectivity
ipconfig Shows IPv4, gateway View network settings
netstat -an Shows listening ports Check open connections
Result:
Successfully studied and executed basic network and configuration commands. Gained practical experience in
monitoring and managing network settings.
Practical-4
Aim: Simple project on NS2 – wired, wireless and combination of wired and wireless.
#Wired:
set ns [new Simulator]
set nf [open wired.nam w]
$ns namtrace-all $nf
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
$tcp set fid_ 1
set sink [new Agent/TCPSink]
$ns attach-agent $n2 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 0.5 "$ftp start"
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam wired.nam &
exit 0
}
$ns at 5.0 "finish"
$ns run
Output:
#Wireless:
# Create simulator
set ns [new Simulator]
# Create a wireless channel
set chan_ [new Channel/WirelessChannel]
# Create trace files
set tracefile [open wireless_trace.tr w]
$ns trace-all $tracefile
set namfile [open wireless.nam w]
$ns namtrace-all-wireless $namfile 500 500
# Define topology
set topo [new Topography]
$topo load_flatgrid 500 500
# Create General Operations Director
create-god 2
# Configure wireless nodes
$ns node-config -adhocRouting AODV \
-llType LL \
-macType Mac/802_11 \
-ifqType Queue/DropTail \
-ifqLen 50 \
-antType Antenna/OmniAntenna \
-propType Propagation/TwoRayGround \
-phyType Phy/WirelessPhy \
-channel $chan_ \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF
# Create nodes
set n0 [$ns node]
set n1 [$ns node]
# Set static node positions (no mobility)
$n0 set X_ 100; $n0 set Y_ 100; $n0 set Z_ 0
$n1 set X_ 200; $n1 set Y_ 100; $n1 set Z_ 0
$ns initial_node_pos $n0 20
$ns initial_node_pos $n1 20
# Create UDP agent and attach to n0
set udp [new Agent/UDP]
$ns attach-agent $n0 $udp
# Create null agent and attach to n1
set null [new Agent/Null]
$ns attach-agent $n1 $null
# Connect the agents
$ns connect $udp $null
# Add CBR traffic source
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 500
$cbr set interval_ 0.01
$cbr set maxpkts_ 1000
$cbr attach-agent $udp
# Start the traffic
$ns at 1.0 "$cbr start"
# Finish procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam wireless.nam &
exit 0
}
# Schedule finish
$ns at 5.0 "finish"
# Run simulation
$ns run
Output:
import java.io.*;
import java.net.*;
System.out.println("Client connected.");
while (true) {
clientMsg = input.readLine();
if (clientMsg.equalsIgnoreCase("bye")) {
System.out.println("Client disconnected.");
break;
System.out.print("Server: ");
serverMsg = keyboard.readLine();
output.println(serverMsg);
socket.close();
serverSocket.close();
Output:
#Client.java
import java.io.*;
import java.net.*;
System.out.println("Connected to server.");
while (true) {
System.out.print("Client: ");
clientMsg = keyboard.readLine();
output.println(clientMsg);
if (clientMsg.equalsIgnoreCase("bye")) {
break;
serverMsg = input.readLine();
System.out.println("Server: " + serverMsg);
socket.close();
Output: