You are on page 1of 26

Faculty of Engineering and Technology

Department of Electrical and Computer Engineering


Communication and Computer Networks
ENCS433

Project#1

Student Name: Layth Abufarhah.

Student1 ID: 1162636.

Partner Name: Ali Shoman.

Partner ID: 1171204.

Partner Name: Loris Tarazi.

Partner ID: 1170691.

Teacher Name: Abdalkarim Awad.

Date :27 / 10 / 2019


 Contents:-
 Abstract.
 Theory.
 Procedure & Discussion.
 Conclusion & Feedback.
 References.
 Appendix.

2
 1) Abstract :
This project aims to:
 Build a simple network using a cable between two computers.
 Build a simple network using an access point between two computers.
 Learn more about ping, tracert and nslookup commands and what is
their output.
 Implement a simple but a complete web server in python or java
listening on port 1900.

3
 2) Theory :
1) Simple network between two computers:-

a) Simple network using a LAN cable:

Dropping an Ethernet cable makes things simple with faster data


speed. The cheapest of CAT5e cable supports speeds up to 1000
Mbps. To give some perspective, USB 2.0 supports speeds up to 480
Mbps. So, transferring data over Ethernet should be the obvious
choice.

The main advantage of using the Ethernet cable method is faster


transfer speeds,at least faster than the regular flash drives and Wi-Fi.
When having a lot of data to transfer then using the Ethernet cable is
the best way to go.

b) Simple network using a access point:

Connecting up to another laptop wirelessly provides transferring


some data without a router or Internet connection, Without an
Internet connection it is not possible to use syncing services like
Dropbox to share data between devices easily. If there is a
networking device like a router, hub or switch, then getting two
computers to talk to each other is easy, but it requires quite a bit of
additional work (file sharing, permissions, firewall conf., etc).

4
2) ping, tracert and nslookup commands:
a) ping command: is a Command Prompt command used to test the
ability of the source computer to reach a specified destination
computer. The ping command is usually used as a simple way to
verify that a computer can communicate over the network with
another computer or network device.

The ping command operates by sending Internet Control Message


Protocol (ICMP) Echo Request messages to the destination computer
and waiting for a response. How many of those responses are
returned, and how long it takes for them to return, are the two major
pieces of information that the ping command provides.

b) tracert command: is a Command Prompt command that's used to


show several details about the path that a packet takes from the
source computer or device to whatever destination specified.
It works by sending several test packets of data to a specified
destination address, and records each intermediate router or link
passed by the data on it's journey. Each router encountered
represents a hop, and is also known as a node. It's common for data
to have several hops before it reaches it's destination.

c) nslookup command: is a network administration command-line tool


available in many computer operating systems for querying the
Domain Name System (DNS) to obtain domain name or IP address
mapping, or other DNS records. The name "nslookup" means "name
server lookup".

5
3) Simple Complete web server in java:
Web server: is a computer where the web content is stored. Basically
web server is used to host the web sites but there exists other web
servers also such as gaming, storage, FTP, email etc.

Java is one of the most used programming languages in the World. The
JDK comes with a lot of exciting features. In that video, we are going to
use the ServerSocket and the Socket classes to create a simple HTTP
Web Server in Java.

6
 3) Procedure & Discussion:
1) Building a Simple network between two computers:-
a) Simple network using a LAN cable:
1- Two computers were connected using a LAN cable as shown in pic1.

Pic: 1

7
2- The directory of control panel was opened on the first computer
(Control Panel\Network and Internet\Network and Sharing
Center\Advanced sharing settings).
3- Sharing was turned on so anyone with network access can read and
write files in the public folders.
4- Password protected sharing was turned off as shown in figure: 1.1.

Fig: 1.1

8
5- The directory of control panel was opened.
(Control Panel\Network and Internet\Network and Sharing
Center).
6- The internet protocol version 4 (TCP/IPv4) properties was set as
shown in figure: 1.2.

Fig: 1.2
7- Previous steps(2-6) were repeated to the second computer.
Switch 192.168.1.7 by 192.168.1.8.

9
8- A file of size 634 MB was sent from the first computer to the
second.
9- The time of sending the file was obtained 58.36 seconds as shown
in figure: 1.3 and figure: 1.4.

Fig: 1.3 Fig: 1.4

10
b) Simple network using a access point:
1- Two computers were connected using a hotspot mobile.
2- The IP address of the first computer was: 192.168.43.186 and the
IP address of the second computer was: 192.168.43.4 as shown in
figure: 1.5 and figure: 1.6.

Fig: 1.5

Fig: 1.6

3- A file of size 634 MB was sent from the first computer to the
second.

11
4- The time of sending the file was obtained 4 minutes and 33.76
seconds as shown in figure: 1.7 and figure: 1.8.

Fig: 1.7 Fig: 1.8

12
2) ping, tracert and nslookup commands:-
a) ping command:

Fig: 2.1

The 0% loss reported under Ping statistics for 34.197.17.4 explains


that each ICMP Echo Request message sent to www.stanford.edu
was returned. This means that, as far as this network connection
goes, it can communicate with stanford's website just fine, the
number of packets sent is the default of ping four packets of size 32
bytes and all responses were returned with average time 199ms.

13
b) tracert command:

Fig: 2.2

Each row represents a different hop with 30 as a maximum number


of hops. Each hop is numbered, so this trace took 21 hops to reach
the destination server, ec2-34-197-17-4.compute-1.amazonaws.com
[34.197.17.4], which serves the stanford website.

Each row is displayed in 5 columns. The first column is simply the


number of the hop. Traceroute will actually send three packets of
data, and measure the time taken for each.

From these results you can see that it took between 200 and 217
milliseconds to retrieve data from the destination server, as shown in
the last hop.
14
c) nslookup command:

Fig: 2.3

In this case, a “non-authoritative answer” notification is given, as the


local DNS server was unable to answer the query itself, and instead
had to contact one or more other name servers.

The non-authoritative answer of name server is:mcluster90-


elbwpeel-1jjv8xqi5kd5g-1169217295.us-east-1.elb.amazonaws.com

With IP’s: 34.197.17.4, 34.196.104.129 and different aliases:


www.stanford.edu.

stanfordhs17.wpengine.com.

lbmaster-90886.wpengine.com.

15
3) Implementation of a simple complete web server in java:-
1- The server was implemented in java programming language as follow:-
// A Java program for a Server
import java.net.*;
import java.util.*;
import java.io.*;
public class Server {
private Socket socket = null;
private ServerSocket server = null;
private Scanner scan = null;
private PrintWriter print=null;
public Server(int port) {
//waits for a connection
try {
server = new ServerSocket(port);
System.out.println("Server started");
System.out.println("Waiting for a client ...");
socket = server.accept();
System.out.println("Client accepted");
System.out.println("------------------------------------------");
// takes input from the client socket
scan = new Scanner(socket.getInputStream());
print=new PrintWriter(socket.getOutputStream(),true);
String line = "";
try {
int sb=0,sa=0;
while (true){
sb=line.length();
line = line + scan.nextLine();
sa=line.length();
//this mean nothing to read
if(sa==sb)break;

16
line=line+"\n";
}
//to check if the request doesn't start with GET
//line=line.substring(1);
System.out.println(line);
if(line.startsWith("GET")){
print.println("HTTP/1.1 200 OK");
print.println("Connection: close");
print.println("Date: " + new Date());
print.println("Content-Type: text/html");
print.println();
print.println("
<html>
<head>
<title>Simple Webserver</title>
</head>
<body>
<table border='1'>
<thead>
<td>Name</td>
<td>ID</td>
</thead>
<tr>
<td><b>Layth Abufarhah</b></td>
<td><b>1162636</b></td>
</tr>
<tr>
<td><b>Loris Tarazi</b></td>
<td><b>1170691</b></td>
</tr>
<tr><td><b>Ali Shoman</b></td>
<td><b>1171204</b></td>
</tr>
17
</table>
<p>Welcome to <span style='color:green'>Computer
Networks<span></p>
<p>IP Address: "+socket.getInetAddress()+"</p><p>Port Number:
"+socket.getPort()+"
</p>
</body>
</html>
");
}else{
print.println("HTTP/1.1 405 Method Not
Allowed");
print.println("Cache-Control: no-cache");
print.println("Pragma: no-cache");
print.println("Date: " + new Date());

print.println("Content-Type:
application/json;

charset=utf-8");
print.println();
print.println("{"+"\"Message\""+":"+"\"The
requested resource does not support http method.\""+"}");
}
} catch (Exception i) {
System.out.println(i);
}
System.out.println("Closing connection");
// close connection
socket.close();
scan.close();
} catch (IOException i) {
System.out.println(i);
}
18
}
public static void main(String args[]) {
Server server = new Server(1900);
}
}
2- The java file was compiled, this mean that the server was ready and
waiting to serve a client’s requests.
3- A Get message request was sent from the client (firefox browser) after
accepting from the same computer.
4- An appropriate message was responded to the browser to display
(html file).
Figure: 3.1 show the request message.
Figure: 3.2 show the displayed response.

Fig: 3.1

19
Fig: 3.2

5- A message request which is doesn’t start with GET (it made by an


arbitrary error in server) was sent from the client (firefox browser)
after accepting from the same computer.
line=line.substring(1); the first line of the request was missed.
6- An appropriate message was responded (405 Method not allowed) to
the browser to display.

Figure: 3.3 show the request message.

Figure: 3.4 show the displayed response.

20
Fig: 3.3

Fig: 3.4

Fig: 3.5

21
7- A mobile was connected to the same network with computer.
8- Ipconfig command was used to get the IP address of the computer as
shown in figure: 3.6.

Fig: 3.6

9- A Get message request was sent from the client (chrome browser)
after accepting from the mobile.
10- An appropriate message was responded to the browser to display
(html file).

Figure: 3.7 show the request message.

Figure: 3.8 show the displayed response.

Fig: 3.7

22
Fig: 3.8

23
 4) Conclusion & Feedback:
In this project, we became familiar with simple networks and the
connections of computers and we also learned more about some commands
like ping, tracert and nslookup, and how to implement a simple web server.

This project was useful as we learned to deal with networks and their
connections and to see a simple example of what we learned in
communication and computer networks course so it was very exciting.

24
 5) References:
https://www.lifewire.com
date: 24/10/2019.
https://www.online-tech-tips.com
date: 24/10/2019.
https://techwiser.com
date: 24/10/2019.
https://dart.dev
date: 25/10/2019.
https://www.ibm.com
date: 25/10/2019.

25
 6) Appendix:

26

You might also like