You are on page 1of 13

School of Information Technology and Engineering

Winter 2018-19

M.Tech (Software Engineering)

SWE2002 Computer Networks

Assessment 1

Name: V.Harsha Vardhan

Reg No: 17MIS0076

Slot: L19+20

Venue: SJT-216

1. Study and test the functionality of basic networking commands in the laboratory.

A.) PING

i) What is the IP address of www.vit.ac.in ?

Ans: 10.10.2.198

ii) Check whether TCP/IP is properly installed and functioning in your system.

Ans: Yes, the TCP/IP is properly installed and functioning in my system

iii) Indicate what percentage of packets sent resulted in a successful response. For the packets
from which you received a response, write down the minimum, average and maximum round trip
times in milliseconds.

Ans: 4 packets transmitted, 4 received so 100% successful response.


minimum round trip time = 0.361 ms
average round trip time = 0.402 ms
maximum round trip time = 0.449 ms

iv) Increase or Decrease the Time Interval between Packets. Write the response.

Ans: ping -i 5 www.vit.ac.in


The above command increases the time interval between any two packets by 5 seconds i.e after
recieving one packet the server waits for 5 seconds before sending the next packet.
ping -i 0.1 www.vit.ac.in
The above command decreases the time interval between any two packets by 0.1 seconds i.e after
recieving one packet the server sends the next packet within 0.1 seconds
v) Send 6 packets .Indicate what percentage of the packets resulted in a successful response.

Ans: ping -c 6 www.vit.ac.in


6 packets transmitted, 6 received, 0% packet loss, time 4997ms.
The above command is used to send six packets and since there is 0% packets loss, it is
100%successful response.

vi) Print Only Ping Command Summary Statistics.

Ans: ping -c 6 -q www.vit.ac.in


The above command is used to print only ping command summary statistics.
PING vit.ac.in (10.10.2.198) 56(84) bytes of data.

--- vit.ac.in ping statistics ---


6 packets transmitted, 6 received, 0% packet loss, time 4999ms
rtt min/avg/max/mdev = 0.317/0.412/0.517/0.081 ms

vii) Change Ping Packet Size of 512, 1024 bytes of data. Write the response.

Ans: ping -s 512 www.vit.ac.in


Response: PING vit.ac.in (10.10.2.198) 512(540) bytes of data.
520 bytes from vit.ac.in (10.10.2.198): icmp_seq=1 ttl=61 time=0.576 ms
ping -s 1024 www.vit.ac.in
Reaponse: PING vit.ac.in (10.10.2.198) 1024(1052) bytes of data.
1032 bytes from vit.ac.in (10.10.2.198): icmp_seq=1 ttl=61 time=0.514 ms

viii) Execute the Timeout option for 5 seconds.

Ans: ping -w 5 www.vit.ac.in


The above example will ping for 5 seconds. i.e ping command will exit after 5 seconds irrespective
of how many packets are sent or received.

ix) Write the current version of ping program.

x) For some of the hosts, you may not have received any responses for the packets you have sent.
What are the reasons for not getting a response?

Ans:
1. It means that your ICMP packet (ping) was silently discarded with no response sent.
2. probably disabled ping response for security reasons.

B.) IFCONFIG/IPCONFIG

i) What is the MAC address of the network interface card of your system?

Ans: b4:b5:2f:da:4f:a6

ii) What is the IP address of your system?

Ans: 10.30.140.45
iii) Find out all the network interfaces connected to your system.

Ans: ifconfig -a
eth0 Link encap:Ethernet HWaddr b4:b5:2f:da:4f:a6
inet addr:10.30.140.45 Bcast:10.30.140.255 Mask:255.255.255.0
inet6 addr: fe80::b6b5:2fff:feda:4fa6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:40540 errors:0 dropped:0 overruns:0 frame:0
TX packets:18122 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:50148654 (50.1 MB) TX bytes:2301529 (2.3 MB)
Interrupt:20 Memory:f7100000-f7120000

lo Link encap:Local Loopback


inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:177 errors:0 dropped:0 overruns:0 frame:0
TX packets:177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0

iv) Display the Network Settings of Specific Interface.

Ans: ifconfig eth0


eth0 Link encap:Ethernet HWaddr b4:b5:2f:da:4f:a6
inet addr:10.30.140.45 Bcast:10.30.140.255 Mask:255.255.255.0
inet6 addr: fe80::b6b5:2fff:feda:4fa6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:40540 errors:0 dropped:0 overruns:0 frame:0
TX packets:18122 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:50148654 (50.1 MB) TX bytes:2301529 (2.3 MB)
Interrupt:20 Memory:f7100000-f7120000

