0% found this document useful (0 votes)
8 views39 pages

Network Design LAB-MANUAL

The document is a lab manual for a second-year IT course focusing on network design, detailing various networking commands in Windows, the installation and configuration of NS2, and simulations using NS2. It includes experiments on basic networking commands, NS2 installation on Windows and Linux, and the simulation of network parameters. Each section provides theoretical background, command syntax, parameters, and procedures for executing experiments.
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)
8 views39 pages

Network Design LAB-MANUAL

The document is a lab manual for a second-year IT course focusing on network design, detailing various networking commands in Windows, the installation and configuration of NS2, and simulations using NS2. It includes experiments on basic networking commands, NS2 installation on Windows and Linux, and the simulation of network parameters. Each section provides theoretical background, command syntax, parameters, and procedures for executing experiments.
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

DEPARTMENT OF INFORMATION TECHNOLOGY

LAB MANUAL
Second Year IT – Semester IV

NETWORK DESIGN LAB [2344115]

ACADEMIC YEAR 2025-26


Experiment No: 01

Aim: -To study basic networking commands in windows operating system.

Software: Windows Command Prompt.

Theory:
i) arp
 This diagnostic command displays and modifies the IP-to-Ethernet or Token Ring physical
address translation tables used by the Address Resolution Protocol (ARP).
 Syntax
arp -a [inet_addr] [-N [if_addr]]
arp -dinet_addr [if_addr]
arp -sinet_addrether_addr [if_addr]
 Parameters
o -a: Displays current ARP entries by querying TCP/IP. If inet_addr is specified, only the IP and
physical Addresses for the specified host are displayed.
o -d:Deletes the entry specified by inet_addr
o -s: adds an entry in the ARP cache to associate the IP address inet_addrwith the physical
address ether_addr.The physical address is given as 6 hexadecimal bytes separated by
hyphens. The IP address is specified using dotted decimal notation. The entry is static. It will
not be automatically removed from the cache after the timeout expires and will not exist after a
reboot of your computer.
o -N [if_addr]:Displays the ARP entries for the network interface specified by if_addr.
ether_addr Specifies a physical address. if_addr Specifies, if present, the IP address of the
interface whose address translation table should be modified. If not present, the first applicable
interface will be used. inet_addr Specifies an IP address in dotted decimal notation.

ii) hostname
 This diagnostic command prints the name of the host on which the command is used.
 Syntax:
hostname -- This command has no parameters.
iii) ipconfig
 This diagnostic command displays all current TCP/IP network configuration values. This
command is useful on computers running DHCP because it enables users to determine which
TCP/IP configuration values have been configured by DHCP. If you enter only ipconfigwithout
parameters, the response is a display of all of the current TCP/IP configuration values, including
IP address, subnet mask, and default gateway.
 Syntax
ipconfig [/all | /renew [adapter] | /release [adapter]]
 Parameters
o all: Produces a full display. Without this switch, ipconfig displays only the IP address, subnet
mask, and default gateway values for each network card.
o renew [adapter]:Renews DHCP configuration parameters. This option is available only on
computers running the DHCP Client service. To specify an adapter name, type the adapter
name that appears when you use ipconfig without parameters.
o release [adapter]:Releases the current DHCP configuration. This option disables TCP/IP on
the local computer and is available only on DHCP clients. To specify an adapter name, type
the adapter name that appears when you use ipconfig without parameters.
iv) netstat
 This diagnostic command displays protocol statistics and current TCP/IP network connections.
 Syntax
netstat [-a] [-e][-n][-s] [-p protocol] [-r] [interval]
 Parameters
o -a:Displays all connections and listening ports; server connections are usually not shown.
o -e: Displays Ethernet statistics. This can be combined with the -s option.
o -n: Displays addresses and port numbers in numerical form (rather than attempting name
lookups).
o -s:Displays per-protocol statistics. By default, statistics are shown for TCP, UDP, ICMP, and
IP; the -p option can be used to specify a subset of the default.
o -p protocol:Shows connections for the protocol specified.
o -r Displays the contents of the routing table.
o Interval:Redisplays selected statistics, pausing interval seconds between each display.
v) ping
 This diagnostic command verifies connections to one or more remote computers.
 Syntax
