Professional Documents
Culture Documents
CN Lab Manual Format EDITED
CN Lab Manual Format EDITED
CN Lab Manual Format EDITED
SOFTWARE REQUIREMENTS:
Command prompt in WINDOWS 10
NETWORKING COMMANDS:
1. C:\>tcpdump: TCPDUMP for Windows is a clone of TCPDUMP, the most used network
sniffer/analyzer for UNIX, compiled with the original tcpdump code (tcpdump.org), and our
own packet capture technology Microlap Packet Sniffer SDK (no libpcap/WinPcap/npcap).
2. C:\>netstat: The netsat displays a variety of statistics about a computers active TCP/IP
connections. This tool is most useful when you are having trouble with TCP/IP application such
as HTTP and FTP.
OUTPUT:
3. C:\>ipconfig: The ipconfig command displays information about the host (the computer
your sitting at) computer TCP/IP configuration
(1)C:\>ipconfig/all: This command displays detailed configuration information bout
your TCP/IP connection including router ,gateway ,DNS ,DHCP and type of Ethernet
adapter in your system.
(2)C:\>ipconfig/renew: Using this command will renew all your IP addresses that
you are currently borrowing from the DHCP server.
2
OUTPUT:
4. C:\>nslookup: The nslookup is used for diagonosing DNS problem. If you can access a
resource by specification an IP address but not it’s DNS , you have a DNS problem.
OUTPUT:
5. C:\>tracert: The tracert command displays a list of all the routers that a packet has to go
through to get from the computers on the internet.
3
OUTPUT:
RESULT:
Thus the networking commands such as tcpdump, netstat, ipconfig, nslookup and
traceroute has been executed in command prompt successfully.
AIM:
To write a HTTP web client program to download a web page using TCP sockets.
ALGORITHM:
1. Start the program
2. Import the socket modeule
3. Define the Host address and the port to be connected
4. Make a socket by binding Host and port with "connect" function
5. Request the client with the "sendall" function
6. Recieve the packets with recv and define it to a response variable
7. Decode the response
8. Print the response
9. Close the socket and end the program
PROGRAM:
import socket
target_website = "www.msec.edu.in"
tcp_port = 80
tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_socket.connect((target_website, tcp_port))
http_request = "GET / HTTP/1.1\r\nHost: " + target_website + "\r\n\r\n"
tcp_socket.sendall(http_request.encode())
http_response = b''
while True:
data = tcp_socket.recv(4096)
if not data:
break
http_response += data
result = str(http_response.decode())
print(result)
tcp_socket.close()
OUTPUT:
5
RESULT:
Thus the HTTP Web Client program to download the web page has been implemented
successfully.
6
7
server.bind(('localhost', 8080))
print('Chat started.....')
server.listen(10)
while True:
command = command.encode()
client.send(command)
RECIEVER:
import socket
import subprocess
server_ip ='localhost'
port = 8080
bd = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
bd.connect((server_ip, port))
command = "open"
while command != "close":
command = bd.recv(1024)
print("Recieved >>> ",str(command))
8
OUTPUT:
SENDER:
RECIEVER:
9
RESULT:
Thus the Echo Client and Echo Server using TCP Sockets has been implemented
successfully.
10
11
Rapid advances in computer & communication technologies have resulted in the increasing merger
of these two fields. The lines have blurred among computing, switching & digital transmission equipment;
and the same digital techniques are being used for data, audio & video transmission. The intgrated systems
are broadly divided as follows
Data transfer using serial and parallel ports, Ethernet and wireless LAN with complete protocol
understanding and actual hands on with hardware & software with ease.
Network laboratory consists of DCT-03 Data communication trainer kit, LTS- 01 LAN / Wireless LAN
training system, L-SIM LAN / WLAN protocol simulator and analyzer software & N-SIM Network
simulation software.
Data communication is a term referred when the sender and receiver are digital devices, which
communicate with each other by means of binary information. The objective of this trainer kit is to clear
the various aspects of the data communications which comprise of
RESULT:
Thus the study of network simulator (ns) and simulation of congestion control algorithms using ns
is executed and verified.
13
AIM:
Note: Your instructor may provide you with a different website. If so, enter the
website name or address here:
b. The capture windows are now active. Locate the Source, Destination, and Protocol
columns on the Wireshark display screen. The HTTP data that carries web page text
and graphics uses TCP for reliability.
Step 2: Stop the capture. From the Wireshark Capture menu, choose Stop.
15
RESULT:
Thus the packet examining and capturing has been completed using the wireshark tool
successfully.
16
AIM:
To Study of TCP/UDP performance using Simulation tool.
TOOLS USED:
Opnet Simulator
INTRODUCTION:
The transport layer protocols provide connection- oriented sessions and
reliable data delivery services. This paper seeks to reflect a comparative analysis
between the two transport layer protocols, which are TCP/IP and UDP/IP, as well to
observe the effect of using these two protocols in a client server network.
The transport layer is not just another layer. It is the heart of the whole
protocol hierarchy. Its task is to provide reliable, cost-effective data transport from
the source machine to the destinationmachine, independently of the physical network
or networks currently in use.
TCP and UDP are transport layer components that provide the connection
point through which applications access network services. TCP and UDP use IP,
which is a lower-layer best effort delivery service.
The ultimate goal of the transport layer is to provide efficient, reliable, and
cost-effective service to its users, normally processes in the application layer. To
achieve this goal, the transport layer makes use of the services provided by the
network layer.
TCP TCP
UDP UDP
TCP
UDP
The main difference between these two protocols is that TCP provides reliability and
congestion control services, while UDP is orientated to improve performance.
The most important and common thing that TCP and UDP are using is the ability to set
a host-to-host communication channel, so the packets will be delivered between processes
running on two different computers.
RESULT:
Thus the TCP/UDP performance has been simulated successfully using OPNET.
19
BRIEF:
USE CASE:
3. DNS: UDP is used for Domain Name System (DNS) queries, which convert
domain names into IP addresses.
20
4. IoT devices: UDP can be used to send small packets of data between devices,
such as sensor readings or control messages.
AIM:
ALGORITHM:
TRANSMITTER:
CODE (TRANSMITTER):
import socket
sock.close()
CODE (RECEIVER):
import socket
sock.bind((UDP_IP, UDP_PORT))
while True:
OUTPUT:
TRANSMITTER:
RECEIVER:
RESULT:
ALGORITHM:
PROGRAM:
import os
import subprocess
def ping(host):
print("\nPING_ING {host}\n---------------------")
24
print(f"Result:\n{output}\n----------------------")
return True
else:
return False
def Arp_checker(v,w0):
w = w0
a = w0
if v == 0:
else:
print("\nTrying again...\n--------")
if w!=0:
n1 = os.system(f"arp -s '{dst_ip}'")
Arp_checker(n1,w-1)
else:
w0 = w0
if q == "y":
25
data = f.read()
print(data)
else:
print("Program ends...")
if ping(dst_ip):
print('Host is reachable.')
else:
break
print(f"\nARP-ING: {dst_ip}\n")
n = os.system(f"arping -c 1 '{dst_ip}'")
Arp_checker(n,x)
26
OUTPUT:
RESULT:
To stimulate and study the link state routing algorithm using simulation using NS2.
ALGORITHM:
PROGRAM:
#include<stdio.h>
#include<iostream>
using namespace std;
//ducslectures.blogspot.in
struct node
{
unsigned dist[6];
unsigned from[6];
}DVR[10];
int main()
{
cout<<"\n\n PROGRAM TO IMPLEMENT DISTANCE VECTOR ROUTING ALGORITHM ";
int costmat[6][6];
int nodes, i, j, k;
cout<<"\n\n Enter the number of nodes : ";
cin>>nodes; //Enter the nodes
cout<<"\n Enter the cost matrix : \n" ;
for(i = 0; i < nodes; i++)
{
for(j = 0; j < nodes; j++)
28
cin>>costmat[i][j];
costmat[i][i] = 0;
DVR[i].dist[j] = costmat[i][j]; //initialise the distance equal to cost matrix
DVR[i].from[j] = j;
}
}
for(i = 0; i < nodes; i++) //We choose arbitary vertex k and we calculate the
//direct distance from the node i to k using the cost matrix and add the distance from k to node
j
for(j = i+1; j < nodes; j++)
for(k = 0; k < nodes; k++)
if(DVR[i].dist[j] > costmat[i][k] + DVR[k].dist[j])
{ //We calculate the minimum distance
DVR[i].dist[j] = DVR[i].dist[k] + DVR[k].dist[j];
DVR[j].dist[i] = DVR[i].dist[j];
DVR[i].from[j] = k;
DVR[j].from[i] = k;
//ducslectures.blogspot.in
}
for(i = 0; i < nodes; i++)
{
cout<<"\n\n For router: "<<i+1;
for(j = 0; j < nodes; j++)
cout<<"\t\n node "<<j+1<<" via "<<DVR[i].from[j]+1<<" Distance "<<DVR[i].dist[j];
}
cout<<" \n\n ";
return 0;
}
OUTPUT:
29
RESULT:
AIM:
ALGORITHM:
CHAT PARTY:
import socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('localhost', 8080))
server.listen(1)
print('Chat started.....')
client, client_addr = server.accept()
print(f'[+] {client_addr} Client connected to the server')
while True:
command = input('Enter text : ')
command = command.encode()
client.send(command)
print('[+] Text sent')
31
message = client.recv(1024)
print("\nReceived >>>", message.decode())
CODE (SPEAKER 2):
import socket
server_ip = 'localhost'
port = 808
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((server_ip, port)
while True:
response = client.recv(1024)
print("\nReceived >>>", response.decode())
message = input('Enter text : ')
message = message.encode()
client.send(message)
print('[+] Message sent')
OUTPUT:
32
SPEAKER 1:
SPEAKER 2:
RESULT: