Uploaded by Hùng “Kami” Nguyễn Minh

2052504 NguyenMinhHung Lab 1a 1c 3b

advertisement
Ho Chi Minh City
University of
Technology
COMPUTER NETWORK
LAB PART I
HOMEWORK
Student:
Nguyen Minh Hung - 2052504
Lecturer: TS. Nguyen Le Duy Lai
FACULTY of COMPUTER SCIENCE and
COMPUTER ENGINEERING
Ho Chi Minh City, November 2022
Lab 1a
2. Understanding functions of network devices
a. Network Interface Card (NIC)
- NIC functions:
The network card implements the electronic circuitry required to
communicate using a specific physical layer and data link layer standard such
as Ethernet or Wi-Fi. This provides a base for a full network protocol stack,
allowing communication among computers on the same local area network
(LAN) and large-scale network communications through routable protocols,
such as Internet Protocol (IP).
The NIC allows computers to communicate over a computer network,
either by using cables or wirelessly. The NIC is both a physical layer and data
link layer device, as it provides physical access to a networking medium and,
for IEEE 802 and similar networks, provides a low-level addressing system
through the use of MAC addresses that are uniquely assigned to network
interfaces.
- Check NIC of a computer, what is its MAC address?: 34-17-EB-7D-B3-A7
- Cable to connect NIC to a network:
- Type:
+ 10Base2: The cable used is a thin coaxial cable.
+ 10Base5: The cable used is a thick coaxial cable.
+ 10Base-T: The cable used is a twisted-pair (T means twisted pair) and
the speed achieved is around 10 Mbps.
+ 100Base-FX: Makes it possible to achieve a speed of 100 Mbps by
using multimode fiber optic (F stands for Fiber).
+ 100Base-TX: Similar to 10Base-T, but with a speed 10 times greater
(100 Mbps).
+ 1000Base-T: Uses a double-twisted pair of category 5 cables and
allows a speed up to one Gigabit per second.
+ 1000Base-SX: Based on multimode fiber optic uses a short
wavelength signal (S stands for short) of 850 nanometers (770 to 860
nm).
+ 1000Base-LX: Based on multimode fiber optic uses a longwavelength signal (L stands for long) of 1350 nm (1270 to 1355
nm). This network is a widely used network technology because
the cost of such a network is not very high.
+ Standard: IEEE 803.3 10 base 5, IEEE 802.3 10 base 2, IEEE 802.3 10
base T RJ45.
b. Hubs
- Roles of hub in a network: is a network hardware device for connecting
multiple Ethernet devices together and making them act as a single network
segment.
- Main characteristics:
+ It works with broadcasting and shared bandwidth.
+ It has 1 broadcast domain and 1 collision domain
+ Works at the physical layer of the OSI model
+ A virtual LAN can’t be created using a hub
+ Provides support for half-duplex transmission mode
+ A hub has just a single broadcast domain
+ Does not support spanning tree protocol
+ Packet collisions occur mostly inside a hub
- Weaknesses of hub:
+ It’s mostly half-Duplex
+ Does not offer dedicated bandwidth
+ It can not select Network’s Best Path.
+ There is no mechanism of any kind to reduce network traffic.
+ Possibility of the device differentiation
+ Network size
- Hub ports: RJ45
c. Switches
- Roles of switches in a network: A network switch is a computer networking
device that connects various devices together on a single computer network. It
may also be used to route information in the form of electronic data sent over
networks. Since the process of linking network segments is also called
bridging, switches are usually referred to as bridging devices.
- Main characteristics of switches:
+ It is Datalink layer device (Layer 2)
+ It works with fixed bandwidth
+ It maintains a MAC address table
+ Allows you to create virtual LAN
+ It works as a multi-port bridge
+ Mostly comes with 24 to 48 ports
+ Supports half and full-duplex transmission modes
- Differences between hubs and switches:
Hub
Switch
A hub operates on the
physical layer.
A switch operates on the data link
layer.
Hubs perform frame
flooding that can be
unicast, multicast, or
broadcast.
It performs broadcast, then the unicast
and multicast as needed.
Just a singular domain of
collision is present in a
hub.
Varied ports have separate collision
domains.
Transmission mode is
Half-duplex
Transmission mode is Full duplex
Hubs operates as a Layer 1
devices per the OSI model.
Network switches help you to operate
at Layer 2 of the OSI model.
To connect a network of
personal computers should
be joined through a central
hub.
Allow connecting multiple devices and
ports.
Uses electrical signal orbits
Uses frame & packet
Does not offer SpanningTree
Multiple Spanning-Tree is possible
Collisions occur mostly in
setups using hubs.
No collisions occur in a full-duplex
switch.
Hub is a passive device
A switch is an active device
A network hub can’t store
MAC addresses.
Switches use CAM (Content
Accessible Memory) that can be
accessed by ASIC (Application
Specific Integrated Chips).
Not an intelligent device
Intelligent device
Its speed is up to 10 Mbps
10/100 Mbps, 1 Gbps, 10 Gbps
Does not use software
Has software for administration
- Weaknesses of switches:
+ Not as good as a router for limiting Broadcasts
+ Communication between VLAN’s requires inter VLAN routing, but
these days, there are many Multilayer switches available in the market.
+ Handling Multicast packets that requires quite a bit of configuration &
proper designing.
+ Reduces the number of Broadcast domains
- Switch ports: RJ45
d. Routers
- Roles of routers in a network: A router is a device that connects two or more
packet-switched networks or subnetworks. It serves two primary functions:
managing traffic between these networks by forwarding data packets to their
intended IP addresses, and allowing multiple devices to use the same Internet
connection.
- Main characteristics of routers:
+ A router works on the 3rd layer (Network Layer) of the OSI model, and
it is able to communicate with its adjacent devices with the help of IP
addresses and subnet.
+ A router provides high-speed internet connectivity with the different
types of ports like gigabit, fast-Ethernet, and STM link port.
+ It allows the users to configure the port as per their requirements in the
network.
+ Routers' main components are central processing unit (CPU), flash
memory, RAM, Non-Volatile RAM, console, network, and interface
card.
+ Routers are capable of routing the traffic in a large networking system
by considering the sub-network as an intact network.
+ Routers filter out the unwanted interference, as well as carry out the
data encapsulation and decapsulation process.
+ Routers provide the redundancy as it always works in master and slave
mode.
+ It allows the users to connect several LAN and WAN.
+ Furthermore, a router creates various paths to forward the data.
- Differences between routers and switches:
Switch
Router
It connects multiple networked
devices in the network.
It connects multiple switches &
their corresponding networks.
It works on the data link layer of
the OSI model.
It works on the network layer
of the OSI model.
It is used within a LAN.
It can be used in LAN or MAN.
A switch cannot perform NAT or
Network Address Translation.
A router can perform Network
Address Translation.
The switch takes more time while
making complicated routing
decisions.
A router can take a routing
decision much faster than a
switch.
It provides only port security.
It provides security measures to
protect the network from
security threats.
It comes in the category of semiIntelligent devices.
It is known as an Intelligent
network device.
It works in either half or fullduplex transmission mode.
It works in the full-duplex
transmission mode. However,
we can change it manually to
work on half-duplex mode.
It sends information from one
device to another in the form of
Frames (for L2 switch) and the
form of packets (for L3 switch).
It sends information from one
network to another network in
the form of data packets.
Switches can only work with the
wired network.
Routers can work with both
wired & wireless networks.
Switches are available with
different ports, such as 8, 16, 24,
48, and 64.
A router contains two ports by
default, such as Fast Ethernet
Port. But we can also add the
serial ports explicitly.
It uses the CAM (Content
Addressable Memory) table for
the source and destination MAC
address.
It uses the routing table to get
the best route for the
destination IP.
- Router ports: RJ45
d. Access Points
- Roles of access points: An access point serves as the connection point
between wireless and wired networks or as the center point of a stand-alone
wireless network. In large installations, wireless users within the radio range
of an access point can roam throughout a facility while maintaining seamless,
uninterrupted access to the network.
- Main characteristics of access points:
+ Access points are the basic elements of a wireless network – They scan
for the wireless devices in its range and all the neighboring Wi-Fi
systems connect to the Access Point to communicate with the network.
+ Access points offer a standard for connectivity – a, b/g, b/g/n which are
all ratified by IEEE so that the Wi-Fi systems from various vendors can
connect to the network.
+ Access points connect to PC’s, laptops, PDA’s, mobiles, Wi-Fi phones,
Wi-Fi Cameras, Wi-Fi display management systems and a host of other
devices that work on the Wi-Fi standard.
+ Access points can also scan the network for wireless threats and
attacks.
+ Even though Access Points provide wireless access to clients, they are
themselves hooked to the network through Cables (Cat 5E/ Cat6) and
hence the back bone of the wireless networks are most often wired. But
there are exceptions.
- Access point’s interfaces:
+ 802.11a
+ 802.11b
+ 802.11g
+ 802.11n (Wi-Fi 4)
+ 802.11ac (Wi-Fi 5)
+ 802.11ax, (Wi-Fi 6)
- Compare access point and other networking devices mentioned above:
Sr
No.
Access Point
An Access point is a networking
device that allows connecting the
1 devices with the wired network.
An access point is mostly used in
2 LANs(Local Area Networks).
3 Maintenance cost is very high
It covers more laptops, computers
4 and smartphones.
Access Point supports a range up to
2000 sq. ft which is approximately
5 185.806 sq. meters.
Router
A Router works as a sender, receiver and
analyser between data and computer
networks that are linked with it.
A Router is used in both LANs (Local
Area Networks) and WANs(Wide Area
Networks).
Maintenance cost is low as compared to
Access Point.
It covers fewer devices.
Routers support a range of up to 150 ft
(46 m)indoors and 300 ft (92 m)
outdoors.
It is mostly used in large enterprises
which have big offices and
6 buildings.
An Access point can’t function as a
7 router.
An access point can’t deliver the
8 data packets.
It is mostly used in homes , SOHO
working environments and
organizations.
A Router can function as an access
point.
A Router delivers data packets in an
organized way.
e. Modem
Dial-up modem:
- Role: Dial-up connections use modems to decode audio signals into data to
send to a router or computer, and to encode signals from the latter two devices
to send to another modem.
- Characteristics:
ADSL Modem:
- Role: ADSL is a technology that facilitates fast data transmission at a high
bandwidth on existing copper wire telephone lines to homes and businesses
- Characteristics: ADSL is characterized by “high speeds” and “always on”
connectivity. This is achieved by using the frequencies not being used by
voice calls. ADSL was designed to support the typical home Internet user
who downloads frequently rather than uploads data
Cable Modem:
- Role: A cable modem is a type of network bridge that provides bi-directional
data communication via radio frequency channels on a hybrid fibre-coaxial
(HFC), radio frequency over glass (RFoG) and coaxial cable infrastructure.
Cable modems are primarily used to deliver broadband Internet access in the
form of cable Internet, taking advantage of the high bandwidth of a HFC and
RFoG network
- Characteristic:
+ Fast speeds.
+ Reliable Internet connection.
+ Easy to set up and manage.
+ Supports remote troubleshooting.
+ DOCSIS compatibility for more bandwidth channels.
+ MoCA support.
3. Connecting network devices
Identify the type of network cable can be used for below network connections:
a) Computer and hub: straight through
b) Computer and switch: straight through
c) Computer and router: straight through
d) Computer hub and hub: crossover
e) Hub and switch: straight through
f) Hub and router: straight through
g) Switch and switch: straight through
h) Switch and router: straight through
k) Router and router: crossover
Lab 1c
Exercise 1:
public class DownloadHomepage {
public static void download(String webpage) {
try {
// Create URL object
URL url = new URL(webpage);
BufferedReader readr = new BufferedReader(new
InputStreamReader(url.openStream()));
// Enter filename in which you want to download
BufferedWriter writer = new BufferedWriter(new
FileWriter("Download.html"));
// read each line from stream till end
String line;
while ((line = readr.readLine()) != null) {
writer.write(line);
}
readr.close();
writer.close();
System.out.println("Successfully Downloaded.");
} // Exceptions
catch (MalformedURLException mue) {
System.out.println("Malformed URL Exception raised");
} catch (IOException ie) {
System.out.println("IOException raised");
}
}
public static void main(String args[])
throws IOException {
String url = "https://www.google.com/";
download(url);
}
}
Exercise 2 & 3:
// Server class
public class Server
{
// Vector to store active clients
static Vector<ClientHandler> ar = new Vector<>();
// counter for clients
static int i = 0;
public static void main(String[] args) throws IOException
{
// server is listening on port 1234
ServerSocket ss = new ServerSocket(1234);
Socket s;
// running infinite loop for getting
// client request
while (true)
{
// Accept the incoming request
s = ss.accept();
System.out.println("New client request received : " + s);
// obtain input and output streams
DataInputStream dis = new DataInputStream(s.getInputStream());
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
System.out.println("Creating a new handler for this client...");
// Create a new handler object for handling this request.
ClientHandler mtch = new ClientHandler(s,"client " + i, dis, dos);
// Create a new Thread with this object.
Thread t = new Thread(mtch);
System.out.println("Adding this client to active client list");
// add this client to active clients list
ar.add(mtch);
// start the thread.
t.start();
// increment i for new client.
// i is used for naming only, and can be replaced
// by any naming scheme
i++;
}
}
}
// ClientHandler class
class ClientHandler implements Runnable
{
Scanner scn = new Scanner(System.in);
private String name;
final DataInputStream dis;
final DataOutputStream dos;
Socket s;
boolean isloggedin;
// constructor
public ClientHandler(Socket s, String name,
DataInputStream dis, DataOutputStream dos) {
this.dis = dis;
this.dos = dos;
this.name = name;
this.s = s;
this.isloggedin=true;
}
@Override
public void run() {
String received;
while (true)
{
try
{
// receive the string
received = dis.readUTF();
System.out.println(received);
if(received.equals("logout")){
this.isloggedin=false;
this.s.close();
break;
}
// break the string into message and recipient part
StringTokenizer st = new StringTokenizer(received, "#");
String MsgToSend = st.nextToken();
String recipient = st.nextToken();
// search for the recipient in the connected devices list.
// ar is the vector storing client of active users
for (ClientHandler mc : Server.ar)
{
// if the recipient is found, write on its
// output stream
if (mc.name.equals(recipient) && mc.isloggedin==true)
{
mc.dos.writeUTF(this.name+" : "+MsgToSend);
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
try
{
// closing resources
this.dis.close();
this.dos.close();
}catch(IOException e){
e.printStackTrace();
}
}
}
// Client class
public class Client
{
final static int ServerPort = 1234;
public static void main(String args[]) throws UnknownHostException,
IOException
{
Scanner scn = new Scanner(System.in);
// getting localhost ip
InetAddress ip = InetAddress.getByName("localhost");
// establish the connection
Socket s = new Socket(ip, ServerPort);
// obtaining input and out streams
DataInputStream dis = new DataInputStream(s.getInputStream());
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
// sendMessage thread
Thread sendMessage = new Thread(new Runnable()
{
@Override
public void run() {
while (true) {
// read the message to deliver.
String msg = scn.nextLine();
try {
// write on the output stream
dos.writeUTF(msg);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
// readMessage thread
Thread readMessage = new Thread(new Runnable()
{
@Override
public void run() {
while (true) {
try {
// read the message sent to this client
String msg = dis.readUTF();
System.out.println(msg);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
sendMessage.start();
readMessage.start();
}
}
LAB 3B:
I. nslookup
1. Run nslookup to obtain the IP address of a Web server in
Asia. What is the IP address of that server?
Answer: I used nslookup on a Web server in Asia, which is
www.aiit.or.kr. Its IP address is 58.229.6.225
2. Run nslookup to determine the authoritative DNS servers
for a university in Europe.
Answer: I used nslookup on a server of the Oxford University,
located in Great Britain. Its IP address is 151.101.194.216
3. Run nslookup so that one of the DNS servers obtained in
Question 2 is queried for the mail servers for Yahoo! mail.
What is its IP address?
Answer: The IP address for the mail server is 18.0.72.3
4. Locate the DNS query and response messages. Are then sent
over UDP or TCP?
Answer: They are sent over UDP.
5. What is the destination port for the DNS query message? What is the
source port of DNS response message?
Answer:
The destination port of DNS query message is 53
The source port of DNS response message is 53
6. To what IP address is the DNS query message sent? Use ipconfig to
determine the IP address of your local DNS server. Are these two IP
addresses the same?
Answer: The DNS query message was sent to 192.168.1.1
The IP address of my local DNS server is the same as the IP address which the
DNS query message was sent to.
7. Examine the DNS query message. What “Type” of DNS query is it? Does
the query message contain any “answers”?
Answer: It’s a type A standard query and it doesn’t contain any answers.
8. Examine the DNS response message. How many “answers” are provided?
What do each of these answers contain?
Answer: There are 3 answers that were provided by the DNS response message.
Each of them contains the name of the host, the type of address, class, the time to
live, the data length and the IP address.
9. Consider the subsequent TCP SYN packet sent by your host. Does the
destination IP address of the SYN packet correspond to any of the IP
addresses provided in the DNS response message?
Answer: The first SYN packet was sent to 104.16.45.99 which corresponds to the
first IP address provided in the DNS response message.
10. This web page contains images. Before retrieving each image, does your
host issue new DNS queries?
Answer: No. The host doesn’t issue new DNS queries.
11. What is the destination port for the DNS query message? What is the
source
port of DNS response message?
Answer: The destination port for the DNS query message is 53.
The source port for of DNS response message is also 53.
12. To what IP address is the DNS query message sent? Is this the IP address
of your default local DNS server?
Answer: The IP address to which the DNS query message sent is 192.168.1.1
It is also the IP address of my default local DNS server.
13. Examine the DNS query message. What “Type” of DNS query is it? Does
the query message contain any “answers”?
Answer: The query is Type A and it doesn’t contain any answers.
14. Examine the DNS response message. How many “answers” are provided?
What do each of these answers contain?
Answer: One answer is provided and it contains the name of the host, the type,
the class, the time to live, the data length and the address.
15. Provide a screenshot.
16. To what IP address is the DNS query message sent? Is this the IP address
of your default local DNS server?
Answer: The DNS query message was sent to 192.168.1.1. This is affirmative as
the IP address of my default local DNS server.
17. Examine the DNS query message. What “Type” of DNS query is it? Does
the query message contain any “answers”?
Answer: The type of DNS query is NS. And it doesn’t contain any answers.
18. Examine the DNS response message. What MIT name servers does the
response message provide? Does this response message also provide the IP
addresses of the MIT name servers?
Answer: The MIT name servers which response message provide are use2, ns137, asia1, ns1-173, usw2, asia2, use5, eur5. We can see the IP addresses of the
MIT name servers by clicking them to see their additional information.
19. Provide a screenshot.
20. To what IP address is the DNS query message sent? Is this the IP address
of your default local DNS server? If not, what does the IP address
correspond to?
Answer: The IP address to which the DNS query message was sent is 18.0.72.3
and this is not the IP address of my default local server. This IP address
correspond to the server of aiit.or.kr in which my host tried to send to query
message to.
21. Examine the DNS query message. What “Type” of DNS query is it? Does
the query message contain any “answers”?
Answer: The URL of the server is probably removed or was privated as the
server didn’t provide me any answers apart from “Time-out request”.
22. Examine the DNS response message. How many “answers” are provided?
What does each of these answers contain?
Answer: As mentioned in the 22nd question. I can not access the DNS response
message of the server as it didn’t sent me any responses.
23. Provide a screenshot.
Download