ping [-t] [-a] [-n count] [-l length] [-f] [-i ttl] [-v tos] [-r count] [-s count]
[[-j host-list] | [-k host-list]] [-w timeout] destination-list
 Parameters
o -t: Pings the specified host until interrupted.
o -a:Resolves addresses to host names.
o -n:count Sends the number of ECHO packets specified by count. The default is 4.
o -l length:Sends ECHO packets containing the amount of data specified by length. The default is
64 bytes; the maximum is 8192.
o -f:Sends a Do Not Fragment flag in the packet. The packet will not be fragmented by gateways on
the route.
o -ittl: Sets the time to live field to the value specified by ttl.
o -v tos: Sets the type of service field to the value specified by tos.
o -r count:Records the route of the outgoing packet and the returning packet in the record route
field. A minimum of 1 to a maximum of 9 hosts must be specified by count.
o -s count: Specifies the timestamp for the number of hops specified by count.
o -j host-list: Routes packets via the list of hosts specified by host-list. Consecutive hosts can be
separated by intermediate gateways (loose source routed). The maximum number allowed by IP is
9.
o -k host-list: Routes packets via the list of hosts specified by host-list. Consecutive hosts cannot be
separated by intermediate gateways (strict source routed). The maximum number allowed by IP is
9.
o -w timeout:Specifies a timeout interval in milliseconds.
o destination-list:Specifies the remote hosts to ping.
vi) route
 This diagnostic command manipulates network routing tables.
 Syntax
route [-f] [command [destination] [MASK netmask] [gateway] [METRIC metric]]
 Parameters
o -f: Clears the routing tables of all gateway entries. If this parameter is used in conjunction with
one of the commands, the tables are cleared prior to running the command.
o command:Specifies one of four commands.

Command Purpose
print Prints a route
add Adds a route
delete Deletes a route
change Modifies an existing route
vii) tracert
 This diagnostic utility determines the route taken to a destination by sending Internet Control
Message Protocol (ICMP) echo packets with varying time-to-live (TTL) values to the destination.
Each router along the path is required to decrement the TTL on a packet by at least 1 before
forwarding it, so the TTL is effectively a hop count. When the TTL on a packet reaches 0, the
router is supposed to send back an ICMP Time Exceeded message to the source computer.
 Tracert determines the route by sending the first echo packet with a TTL of 1 and incrementing the
TTL by 1 on each subsequent transmission until the target responds or the maximum TTL is
reached. The route is determined by examining the ICMP Time Exceeded messages sent back by
intermediate routers. Notice that some routers silently drop packets with expired TTLs and will be
invisible to tracert.
 Syntax
tracert[-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name
 Parameters
o -d: Specifies not to resolve addresses to host names.
o -h maximum_hops: Specifies maximum number of hops to search for target.
o -j host-list:Specifies loose source route along host-list.
o -w timeout :Waits the number of milliseconds specified by timeout for each reply.
o target_name:Name of the target host.
Commands Execution:
Conclusion: This experiment helps us to test different networking commands that helps us to know about
different network parameters.
Experiment No. 2

Aim: To study installation and configuration of NS2.

Software: NS2 (Network Simulator 2)

Theory:
NS is an event driven network simulator developed at UC Berkeley that simulates variety of IP
networks. It implements network protocols such as TCP and UPD, traffic source behavior such as FTP,
Telnet, Web, CBR and VBR, router queue management mechanism such as Drop Tail, RED and CBQ,
routing algorithms such as Dijkstra, and more. NS also implements multicasting and some of the MAC layer
protocols for LAN simulations. The NS project is now a part of the VINT project that develops tools for
simulation results display, analysis and converters that convert network topologies generated by well-known
generators to NS formats. Currently, NS (version 2) written in C++ and OTcl (Tcl script language with
Object-oriented extensions developed at MIT) is available.

Figure 1. Simplified User's View of NS

As shown in Figure 1, in a simplified user's view, NS is Object-oriented Tcl (OTcl) script interpreter that
has a simulation event scheduler and network component object libraries, and network setup (plumbing)
module libraries (actually, plumbing modules are implemented as member functions of the base simulator
object). In other words, to use NS, you program in OTcl script language. To setup and run a simulation
network, a user should write an OTcl script that initiates an event scheduler, sets up the network topology
using the network objects and the plumbing functions in the library, and tells traffic sources when to start
and stop transmitting packets through the event scheduler. The term "plumbing" is used for a network setup,
because setting up a network is plumbing possible data paths among network objects by setting the
"neighbor" pointer of an object to the address of an appropriate object. When a user wants to make a new
network object, he or she can easily make an object either by writing a new object or by making a
compound object from the object library, and plumb the data path through the object.

Another major component of NS beside network objects is the event scheduler. An event in NS is a packet
ID that is unique for a packet with scheduled time and the pointer to an object that handles the event. In NS,
an event scheduler keeps track of simulation time and fires allthe events in the event queue scheduled for the
current time by invoking appropriate network components, which usually are the ones who issued the
events, and let them do the appropriate action associated with packet pointed by the event.
Network components communicate with one another passing packets;however, this does not consume actual
simulation time. All the network components that need to spend some simulation time handling a packet
(i.e. need a delay) use the event scheduler by issuing an event for the packet and waiting for the event to be
fired to itself before doing further action handling the packet. For example, a network switch component
that simulates a switch with 20 microseconds of switching delay issues an event for a packet to be switched
to the scheduler as an event 20 microsecond later. The scheduler after 20 microsecond dequeues the event
and fires it to the switch component, which then passes the packet to an appropriate output link component.
Another use of an event scheduler is timer. For example, TCP needs a timer to keep track of a packet
transmission time out for retransmission (transmission of a packet with the same TCP packet number but
different NS packet ID). Timers use event schedulers in a similar manner that delay does. The only
difference is that timer measures a time value associated with a packet and does an appropriate action
related to that packet after a certain time goes by, and does not simulate a delay.

NS is written not only in OTcl but in C++ also. For efficiency reason, NS separates the data path
implementation from control path implementations. In order to reduce packet and event processing time (not
simulation time), the event scheduler and the basic network component objects in the data path are written
and compiled using C++. These compiled objects are made available to the OTcl interpreter through an
OTcl linkage that creates a matching OTcl object for each of the C++ objects and makes the control
functions and the configurable variables specified by the C++ object act as member functions and member
variables of the corresponding OTcl object. In this way, the controls of the C++ objects are given to OTcl. It
is also possible to add member functions and variables to a C++ linked OTcl object. The objects in C++ that
do not need to be controlled in a simulation or internally used by another object do not need to be linked to
OTcl. Likewise, an object (not in the data path) can be entirely implemented in OTcl. Figure 2 shows an
object hierarchy example in C++ and OTcl. One thing to note in the figure is that for C++ objects that have
an OTcl linkage forming a hierarchy, there is a matching OTcl object hierarchy very similar to that of C++.

Figure 2. C++ and OTcl: The Duality


Figure 3. Architectural View of NS

Figure 3 shows the general architecture of NS. In this figure a general user (not an NS developer) can be
thought of standing at the left bottom corner, designing and running simulations in Tcl using the simulator
objects in the OTcl library. The event schedulers and most of the network components are implemented in
C++ and available to OTcl through an OTcl linkage that is implemented using tclcl. The whole thing
together makes NS, which is a OO extended Tcl interpreter with network simulator libraries.

As shown in Figure 1, when a simulation is finished, NS produces one or more text-based output files that
contain detailed simulation data, if specified to do so in the input Tcl (or more specifically, OTcl) script.
The data can be used for simulation analysis or as an input to a graphical simulation display tool called
Network Animator (NAM). NAM has a nice graphical user interface similar to that of a CD player (play,
fast forward, rewind, pause and so on), and also has a display speed controller. Furthermore, it can
graphically present information such as throughput and number of packet drops at each link, although the
graphical information cannot be used for accurate simulation analysis.

NS2 Installation in Windows XP:

Step 1: Download NS2 windows library.


Step 2: Extract the zip file

Step 3: Double click [Link] and install it. The default install directory isC:/Program Files/Tcl.

Step 4: Copy [Link] & [Link] from the extracted folder and paste it intoC:/Program Files/Tcl/bin
directory.

Step 5: (Optional) Add the path C:/Program Files/Tcl/bin to the environmentvariable PATH. This will
allow you to execute NS from anywhere.
NS2 Installation in Linux (Ubuntu):

Step 1: Open the Terminal from the Programs Menu / Press Ctrl + Alt +T Step 2: Update your repository
by running the following command

sudo apt-get update

Step 3: Upgrade your repository by running the following command

sudo apt-get upgrade


Step4: Download 'ns-allinone-2.35' from :
[Link]

Step 5: Extract the downloaded zip file '[Link] file' to desktop.

Step 6: Install NS2 NAM & XGRAPH using the below command

sudo apt-get install ns nam xgraph

Conclusion:Thus, we have installed and configured NS2 on Windows and Linux (Ubuntu).
Experiment No. 3

Aim: To simulate and analyze the effect of varying number of nodes and physical layer parameters using
Network Simulator 2 (NS2).

Apparatus / Requirements:
 Software:
o Network Simulator 2 (NS2)
o TCL scripting language
 Hardware:
o Computer system (Linux/Ubuntu preferred)
 Basic knowledge of:
o Networking concepts
o Wireless communication
o TCL scripting
Theory:
Network Simulator 2 (NS2) is a discrete event simulator widely used for research in networking. It supports
simulation of wired and wireless networks, including physical (PHY) layer configurations.

Key Concepts:
1. Number of Nodes
 Nodes represent devices in a network.
 Increasing the number of nodes affects:
o Network congestion
o Packet delivery ratio
o Delay and throughput

2. Physical Layer in NS2


The physical layer defines how signals are transmitted over the medium. In NS2, it is configured using
parameters such as:
 Channel type (e.g. WirelessChannel)
 Propagation model (e.g. TwoRayGround)
 Network interface (Phy/WirelessPhy)
 Antenna model
 Transmission range
 Frequency and bandwidth

3. Wireless Network Components in NS2


 Channel: Communication medium
 Propagation Model: Signal attenuation
 Antenna: Signal transmission/reception
 MAC Layer: Medium access control
 Interface Queue: Packet buffering

Procedure:
Step 1: Initialize Simulator
 Create a new NS2 TCL script file.
set ns [new Simulator]

Step 2: Define Trace Files


set tracefile [open [Link] w]
$ns trace-all $tracefile

Step 3: Configure Wireless Channel


set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ant) Antenna/OmniAntenna

Step 4: Set Number of Nodes


set val(nn) 10 ;# number of nodes

Step 5: Configure Topography


set topo [new Topography]
$topo load_flatgrid 500 500

Step 6: Create Nodes


for {set i 0} {$i < $val(nn)} {incr i} {
set node($i) [$ns node]
}

Step 7: Configure Physical Layer


$ns node-config -adhocRouting AODV \
-llType LL \
-macType $val(mac) \
-ifqType $val(ifq) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan)

Step 8: Define Traffic


set udp [new Agent/UDP]
$ns attach-agent $node(0) $udp

set cbr [new Application/Traffic/CBR]


$cbr attach-agent $udp
$cbr set rate_ 1Mb

Step 9: Run Simulation


$ns run
Result:
 The simulation successfully demonstrates:
o Creation of multiple nodes in a wireless environment
o Configuration of physical layer parameters
 Observations:
o Increasing number of nodes leads to higher congestion
o Physical layer parameters influence signal strength and packet delivery

Conclusion:
 NS2 effectively simulates wireless networks with configurable node count and physical layer
settings.
 The number of nodes significantly impacts network performance.
 Proper physical layer configuration improves communication reliability and efficiency.
 This experiment helps in understanding real-world wireless network behavior.
Experiment No. 4

Aim: To configure and verify static routing between multiple networks using Cisco Packet Tracer.

Apparatus / Requirements:
 Software:
o Cisco Packet Tracer
 Hardware (virtual):
o Routers (e.g., 2 or 3 routers)
o PCs (end devices)
o Ethernet cables
 Basic knowledge of:
o IP addressing
o Routing concepts
Theory:
Routing is the process of forwarding packets from one network to another.
Static Routing:
 Static routing is a manual method where routes are configured by the network administrator.
 Unlike dynamic routing, it does not automatically update routes.
Key Features
 Simple to configure for small networks
 No routing protocol overhead
 More secure (no route advertisements)
 Not scalable for large networks
Static Route Syntax
ip route [destination_network] [subnet_mask] [next_hop_ip]
Example
ip route [Link] [Link] [Link]

Procedure:
Step 1: Create Network Topology

 Open Cisco Packet Tracer


 Add:
o 2 Routers (R1, R2)
o 2 PCs (PC1, PC2)
 Connect:
