Professional Documents
Culture Documents
Manish Comp Network
Manish Comp Network
- F/ TL/021
Rev.00 Date 20.03.2020
A
WITH
GP
RECORD NOTEBOOK
DEPARTMENT
Of
COMPUTER SCIENCE AND ENGINEERING
Dr. M.G.R.
EDUCATIONAL AND RESEARCH INSTITUTE A
NAAC
(Deemed to- be University)
Maduravoyal, Chennai 600 095. Tamilnadu. India.
(An ISO 9001 : 2015 Certified Institution)
University with Graded Autonomy Status
BONAFIDE CERTIFICATE
AIM
ALGORITHM
Step1. Start the program
Step2. Open the command prompt
Step3. Enter the commands along with the proper options
Step4. View the Command Output
PROGRAM
1. ping
This is used to provide a basic connectivity test between the requesting host and the destination host.
2. ipconfig
Displays all current TCP/IP network configuration values and refreshes Dynamic Host Configuration
Protocol (DHCP) and Domain Name System (DNS) settings.
3. tracert
This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a
component in the properties of a network adapter in Network Connections.
4. nslookup
nslookup is the name of a program that lets an Internet server administrator or any computer user
enter a host name (for example, "whatis.com")and find out the corresponding IP address or domain
name system (DNS) record. The user can also entera command for it to do a reverse DNS lookup
and find the host name for an IP address that is specified.
5. ipconfig/all
6. Without the use of any parameter, the command shows only the basic network information. But
information about the DNS and DHCP servers is not displayed by default. To show all the
information about your network adapter, you will need to use the /all parameter.
7. getmac
The getmac (short for get MAC address) is a simple Windows network command-line utility used to
find the physical address of the network adapters (NIC) ina computer. This tool is typically used in
troubleshooting network issues.
OUTPUT
G Select Command Prompt X
Microsoft Windows [Version 10.e.22621. 674]
(c) Microsoft Corporation. All rights reserved.
C:\Users\mk846> ipconfig
Windows IP Configuration
C:\Users\mk846> ipconfig/all
Windows IP Configuration
:
Host Name Manish
Primary Dns Suffix :
:
Node Type Hybrid
IP Routing Enabled. :
No
WINS Proxy Enabled. : No
Description :
Microsoft Wi-Fi Direct Virtual Adapter
Physical Address. :A8-64-F1-AF- BD- 16
DHCP Enabled. :
Yes
:
Autoconfiguration Enabled Yes
G Select Command Prompt
Wireless LAN adapter Local Area Connection* 2:
Media State :
Media disconnected
Connection- specific DNS Suffix :
Description Microsoft Wi-Fi Direct Virtual Adapter #2
Physical
DHCP
Address
Enabled.
Autoconfiguration
.
Enabled
... :
: AA-64-F1-AF-BD-15
: No
Yes
Non-authoritative answer:
Name: google. com
Addresses: 2404 :6800 : 4007 : 806: :200e
142.250.71.14
1
1 ms 1 ms 1 ms 172.16.1.1
2 20 ms 14 ms 14 ms 103.60.137.65
3 18 ms 14 ms 16 ms 103.60.138.5
.
19 ms
13 ms 12 ms as32934 .maa.. extreme -ix net [45.120.251. 139]
5 33 ms 28 ms 17 ms po102.psw04 maa2.tfbnw. net [129. 134.34.157]
6 14 ms 17 ms 16 ms 173.252.67.161
7 15 ms 18 ms 14 ms edge-star-mini-shv-01-maa2. facebook .com [157.240.23.35]
Trace complete.
C:\Users\mk846>ping 172.16.1.1
Pinging 172.16.1.1 with 32 bytes of data:
Reply from 1 172.16.1.1: bytes=32 time=2ms
-2ms TTL=64
Reply from 172.16.1.1: bytes=32 time=2ms TTL=64
Reply from 172.16.1.1: bytes=32 time=1ms TTL=64
Reply from 172.16.1.1: bytes=32 time=2ms TTL=64
3
MANISH SINGH SURYAVANSHI 2010611011 18
C:\Users\mk846>getmac
C:\Users \mk846>net
The syntax of this command is:
NET
[ ACCOUNTS| COMPUTER | cONFIG CONTINUE | FILE GROUP HELP|
HELPMSG | LOCALGROUP| PAUSE | SESSION| SHARE| START
STATISTICS| STOP| TIME| USE| USER VIEW ]
terface:
Interf 192.168.192.1 --- x10
Internet Address Physical Address Type
192.168.192.255 ff-ff-ff-ff-ff-ff static
224.0.0.22 01-00-5e-00-00-16 static
224.0..251 01-00-5e-00-00-fb static
224.0.0.252 01-00-5e-00-00-fc static
230.0.0.1 01-00-5e-00-00-01 static
G Select Command Prompt
Interface: 172. 16. 184.122 --- 0x11
Internet Address Physical Address Type
172.16.1.1 00-e2-69-0d-9a-f8 dynamic
172.16.100.224 b4-8c-9d- ac-b9-57 dynamic
172.16.101. 190 2a-52-a7 -69-13-86 dynamic
172.16.255. 255 ff-ff-ff-ff-ff-ff static
224.0.0. 22 01-00-5e-00-00-16 static
224.0.0.251 01-00-5e-00-00-fb static
224.0.0.252 01-00-5e-00-00-fc static
230.0.0.1 01-00-5e- 00-00-01 static
239.255.255.250 01-00-5e-7f-ff-fa static
255.255.255.255 ff-ff-ff-ff-ff-ff static
RESULT
Thus, the Network Commands with optionsfor Windows Operating System has been executed
successful.
AIM
Towrite a java program for implementing Socket program to extent communication between two
deferent ends using TCP.
ALGORITHM
SERVER
CLIENT
5
MANISH SINGH SURYAVANSHI 201061101118
Step11. Stop the program
PROGRAM
SERVER
import java.net.*;
import java.io.*;
try
System.out.println("Server started");
socket = server.accept();
System.out.println("Client accepted");
in = new DatalnputStream(new
BufferedlnputStream(socket.getInputStream(0):
while (!line.cquals("Over")
6
MANISH SINGH SURYAVANSHI 2010611011 18
try
line = in.readUTF(0:
System.out.println(line);
catch(1OException i)
System.out.printin(i);
System.out.println("Closing connection");
socket.close();
in.close():
catch(1OException i)
System.out.println(i);
7
MANISH SINGH SURYAVANSHI 2010611011 18
CLIENT
import java.net. *;
import java.io.*;
try
System.out.println("Connected");
catch(UnknownHostException u)
System.out.printn(u);
catch(1OException i)
System.out.println(i);
8
MANISH SINGH SURYAVANSHI 2010611011 18
while (!line.equals("Over"))
try
line = input.readLine();
out.writeUTF(line);
catch(10Exception i)
System.out.println(i);
try
input.close();
out.close0;
socket.close):
catch(10Exception i)
System.out.println(i);
OUTPUT
CAWindows\System32\cmd.exe - java Server CAWindows\System32\cmd.exe - java Client x
RESULT
Thus, the java program for implementing Socket program to extent communication between two
deferent ends using TCP is executed and the output is verified successfully
10
MANISH SINGH SURYAVANSHI 201061101118
Ex. No:3 Date: 18-08-2022
AIM
Towrite a java program for implementing Socket program to extent communication between two
deferent ends using UDP.
ALGORITHM
SERVER
CLIENT
PROGRAM
SERVER
import java.io.IOException;
import java.net.DatagramSocket;
11
MANISH SINGH SURYAVANSHI 2010611011 18
import java.net. SocketException;
while (true)
ds.receive(DpReceive);
System.out.println("Client:-" + data(receive):
if (data(receive).toString).equals("bye"))
break:
if (a == null)
return null;
12
MANISH SINGH SURYAVANSHI 2010611011 18
StringBuilder ret = new StringBuilder();
int i= 0;
ret.append(char) a[i]);
it+:
return ret;
CLIENT
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress:
import java.util.Scanner;
InetAddress ip = InetAddress.getLocalHost();
byte buf[]=null;
while (true)
13
MANISH SINGH SURYAVANSHI 2010611011 18
String inp = sc.nextLine();
buf- inp.getBytes();
DatagramPacket DpSend -new DatagramPacket(buf, buf.length, ip, 1234);
ds.send(DpSend);
if (inp.equals("bye")
break;
OUTPUT
C:\Users\mk&46\On eDrive \Desktop\JAVA PROGRAMS>java udpBaseServer This program is done by: MANISH SINGH SURYAVANSHI 201061101118
This program is done by: MANISH SINGH SURYAVANSHI 201061101118 Hi Server, This is Manish
am running UDP program
I
Client: -Hi Server, This is Manish bye
Client: -I am running UDP program
Client: -bye C:\Users\mk846\ OneDrive\Desktop\JAVA PROGRAMS>
RESULT
Thus, the given program for the connection between the client and server has been established by
using UDP and executed successfully.
14
MANISH SINGH SURYAVANSHI 201061101118
Ex. No: 4 Date: 25-08-2022
AIM
To write a java program for transferring a file between two computers using TCP.
ALGORITHM
SERVER
CLIENT
15
MANISH SINGH SURYAVANSHI 2010611011 18
PROGRAM
SERVER
import java.io.*:
import java.net.*;
class Server4
Socket s=ss.accept);
System.out.println("connected..."):
int r;
while(r-fin.read))!=-1)
dout. write(r);
s.close);
ss.close();
16
MANISH SINGH SURYAVANSHI 2010611011 18
CLIENT
import java.io. *;
import java.net.*:
class Client4
if(s.isConnected)
System.out.println("connected to server");
int r;
while(r=din.rcad())!--1)
fout. write(char)r);
s.close():;
17
MANISH SINGH SURYAVANSHI 2010611011 18
OUTPUT
GCAWindows\System32\cmd.exe GCAWindows\System32\cmd.exe
Microsoft Windows [Version 10.0. 22621. 674] Microsoft Windows [Version 10.0.22621.674]
(c) Microsoft Corporation. All rights reserved. I(c) Microsoft Corporation. All rights reserved.
D:\>javac Server4.java D:\>javac Server4.java
Hi Hi
I am Manish singh and I am sending this file. IamManish singh and I am sending this file.
RESULT
Thus, the java program for transferring file from one machine to another machine using TCP is
executed and the output is verified successfully.
18
MANISH SINGH SURYAVANSHI 2010611011 18
Ex. No: 5 Date: 01-09-2022
AIM
ALGORITHM
SERVER
CLIENT
PROGRAM
SERVER
import java.io.*;
import java.net.*;
class Server5
System.out.println("Server ready");
int a, b, c;
while (true)
fun = receiveRead.readLine():;
if (fun != null)
a= Integer.parselnt(receiveRead.readLine));
System.out.printin("Parameter 1l:"+a);
b= Integer.parselnt(receiveRead.readLine));
if (fun.compareTo("add") =0)
C=a + b:
if (fun.compareTo("sub") =0)
20
MANISH SINGH SURYAVANSHI 2010611011 18
c=a-b:
System.out.println("Substraction ="+ c);
if (fun.compareTo("mul") =0)
C=a* b:
System.out.println("Multiplication ="+c);
if(fun.compareTo("div") ==0)
C=a/ b:
System.out.flush();
CLIENT
import java.io.*;
import java.net.*;
class Client5
21
MANISH SINGH SURYAVANSHI 2010611011 18
public static void main(String[]args) throws Exception
while (true)
temp = keyRead.readLine);
sendMessage = temp.toLowerCase();
pwrite.printin(sendMessage);
sendMessage = keyRead.readLine);
pwrite.println(sendMessage);
sendMessage keyRead.readLine);
pwrite.println(sendMessage);
System.out. flush():
22
MANISH SINGH SURYAVANSHI 2010611011 18
if (receiveMessage = recciveRcad.readLine()) != null)
System.out.printin(receiveMessage);
OUTPUT
CAWindows\System32\cmd.exe -java Servers X CAWindows\System32\cmd.exe- java Client5 X
.
Microsoft Windows [Version 10.0.22621 674]
(c) Microsoft Corporation. All rights reserved. p:\java>javac Client5.java
p:\java>javac Server5.java D:\java>java Client5
D:\java>java Server5 This program is done by: MANISH SINGH SURYAVANSHI 201061101118
This program is done by: MANISH SINGH SURYAVANSHI 201061101118 Client ready, type and press Enter key
. . .
Server ready Enter operation to perform(add, sub, mul, div).
Operation add add
Parameter 1 : 15 Enter first parameter
Addition = 27 15
:
Operation sub
:
Enter second parameter :
Parameter 1 65
= =
Substraction 47 Addition 27
Operation mul
: . . .
Parameter 1 8
=
Enter operation to perform (add, sub, mul, div).
Multiplication 48 sub
Enter first parameter
65
Enter second parameter
:
18
Substraction = 47
Multiplication 48
. . .
Enter operation to perform(add, sub, mul, div).
RESULT
Thus, the Java program for implementing Remote Procedure Call is executed and the output is
verified successfully.
23
MANISH SINGH SURYAVANSHI 201061101118
Ex. No:6 Date: 22-09-2022
AIM
To write a java program for simulating ARP and RARP protocols using TCP.
ALGORITHM
SERVER
PROGRAM
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
int main()
int ch;
clrscr():
fl= fopen("arp_rarp.txt","r");
if ( fl == NULL ) /* check does file exist*/
24
MANISH SINGH SURYAVANSHI 2010611011 18
printf("Cannot open file for reading \n" );
exit(1 );
while(fgets(str1,80,fl)!-NULL)
token = strtok(strl,s);
if (stremp(token,"192. 168.3.2")=0)
else
fclose(fl );
getch();
return 0:
25
MANISH SINGH SURYAVANSHI 2010611011 18
OUTPUT
RESULT
Thus the Java program for implementing ARP/RARP is executed and the output is verified
successfully.
26
MANISH SINGH SURYAVANSHI 201061101118
Ex. No:7 Date: 06-10-2022
AIM
ALGORITHM
Step1. Start the program
Step2. Create a SocketHTTPClient. java file and add the main method
Step3. Input the hostname and provide the default port number as 80
Step4. Create a Socket by passing hostname and port number as parameters.
Step5. Use the PrintWriter class to retrieve the HTML content
Step6. Display the content in the console.
Step7. Stop the program
PROGRAM
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
System.out.println(line);
writer.write(line);
writer.newLine():
reader.close);
writer.close);
OUTPUT
O
File D:/java/data.html A D:\java>javac Main.java
Web History |
Settings | Sign
Search Images Maps Play YouTube News Gmail Drive More in b:\1ava>java Main
RESULT
Thus, the Java program for downloading a web page using HTTP Socket is executed and the output
is verified successfully.
28
MANISH SINGH SURYAVANSHI 2010611011 18
Ex. No: 8 Date: 13-10-2022
AIM
To write a java program for file transfer client-server architecture using tcp-ip protocols.
ALGORITHM
PROGRAM
import java.io.*;
import javax.comm.*;
try
29
MANISH SINGH SURYAVANSHI 2010611011 18
port.setFlowControlMode( SerialPort.FLOWCONTROL NONE );
out.write( msg.getBytes() );
out.flush0;
out.close);
port.close);
catch( Exception e)
OUTPUT
$ java Rs232c.java
Transfered
RESULT
Thus, thejava program using RS232C has been verified and executed successfully.
30
MANISH SINGH SURYAVANSHI 2010611011 18
Ex. No:9 Date: 20-10-2022
AIM
ALGORITHM
PROGRAM
SERVER
import java.rmi.*:
import java.rmi.server.*;
try
31
MANISH SINGH SURYAVANSHI 2010611011 18
RMIServer p-new RMIServer();
Naming.rebind("rmilnterface",p);
catch(Exception e)
String reply:
return reply;
CLIENT
import java.rmi.*:
import java.io.*;
try
32
MANISH SINGH SURYAVANSHI 201061101118
BufferedReader br-new BufferedReader(new InputStreamReader(System.in));
System.out.println("Type something..");
String input=br.readLine():
System.out.println(p.countInput(input));
catch(Exception e)
:
System.out.println("Exception occurred "te.getMessage();
Mylnterface.java
import java.rmi. *;
33
MANISH SINGH SURYAVANSHI 2010611011 18
OUTPUT
CAWindows\System32\cmd.exe -java RMIServer X C\Windows\System32\cmd.exe X
Microsoft Windows [Version 10.0.22621.674] Microsoft Windows [Version 10.0.22621. 674]
(c) Microsoft Corporation. All rights reserved. T(c) Microsoft Corporation. All rights reserved.
D:\java\RMI>javac *.java D:\java\RMI>java RMIClient
p:\java\RMI>set path=C: \Program Files \Java\j dk-17.0.1\bin This program is done by: MANISH SINGH SURYAVANSHI 201061101118
RESULT
Thus, the Java program for implementing Remote Method Invocation is executed and the output is
verified successfully.
34
MANISH SINGH SURYAVANSHI 2010611011 18
Ex. No: 10 Date: 13-10-2022
AIM
ALGORITHM
Step1. Start the program
Step2. Import necessary packages.
Step3. Create the frame and define necessary parameters for frame.
Step4. Using socket get the local host.
Step5. Open the connection using IO Buffer stream.
Step6. Close the connection.
Step7. Stop the program
PROGRAM
import java.net.*;
import java.io.*;
import java.util.*;
if (args.length !=2)
try
name =F
SC.nextLine():
socket.setTimeToLive(0);
socket.joinGroup(group);
ReadThread(socket,group,port));
while(true)
String message;
message = sc.nextLine();
if(message.cqualsIgnoreCase(GroupChat.TERMINATE)
36
MANISH SINGH SURYAVANSHI 2010611011 18
finished = true;
socket.leaveGroup(group);
socket.close();
break;
message =
name +":" message;
DatagramPacket (buffer,buffer.length.group,port);
socket.send(datagram);
catch(SocketException se)
se.printStackTrace();
catch(10Exception ie)
ie.printStackTrace();
37
MANISH SINGH SURYAVANSHI 2010611011 18
private MulticastSocket socket;
this.socket = socket;
this.group group;
this.port = port;
@Override
while(!GroupChat. finished)
DatagramPacket(buffer,buffer.length,group,port);
String message;
try
socket.receive(datagram);
message = new
String(buffer,0,datagram.getLength),"UTF-8");
if(!message.startsWith( GroupChat.name)
38
MANISH SINGH SURYAVANSHI 201061101118
System.out.println(message);
catch(1OException e)
System.out.println("Socket closed!");
OUTPUT
a CAWindows\System32\cmd.exe- java GroupChat 239.0.0.0 4545 CAWindows\System32\cmd.exe- java GroupChat 239.0.0.0 4545
.
X
Microsoft Windows [Version 10.0. 22621 .674] Microsoft Windows [Version 10.0.22621 674]
(c) Microsoft Corporation. All rights reserved. (c) Microsoft Corporation. Al1l rights reserved.
.
D:\javajavac GroupChat java D:\java>javac GroupChat.java
Note: GroupChat.java uses or overrides a deprecated API. Note: GroupChat.java uses or overrides a deprecated API.
Note: Recompile with -Xlint : deprecation for details. Note: Recompile with -Xlint:deprecation for details.
D:\java>java GroupChat 239.0.0.0 4545 D:\java>java GroupChat 239.0.0.0 4545
This program is done by: MANISH SINGH SURYAVANSHI 201061101118 This program is done by: MANISH SINGH SURYAVANSHI 201061101118
Singh: Hi Hi
:
Hello Manish Hello
How are you Manish : How are you
singh: Fine Fine
Singh: And You And You
RESULT
Thus, the java program for implementing the demonstration of network simulators has been verified
and executed successfully.
39
MANISH SINGH SURYAVANSHI 201061101118