0% found this document useful (0 votes)
16 views

Docuument Networking

The document describes experiments conducted on network programming commands and socket programming. It provides code snippets for a server-client program to establish a socket connection and send the client's IP address and name to the server. The procedures explain how to create a socket connection and ensure communication by sending the client details to the server.

Uploaded by

bhaveshk1507
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Docuument Networking

The document describes experiments conducted on network programming commands and socket programming. It provides code snippets for a server-client program to establish a socket connection and send the client's IP address and name to the server. The procedures explain how to create a socket connection and ensure communication by sending the client details to the server.

Uploaded by

bhaveshk1507
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

LABORATORY REPORT

Data Communications and Networks


REPORT

Submitted by

NAME: Bhavesh Kushwaha


REGNO: 22MCA10023

Master of Computer Application

Submitted to

Dr. D Saravanan

SCHOOL OF COMPUTING SCIENCE AND ENGINEERING

VIT BHOPAL UNIVERSITY

April, 2023
Table of Contents

SL.NO Name of the experiment DATE


1 Experiment No. 1 10/04/2023
Registration no: 22MCA10023
2 Experiment No. 2 10/04/2023
3 Experiment No. 3 10/04/2023
4 Experiment No. 4 10/04/2023
5 Experiment No. 5 10/04/2023

Date: 10/04/2023 Title

Exp. No: 01 Computer Networking Commands

Experiment No. 1

1) arp
Name: Bhavesh Kushwaha
DATE of Submission: 11/04/2023
Registration no: 22MCA10023
In a local area network (LAN), the Address Resolution Protocol (ARP) process maps a dynamic address to a
permanent physical machine address. A media access control (MAC) address is another name for the actual machine
address.

2) hostname
The hostname command shows the host system's name. The host name can only be changed by someone
with root user authority.

3) ipconfig
displays all of the TCP/IP network configuration values that are currently in effect and updates the DHCP
and DNS settings. Internet Protocol version 4 (IPv4) and IPv6 addresses, subnet masks, and default
gatewayare shown for all adapters when ipconfig is used without any options.

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023

4) ipconfig /all
Ipconfig /all shows full configuration details for each TCP/IP-connected adapter.

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023
5) ipconfig /renew :
that command instructs the DHCP server on your router to renegotiate an IP address lease with your
DHCP client.

6) ipconfig /release :
Ipconfig/release notifies a DHCP server that you no longer want the address it gave you the last
time you asked for it. If you no longer require the address, this is probably a very courteous
thing to do.
A fresh IP address is requested via Ipconfig/renew from the DHCP server.

7)ipconfig /flushdns :

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023
Your cache will now be totally deleted, and any websites you visit will now load in brand-new versions.

8) netstat –a :
For each protocol, the netstat -s command displays statistics (while the netstat -p command shows the
statistics for the specified protocol). Just the following protocols' statistics are shown by the netstat -s
command: UDP, TCP.

9) nbtstat –a
shows statistics for the NetBIOS over TCP/IP (NetBT) protocol, as well as the NetBIOS name cache and local and
remote NetBIOS name tables. Moreover, this operation enables the NetBIOS name cache and Windows Internet

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023
Name Service registered names to be refreshed (WINS).

10) nslookup :
The application known as "nslookup" enables any computer user or Internet server
administrator to enter a host name (for instance, "whatis.com") and discover the related IP
address or domain name system (DNS) record.

11) ping :
The Internet Control Message Protocol (ICMP), which is part of TCP/internet IP's layer, is used by the ping
application. The simplest application of it is to validate network connectivity between two hosts. Ping
transmits an ICMP echo request, and it waits for a response in the form of an ICMP echo reply.

12) pathping :
The results of this command are computed based on the packets returned from each router after several
echo Request messages have been sent to each router between a source and a destination over a period
of time.

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023

13) route :
You can manually add entries to the network routing tables using the route command. The network address
of the Destination variable, which can be supplied either by symbolic name or numeric address, is how the
route command differentiates between routes to hosts and routes to networks.

14) tracert :
By delivering Internet Control Message Protocol (ICMP) echo packets to a target, the TRACERT diagnostic
tool ascertains the path to the location. TRACERT employs various IP Time-To-Live (TTL) values in these
packets.

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023
Date: 10/04/2023 Title

Exp. No: 02 Socket Programming

Experiment No. 2

1) Server Side Programming

import java.io.*;
import java.net.*;
public class MyServer{
public static void main(String[] args) throws IOException{
try{
ServerSocket ss=new ServerSocket(port:6666);
Socket s=ss.accept();
DataInputStream dis=new DataInputStream(s.getInputStream());
String str=(String)dis.readUTF();
System.out.println(x:"Waiting for the Client");
System.out.println("message= "+str);
ss.close();

}catch(Exception e){
System.out.println(e);
}
}
}

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023
OUTPUT:

2)Client Side Programming


import java.io.*;
import java.net.*;
import java.util.Scanner;
public class MyClient {
public static void main(String[] args) throws IOException {
DataInputStream dis=new DataInputStream(System.in);
Scanner sc=new Scanner(System.in);
try{
Socket s=new Socket(host:"localhost",port:6666);
DataInputStream dout=new DataInputStream(s.getOutputStream());
System.out.println(x:"Enter no ");
String m1=sc.next();
System.out.println(x:"Enter name ");
String m2=sc.next();
dout.writeUTF("Hello Server"+" Number "+m1+" And Name is "+m2);
dout.close();
s.close();
Name: Bhavesh Kushwaha
DATE of Submission: 11/04/2023
Registration no: 22MCA10023
}catch(Exception e){
System.out.println(e);
}
}
}

OUTPUT:

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023
Date: 10/04/2023 Title

Exp. No: 03 Socket Programming

Experiment No. 3

By connecting a client and a server, the Network Communication Model is established.

By sending the client's IP address to the server and displaying it inside the server's facilities,
the connection is also ensured.

Aim :

Write a Socket Program for Server and Client to print IP address and Name that details sent
by client

Procedure :

How to Create a Socket Connection:

1) A socket connection is necessary in order to connect to another machine.

2) A socket connection indicates that the two devices are aware of each other's network
position.

The Java.net, third.

A socket is represented by the Socket class.

4) Use the Socket object and its getRemoteSocketAddress function to determine the
current system's IP address ()

Communication :

Data input and output are done via streams for communication across a socket connection.

Closing the Connection :

Once the message to the server is sent, the socket connection is explicitly closed.

1)Server Side Programming


import java.io.*;
Name: Bhavesh Kushwaha
DATE of Submission: 11/04/2023
Registration no: 22MCA10023
import java.net.*;

import javax.sound.sampled.Port;
public class MyServer{
public static void main(String[] args) throws IOException{
try{
ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();
DataInputStream dis=new DataInputStream(s.getInputStream());
String str=(String)dis.readUTF();
System.out.println("Waiting for the Client");
System.out.println("message= "+str);
ss.close();

}catch(Exception e){
System.out.println(e);
}
}
}

2)Client Side Programming


import java.io.*;
import java.net.*;
import java.util.Scanner;
public class MyClient {
public static void main(String[] args) throws IOException {
DataInputStream dis=new DataInputStream(System.in);
Scanner sc=new Scanner(System.in);
try{
Socket s=new Socket("localhost",6666);
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
//System.out.println("Enter no ");
Name: Bhavesh Kushwaha
DATE of Submission: 11/04/2023
Registration no: 22MCA10023

String m1=s.getRemoteSocketAddress().toString();
System.out.println("Enter name ");
String m2=sc.next();
dout.writeUTF("Hello Server"+" Number "+m1+" And Name is "+m2);
//dout.flush();
dout.close();
s.close();
}catch(Exception e){
System.out.println(e);
}
}
}

Output :

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023
Date: 10/04/2023 Title

Exp. No: 04 Implementation of Remote Command Execution(RCE)

Experiment No. 4

AIM
To implement Remote Command Execution(RCE).

ALGORITHM-
CLIENT SIDE:
Connecting the Client and Server is step one. new Socket("127.0.0.1",6555); socket client
2. Construct streams of instances for the input and output.
3. BufferedReaderbr=newBufferedReader(newInputStreamReader(System.in)); Print Stream ps=new Print
Stream(client.getOutputStream());
4. In the Client Window, type the command. Deliver a message to the output using these commands:
str=br.readLine(); ps.println(str);

SERVER SIDE:
1. Accept the connection request by the client. ServerSocket server=new ServerSocket(6555);
Sockets=server.accept();
2. Getthe IPaddressfromitsinputstream.
BufferedReaderbr1=newBufferedReader(newInputStreamReader(s.getInputStream())); ip=br1.readLine();
3. During runtime execute the process Runtime r=Runtime.getRuntime(); Process p=r.exec(str);

CODE :

CLIENT PROGRAM:
import java.io.*; import java.net.*; class clientRCE
{

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023
public static void main(String args[]) throws IOException
{
try
{
String str;Socket client=new Socket("127.0.0.1",6555); PrintStream ps=new
PrintStream(client.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("\t\t\t\
tCLIENT WINDOW\n\n\t\tEnter TheCommand:"); str=br.readLine();
ps.println(str);
}
catch(IOException e)
{
System.out.println("Error"+e); }
}
}

SERVER PROGRAM:
import java.io.*; import java.net.*; class serverRCE
{
public static void main(String args[]) throws IOException
{
try
{
String str;
ServerSocket server=new ServerSocket(6555); Socket s=server.accept();
BufferedReader br=new BufferedReader(new InputStreamReader(s.getInputStream())); str=br.readLine();
Runtime r=Runtime.getRuntime(); Process p=r.exec(str);
}
catch(IOException e)
{
System.out.println("Error"+e);

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023
}
}
}

OUTPUT
C:\Users\user\Documents\DCN>java serverRCE.java
C:\Users\user\Documents\DCN>java clientRCE.java
CLIENT WINDOW
Enter TheCommand:

NOTEPAD:

RESULT:
Thus the implementation RCE is done & executed successfully.

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023
Registration no: 22MCA10023

Date: 10/04/2023 Title

Exp. No: 05 ARP Spoofing

Experiment No. 5

Aim:
To implement Arp Spoofing in terminal
Algorithm:
1) Open terminal as administrator
2) Enter arp/a interminal
3) Enter arp -s “System IP address”,”random mac address”
4) Click Enter
Code:
Arp -s 172.25.43.197 01-00-5e-00-00-fb
Output:

Result:
Hence the ARP Spoofing is done

Name: Bhavesh Kushwaha


DATE of Submission: 11/04/2023

You might also like