o PC1 → R1
o R1 → R2
o R2 → PC
Step 2: Assign IP Addresses
PC1
 IP: [Link]
 Subnet Mask: [Link]
 Gateway: [Link]

PC2
 IP: [Link]
 Subnet Mask: [Link]
 Gateway: [Link]

Router R1
enable
configure terminal
interface g0/0
ip address [Link] [Link]
no shutdown

interface g0/1
ip address [Link] [Link]
no shutdown

Router R2
enable
configure terminal
interface g0/0
ip address [Link] [Link]
no shutdown

interface g0/1
ip address [Link] [Link]
no shutdown

Step 3: Configure Static Routes

On Router R1
ip route [Link] [Link] [Link]

On Router R2
ip route [Link] [Link] [Link]

Step 4: Verify Configuration


 Use ping command from PC1:
ping [Link]
 Check routing table:
showip route
Result:
 Static routes were successfully configured between routers.
 Communication between different networks was established.
 Ping between PC1 and PC2 was successful.

Conclusion:
 Static routing is simple and effective for small networks.
 It provides full control over routing decisions.

However, it is not suitable for large or dynamic networks due to manual configuration requirements.
Experiment No. 5

Aim: To simulate and analyze the performance of the Sliding Window Protocol using Network Simulator 2
(NS2).

Apparatus / Requirements:
 Software:
o Network Simulator 2 (NS2)
 Programming:
o TCL scripting language
 Hardware:
o Computer system (Linux/Ubuntu preferred)
 Basic knowledge of:
o Data communication
o Flow control protocols
Theory:
The Sliding Window Protocol is a flow control mechanism used in data transmission to ensure efficient
and reliable delivery of packets.

Key Concepts:

1. Sliding Window

 It allows a sender to transmit multiple frames before needing an acknowledgment.


 The “window” represents the number of frames that can be sent without waiting.

2. Types of Sliding Window Protocols

 Stop-and-Wait (window size = 1)


 Go-Back-N
 Selective Repeat

3. Working Principle

 Sender maintains a window of frames.


 Receiver sends acknowledgments (ACKs).
 Window “slides” forward as ACKs are received.
 Improves throughput compared to Stop-and-Wait.

4. Sliding Window in NS2

 NS2 implements sliding window behavior using TCP protocols.


 TCP automatically handles:
o Flow control
o Congestion control
o Window size adjustment
Procedure:

Step 1: Create TCL Script


Create a new .tcl file.
Step 2: Initialize Simulator
set ns [new Simulator]
Step 3: Create Nodes
set n0 [$ns node]
set n1 [$ns node]
Step 4: Create Link
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
Step 5: Configure TCP (Sliding Window)
settcp [new Agent/TCP]
$tcp set window_ 5
$ns attach-agent $n0 $tcp

set sink [new Agent/TCPSink]


$ns attach-agent $n1 $sink

$ns connect $tcp $sink


Step 6: Add Traffic
set ftp [new Application/FTP]
$ftp attach-agent $tcp
Step 7: Start and Stop Simulation
$ns at 1.0 "$ftp start"
$ns at 5.0 "$ftp stop"
$ns at 6.0 "finish"

proc finish {} {
global ns
$ns halt
}
Step 8: Run Simulation
$ns run

Result:
 The simulation successfully demonstrates sliding window behavior using TCP.
 Multiple packets are transmitted before receiving acknowledgments.
 Efficient data transfer compared to Stop-and-Wait is observed.

Conclusion:
 Sliding Window Protocol improves network efficiency by allowing continuous transmission.
 NS2 simulates this behavior using TCP mechanisms.

Window size plays a crucial role in determining throughput and performance.


Experiment No. 6

Aim: To perform subnetting and supernetting and implement them using Cisco Packet Tracer.

Apparatus / Requirements:
 Software:
o Cisco Packet Tracer
 Hardware (virtual):
o Routers
o Switches
o PCs
 Basic knowledge of:
o IP addressing
o Subnet masks
o Routing
Theory:
1. Sub netting: Sub netting is the process of dividing a large network into smaller sub-networks
(subnets).

Advantages:
 Efficient IP address utilization
 Improved network performance
 Enhanced security and management

Example:
Network: [Link]/24
Subnet into 4 subnets:
Subnet Network Address Range Broadcast
1 [Link]/26 .1 – .62 .63
2 [Link]/26 .65 – .126 .127
3 [Link]/26 .129 – .190 .191
4 [Link]/26 .193 – .254 .255

2. Super netting: Super netting (route summarization) is the process of combining multiple networks
into a single larger network.
Advantages:
 Reduces routing table size
 Improves routing efficiency

Example:
Combine:
 [Link]/24
 [Link]/24

Supernet: [Link]/23
Procedure:
Part A: Sub netting
Step 1: Design Topology
 Open Cisco Packet Tracer
 Add:
o 1 Router
o 2–4 PCs
o 1 Switch
Step 2: Assign Subnet IPs

Example:
 Subnet 1:
o PC1: [Link] /26
o Gateway: [Link]
 Subnet 2:
o PC2: [Link] /26
o Gateway: [Link]

Step 3: Configure Router Interfaces


enable
configure terminal

interface g0/0
ip address [Link] [Link]
no shutdown

interface g0/1
ip address [Link] [Link]
no shutdown

Step 4: Test Connectivity


ping [Link]
Part B: Super netting

Step 1: Create Two Networks


 Network 1: [Link]/24
 Network 2: [Link]/24

Step 2: Configure Routers


Assign IPs to interfaces accordingly.

Step 3: Configure Summary Route


ip route [Link] [Link] <next-hop-ip>

Step 4: Verify
showip route
Result:
 Subnetting successfully divided a network into smaller segments.
 Supernetting successfully combined multiple networks into a single route.
 Communication between networks was achieved efficiently.

Conclusion:
 Subnetting improves network management and reduces congestion.
 Supernetting simplifies routing by reducing routing table entries.

Both techniques are essential for efficient IP address management in real-world networks.
Experiment No. 7

Aim: To study and implement socket programming using the TCP protocol for reliable communication
between client and server.

Apparatus / Requirements:

 Software:
o C / C++ / Python (any programming language supporting sockets)
 Tools:
o Compiler (GCC / Python interpreter)
 Hardware:
o Computer system (Linux/Windows)
 Basic knowledge of:
o Computer networks
o TCP/IP model

Theory:

Socket Programming

Socket programming enables communication between two devices over a network using endpoints called
sockets.

TCP (Transmission Control Protocol)


 TCP is a connection-oriented protocol.
 It ensures:
o Reliable data transfer
o Error checking
o Ordered delivery
o Flow control

Working of TCP Socket


1. Server creates a socket
2. Server binds to an IP and port
3. Server listens for incoming connections
4. Client connects to server
5. Data is exchanged
6. Connection is closed
Socket Functions (C Language)

Function Description
socket() Create socket
bind() Assign IP & port
listen() Wait for connection
accept() Accept client
connect() Connect to server
send() / recv() Data transfer
close() Close socket

Procedure:

Step 1: Write Server Program (C)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>

intmain() {
intserver_fd, client_socket;
structsockaddr_inaddress;
intaddrlen=sizeof(address);
charbuffer[1024] = {0};

server_fd=socket(AF_INET, SOCK_STREAM, 0);

address.sin_family=AF_INET;
address.sin_addr.s_addr=INADDR_ANY;
address.sin_port=htons(8080);

bind(server_fd, (structsockaddr*)&address, sizeof(address));


listen(server_fd, 3);

printf("Waiting for connection...\n");

client_socket=accept(server_fd, (structsockaddr*)&address, (socklen_t*)&addrlen);

read(client_socket, buffer, 1024);


printf("Client: %s\n", buffer);
send(client_socket, "Hello from server", 17, 0);

close(client_socket);
close(server_fd);
return0;
}

Step 2: Write Client Program (C)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>

intmain() {
intsock=0;
structsockaddr_inserv_addr;
char*message="Hello from client";
charbuffer[1024] = {0};

sock=socket(AF_INET, SOCK_STREAM, 0);

serv_addr.sin_family=AF_INET;
serv_addr.sin_port=htons(8080);

inet_pton(AF_INET, "[Link]", &serv_addr.sin_addr);

connect(sock, (structsockaddr*)&serv_addr, sizeof(serv_addr));

send(sock, message, strlen(message), 0);


read(sock, buffer, 1024);

printf("Server: %s\n", buffer);

close(sock);
return0;
}
Step 3: Compile Programs
gccserver.c-o server
gccclient.c-o client