C.) HOSTNAME

i) Find the name of your system?

Ans: DESKTOP-A6R68GV

ii) What is the significance of the name?

Ans: A hostname is a label that is assigned to a device connected to a computer network and that is
used to identify the device in various forms of electronic communication, such as the World Wide
Web.
D.) NETSTAT

i) List Various Listening Ports.

Ans: netstat -a
Active Connections
Proto Local Address Foreign Address State
TCP 0.0.0.0:135 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:445 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:3306 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:3648 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:5040 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:5700 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:7779 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:9012 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:49664 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:49665 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:49666 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:49667 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:49668 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:49669 DESKTOP-A6R68GV:0 LISTENING
TCP 0.0.0.0:51910 DESKTOP-A6R68GV:0 LISTENING
TCP 127.0.0.1:5240 DESKTOP-A6R68GV:0 LISTENING
TCP 127.0.0.1:8884 DESKTOP-A6R68GV:0 LISTENING
TCP 127.0.0.1:9222 DESKTOP-A6R68GV:0 LISTENING

ii) List TCP Ports connections


Ans: netstat -at
Active Connections
Proto Local Address Foreign Address State Offload State

TCP 0.0.0.0:135 DESKTOP-A6R68GV:0 LISTENING InHost


TCP 0.0.0.0:445 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:3306 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:3648 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:5040 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:5700 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:7779 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:9012 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:49664 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:49665 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:49666 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:49667 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:49668 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:49669 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 0.0.0.0:51910 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 127.0.0.1:5240 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 127.0.0.1:5240 DESKTOP-A6R68GV:53155 ESTABLISHED InHost
TCP 127.0.0.1:8884 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 127.0.0.1:9222 DESKTOP-A6R68GV:0 LISTENING InHost
TCP 127.0.0.1:53155 DESKTOP-A6R68GV:5240 ESTABLISHED InHost
TCP 172.16.231.7:139 DESKTOP-A6R68GV:0 LISTENING InHost
iii) List UDP Ports connections

Ans: netstat -au


UDP 0.0.0.0:1900 *:*
UDP 0.0.0.0:5050 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5353 *:*
UDP 0.0.0.0:5355 *:*
UDP 0.0.0.0:12700 *:*
UDP 0.0.0.0:51910 *:*
UDP 127.0.0.1:1900 *:*
UDP 127.0.0.1:49666 *:*
UDP 127.0.0.1:55734 *:*
UDP 127.0.0.1:58636 *:*
UDP 172.16.231.7:137 *:*
UDP 172.16.231.7:138 *:*
UDP 172.16.231.7:1900 *:*
UDP 172.16.231.7:55733 *:*
UDP 172.16.231.7:58635 *:*
UDP [::]:5353 *:*
UDP [::]:5353 *:*
UDP [::]:5355 *:*
UDP [::]:51910 *:*
UDP [::1]:1900 *:*
UDP [::1]:58634 *:*
UDP [fe80::925:d0cc:244c:513d%3]:1900 *:*
UDP [fe80::925:d0cc:244c:513d%3]:58633 *:*

iv) List all the LISTENING Connections

Ans: netstat -l
TCP [::]:135 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:445 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:3306 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:3648 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:5700 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:7779 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:49664 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:49665 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:49666 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:49667 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:49668 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:49669 DESKTOP-A6R68GV:0 LISTENING
TCP [::]:51910 DESKTOP-A6R68GV:0 LISTENING
TCP [::1]:49853 DESKTOP-A6R68GV:0 LISTENING
UDP [::]:5353 *:*
UDP [::]:5353 *:*
UDP [::]:5355 *:*
UDP [::]:51910 *:*
UDP [::1]:1900 *:*
UDP [::1]:58634 *:*
v) Find the statistics of all protocols.

Ans: netstat -s
IPv4 Statistics

Packets Received = 1182860


Received Header Errors =0
Received Address Errors = 251
Datagrams Forwarded =0
Unknown Protocols Received =0
Received Packets Discarded = 40091
Received Packets Delivered = 1157597
Output Requests = 555391
Routing Discards =0
Discarded Output Packets = 1111
Output Packet No Route = 108
Reassembly Required =8
Reassembly Successful =1
Reassembly Failures =0
Datagrams Successfully Fragmented = 0
Datagrams Failing Fragmentation = 0
Fragments Created =0

IPv6 Statistics

Packets Received = 6716


Received Header Errors =0
Received Address Errors = 2498
Datagrams Forwarded =0
Unknown Protocols Received =0
Received Packets Discarded = 1373
Received Packets Delivered = 5311
Output Requests = 3151
Routing Discards =0
Discarded Output Packets =0
Output Packet No Route =0
Reassembly Required =0
Reassembly Successful =0
Reassembly Failures =0
Datagrams Successfully Fragmented = 0
Datagrams Failing Fragmentation = 0
Fragments Created =0

ICMPv4 Statistics

Received Sent
Messages 506 2625
Errors 0 0
Destination Unreachable 202 1962
Time Exceeded 254 0
Parameter Problems 0 0
Source Quenches 0 0
Redirects 0 0
Echo Replies 44 4
Echos 6 659
Timestamps 0 0
Timestamp Replies 0 0
Address Masks 0 0
Address Mask Replies 0 0
Router Solicitations 0 0
Router Advertisements 0 0

ICMPv6 Statistics

Received Sent
Messages 51 150
Errors 0 0
Destination Unreachable 0 0
Packet Too Big 0 0
Time Exceeded 0 0
Parameter Problems 0 0
Echos 0 0
Echo Replies 0 0
MLD Queries 0 0
MLD Reports 0 0
MLD Dones 0 0
Router Solicitations 0 90
Router Advertisements 0 0
Neighbor Solicitations 0 30
Neighbor Advertisements 51 30
Redirects 0 0
Router Renumberings 0 0

TCP Statistics for IPv4

Active Opens = 4800


Passive Opens = 46
Failed Connection Attempts = 226
Reset Connections = 705
Current Connections = 20
Segments Received = 647302
Segments Sent = 217691
Segments Retransmitted = 3573

TCP Statistics for IPv6

Active Opens =2
Passive Opens =0
Failed Connection Attempts =4
Reset Connections =0
Current Connections =0
Segments Received = 12
Segments Sent =8
Segments Retransmitted =4

UDP Statistics for IPv4

Datagrams Received = 270724


No Ports = 30395
Receive Errors = 253352
Datagrams Sent = 332900

UDP Statistics for IPv6

Datagrams Received = 7476


No Ports = 916
Receive Errors = 457
Datagrams Sent = 2345

vi) Display Kernel IP routing table.

Ans: netstat -r
=======================================================================
====
Interface List
10...98 40 bb 14 b8 9a ......Realtek PCIe FE Family Controller
12...e6 02 9b f4 13 1b ......Microsoft Wi-Fi Direct Virtual Adapter
22...e4 02 9b f4 13 1c ......Microsoft Wi-Fi Direct Virtual Adapter #3
13...00 ff 5c 1b 46 77 ......TAP-Windows Adapter V9
3...e4 02 9b f4 13 1b ......Intel(R) Dual Band Wireless-AC 3160
1...........................Software Loopback Interface 1
=======================================================================
====

IPv4 Route Table


=======================================================================
====
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 172.16.224.1 172.16.231.7 55
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-link 127.0.0.1 331
172.16.224.0 255.255.248.0 On-link 172.16.231.7 311
172.16.231.7 255.255.255.255 On-link 172.16.231.7 311
172.16.231.255 255.255.255.255 On-link 172.16.231.7 311
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 172.16.231.7 311
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-link 172.16.231.7 311
=======================================================================
====
Persistent Routes:
None
IPv6 Route Table
=======================================================================
====
Active Routes:
If Metric Network Destination Gateway
1 331 ::1/128 On-link
3 311 fe80::/64 On-link
3 311 fe80::925:d0cc:244c:513d/128
On-link
1 331 ff00::/8 On-link
3 311 ff00::/8 On-link
=======================================================================
====
Persistent Routes:
None

vii) Show the Kernel interface table, similar to ifconfig command.

Ans: netstat -ie


eth0 Link encap:Ethernet HWaddr b4:b5:2f:da:4f:a6
inet addr:10.30.140.45 Bcast:10.30.140.255 Mask:255.255.255.0
inet6 addr: fe80::b6b5:2fff:feda:4fa6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:40540 errors:0 dropped:0 overruns:0 frame:0
TX packets:18122 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:50148654 (50.1 MB) TX bytes:2301529 (2.3 MB)
Interrupt:20 Memory:f7100000-f7120000

lo Link encap:Local Loopback


inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:177 errors:0 dropped:0 overruns:0 frame:0
TX packets:177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0

viii) By simply opening a browser connection to HTTP (port 80) server (while still offline!) what
will be status of netstat command?

ix) Display Service name with PID.

Ans: netstat -tp


Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign
Address State
PID/Program name tcp 0 0 192.168.0.2:ssh 192.168.0.1:egs ESTABL
ISHED 2179/sshd
E.) TRACEROUTE or TRACERT

i) Write the function of this command.

Ans: The tracert command displays a list of all the routers that a packet must go through to get from
the computer where tracert is run to any other computer on the internet.

F.) NSLOOKUP

i) What is the IP address and name of the machine www.google.com?

Ans: nslookup google.com


Server: UnKnown
Address: 172.16.224.1

Non-authoritative answer:
Name: google.com
Addresses: 2404:6800:4002:808::200e
216.58.196.206

G.) ARP

1. How do you show the full ARP table for your machine? Capture a printout of what it is. Explain
each column of what is printed.

2. Write a Java program to run the basic networking commands.


Ans:
import java.net.*;
public class MyAddress {
public static void main (String[] args) {
try {
InetAddress address = InetAddress.getLocalHost( );
System.out.println(address);
}
catch (UnknownHostException e) {
System.out.println("Could not find this computer's address.");
}
}
}

3. Write a java program to display the name of the computer and its IP address that you are
currently working on.
Ans:
for ip-address
import java.net.*;
public class MyAddress {
public static void main (String[] args) {
try {
InetAddress address = InetAddress.getLocalHost( );
System.out.println(address);
}
catch (UnknownHostException e) {
System.out.println("Could not find this computer's address.");
}
}
}
For name
import java.net.*;
public class ReverseTest {
public static void main (String[] args) {
try {
InetAddress ia = InetAddress.getByName("10.30.140.45");
System.out.println(ia.getHostName( ));
}
catch (Exception e) {
System.err.println(e);
}
}

4. Write a java program to print the IP address of www.google.com and all IP addresses of
www.microsoft.com .

Ans:
For google
import java.net.*;
public class AllAddressesOfgoogle {
public static void main (String[] args) {
try {
InetAddress[] addresses = InetAddress.getByName("www.google.com");
for (int i = 0; i < addresses.length; i++) {
System.out.println(addresses[i]);
}
}
catch (UnknownHostException e) {
System.out.println("Could not find www.microsoft.com");
}
}
}

For Microsoft
import java.net.*;
public class AllAddressesOfgoogle {
public static void main (String[] args) {
try {
InetAddress[] addresses = InetAddress.getAllByName("www.google.com");
for (int i = 0; i < addresses.length; i++) {
System.out.println(addresses[i]);
}
}
catch (UnknownHostException e) {
System.out.println("Could not find www.microsoft.com");
}
}
}
5. Write a java program to print all Network Interfaces of “localhost”.

Ans:
import java.io.*;
import java.net.*;
import java.util.*;
import static java.lang.System.out;
public class ListNets
{
public static void main(String args[]) throws SocketException
{
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets))
displayInterfaceInformation(netint);
}
static void displayInterfaceInformation(NetworkInterface netint) throws SocketException
{
out.printf("Display name: %s\n", netint.getDisplayName());
out.printf("Name: %s\n", netint.getName());
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
out.printf("InetAddress: %s\n", inetAddress);
}
out.printf("\n");
}
}

6. Write a java program to download the contents associated with a HTTP URL and save it in a
file.

Ans:

import java.io.*;
import java.net.*;
public class JavaGetUrl {
public static void main (String[] args) {
URL u;
InputStream is = null;
DataInputStream dis;
String s;
try {
u = new URL("http://200.210.220.1:8080/index.html");
is = u.openStream(); // throws an IOException
dis = new DataInputStream(new BufferedInputStream(is));
while ((s = dis.readLine()) != null)
{
System.out.println(s);
}
}
catch (MalformedURLException mue)
{
System.out.println("Ouch - a MalformedURLException happened.");
mue.printStackTrace();
System.exit(1);
}
catch (IOException ioe)
{
System.out.println("Oops- an IOException happened.");
ioe.printStackTrace();
System.exit(1);
}
finally{
try
{
is.close();
}
catch (IOException ioe) {}
}
}
}

You might also like