Step 4: Execute Programs


./server
./client
Result
 TCP connection established successfully between client and server.
 Messages were transmitted reliably.
 Server received client message and responded correctly.
Conclusion
 TCP socket programming enables reliable communication between systems.
 It ensures ordered and error-free data transmission.

This experiment demonstrates the practical implementation of client-server architecture.


Experiment No. 8
Aim: To study and implement socket programming using the UDP protocol for communication between
client and server.

Apparatus / Requirements:
 Software:
o C / C++ / Python
 Tools:
o GCC Compiler / Python Interpreter
 Hardware:
o Computer system (Linux/Windows)
 Basic knowledge of:
o Computer networks
o TCP/IP model
Theory:

Socket Programming

Socket programming allows two systems to communicate over a network using endpoints called sockets.

UDP (User Datagram Protocol)

 UDP is a connectionless protocol.


 It does not guarantee:
o Delivery
o Order
o Duplication protection

Features of UDP

 Faster than TCP


 Low overhead
 No connection establishment
 Suitable for real-time applications (video streaming, gaming)

Difference between TCP and UDP


Feature TCP UDP
Connection Connection-oriented Connectionless
Reliability High Low
Speed Slower Faster
Ordering Guaranteed Not guaranteed
Working of UDP Socket:
1. Server creates socket
2. Server binds to IP and port
3. Client sends datagram
4. Server receives message
5. Server replies (optional)
6. No connection setup required

Procedure:

Step 1: Write UDP Server Program (C)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>

#define PORT 8080

intmain() {
intsockfd;
charbuffer[1024];
structsockaddr_inserver_addr, client_addr;
socklen_tlen=sizeof(client_addr);

sockfd=socket(AF_INET, SOCK_DGRAM, 0);

server_addr.sin_family=AF_INET;
server_addr.sin_port=htons(PORT);
server_addr.sin_addr.s_addr=INADDR_ANY;

bind(sockfd, (structsockaddr*)&server_addr, sizeof(server_addr));

printf("UDP Server is running...\n");

recvfrom(sockfd, buffer, sizeof(buffer), 0,


(structsockaddr*)&client_addr, &len);

printf("Client: %s\n", buffer);

sendto(sockfd, "Hello from server", 17, 0,


(structsockaddr*)&client_addr, len);
close(sockfd);
return0;
}

Step 2: Write UDP Client Program (C)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>

#define PORT 8080

intmain() {
intsockfd;
char*message="Hello from client";
charbuffer[1024];
structsockaddr_inserver_addr;

sockfd=socket(AF_INET, SOCK_DGRAM, 0);

server_addr.sin_family=AF_INET;
server_addr.sin_port=htons(PORT);
inet_pton(AF_INET, "[Link]", &server_addr.sin_addr);

sendto(sockfd, message, strlen(message), 0,


(structsockaddr*)&server_addr, sizeof(server_addr));

recvfrom(sockfd, buffer, sizeof(buffer), 0, NULL, NULL);

printf("Server: %s\n", buffer);

close(sockfd);
return0;
}

Step 3: Compile Programs

gccudp_server.c-oudp_server
gccudp_client.c-oudp_client

Step 4: Execute Programs

./udp_server
./udp_client
Result:

 UDP communication between client and server was successfully established.


 Messages were transmitted without connection setup.
 Data exchange occurred using datagrams.

Conclusion:

 UDP provides fast communication with minimal overhead.


 It is suitable for applications where speed is more important than reliability.

This experiment demonstrates connectionless communication using socket programming.


Experiment No. 9

Aim: To simulate and analyze the TCP/IP stack using a network protocol analyzer and study the network
traffic.

Apparatus / Requirements:
 Software:
o Wireshark (or similar network protocol analyzer)
 Hardware:
o Computer system with internet connectivity
 Basic knowledge of:
o TCP/IP model
o Networking protocols

Theory:

TCP/IP Stack
The TCP/IP model consists of four layers:
1. Application Layer – HTTP, FTP, DNS
2. Transport Layer – TCP, UDP
3. Internet Layer – IP
4. Network Access Layer – Ethernet

Network Protocol Analyzer


A network protocol analyzer like Wireshark captures and displays packets flowing through a network.

Key Protocols Observed


 IP (Internet Protocol) – Handles addressing and routing
 TCP (Transmission Control Protocol) – Reliable communication
 UDP (User Datagram Protocol) – Fast, connectionless communication
 HTTP – Web communication
 DNS – Domain name resolution
Procedure:
Step 1: Install and Launch Tool
 Open Wireshark
 Select the active network interface (Wi-Fi/Ethernet)

Step 2: Start Packet Capture


 Click Start Capture
 Network packets will begin appearing in real-time

Step 3: Generate Network Traffic

Perform activities such as:


 Open a website (e.g., [Link])
 Ping a server
 Download/upload a file

Step 4: Apply Filters

Use filters to analyze specific protocols:


 TCP: tcp

 UDP: udp
 DNS: dns
 HTTP: http

Step 5: Analyze Packets


 Click on any packet
 Observe:
o Source and destination IP
o Protocol used
o Packet length
o Payload data

Step 6: Study TCP Features


 Identify:
o 3-way handshake (SYN, SYN-ACK, ACK)
o Sequence numbers
o Acknowledgments
o Retransmissions
Step 7: Stop Capture
 Click Stop
 Save the capture file for analysis
Result:
 Successfully captured and analyzed network packets using Wireshark.
 Observed TCP/IP stack layers in real-time communication.
 Identified various protocols such as TCP, UDP, DNS, and HTTP.
Conclusion:
 The TCP/IP stack operation can be effectively visualized using a network protocol analyzer.
 Packet-level analysis helps understand real-time communication between devices.
This experiment enhances understanding of protocol behavior and network troubleshooting.
Experiment No. 10

Aim: To design a scalable and efficient network for an organization using IP addressing, DNS (naming),
and routing concepts.

Apparatus / Requirements:

 Software (optional for simulation):


o Cisco Packet Tracer
 Hardware (conceptual):
o Routers
o Switches
o Servers (DNS, Web, etc.)
o End devices (PCs, laptops)
 Knowledge of:
o IP addressing
o DNS
o Routing

Theory:
1. IP Addressing (Addressing)
 Each device in a network must have a unique IP address.
 IP addressing can be:
o Static
o Dynamic (using DHCP)
Example:
 Network: [Link]/24
 Subnets created for departments

2. Naming (DNS – Domain Name System)

 DNS translates human-readable domain names into IP addresses.


 Example:
o [Link] → [Link]
 Uses a DNS server for resolution.

3. Routing
 Routing determines the path for data to travel between networks.
 Types:
o Static routing
o Dynamic routing (e.g., RIP, OSPF)
Network Design Overview

Organization Structure Example


 HR Department
 Finance Department
 IT Department
 Server Room

IP Addressing Scheme
Department Network Subnet Mask Hosts
HR [Link]/26 [Link] 62
Finance [Link]/26 [Link] 62
IT [Link]/26 [Link] 62
Servers [Link]/26 [Link] 62

DNS Configuration
 DNS Server IP: [Link]

Sample DNS Records

Domain Name IP Address

[Link] [Link]

[Link] [Link]

[Link] [Link]

Routing Design
 Use a central router to connect all subnets
 Configure routing between subnets
Example (Static Routing)
ip route [Link] [Link] <next-hop>
ip route [Link] [Link] <next-hop>
(Or use dynamic routing like RIP/OSPF for scalability)
Network Topology (Conceptual)

[ Router ]

HR Finance IT
| | |
PCs PCs PCs
\
[ Switch ]
|
[ DNS Server ]

Procedure:

Step 1: Design Topology

 Create departments using switches


 Connect all switches to a central router

Step 2: Assign IP Addresses

 Allocate subnet ranges to each department


 Assign IPs to devices

Step 3: Configure DNS Server

 Add domain name mappings


 Enable DNS service

Step 4: Configure Routing

 Configure router interfaces


 Add static or dynamic routes

Step 5: Test Network

 Use:
o ping
o nslookup

 Verify communication and DNS resolution


Result:

 Network successfully designed using IP addressing, DNS, and routing.


 Devices communicated across subnets.
 Domain names were resolved correctly using DNS.

Conclusion:

 Proper IP addressing ensures efficient network organization.


 DNS simplifies communication using names instead of IP addresses.
 Routing enables inter-network communication.

A well-designed network improves scalability, performance, and management.

You might also like