Faculty of Computer Science and Engineering - HCMC University of Technology
Department of Systems and Networks
1. (LAB1) Overview of the network and network devices
Introduction: In this lab, we will explore various network devices and illustrate the connections between devices. The works include:
● Introduction to network devices
● Connections between network devices:
○ (i) PCs to switch (ii) PC to PC and DHCP server (iii) PC to internet through NAT interface and (iv) PC to HTTP web server
● Programming an application with network connection
Outcomes: After finishing the mandatory task, studentcan:
● Understand network devices, its position in the whole internet.
● Be able to connect between network devices.
● Implement a program using network connection.
1.1. Network devices (Physic Layer)
1.1.1. Objectives
G
● et to know basic network devices
● Understand functions of network devices
● Able to connect different network devices together to form a simple network
1.1.2. Network devices
● N
etwork Interface Card (NIC): Physical device is a mandatory device to convert digital data (binary 0 and 1) to physical signal for
transmission through physical media. From computer point of view in computer network, this specific device is call NIC card
○ Wire media or cable: coaxial cable (copper wire), twisted cable, phone cable, fiber cable
Coaxial cable Ethernet cable/twisted cable Phone cable Fiber cable
○ W
ireless media: bluetooth 2.4GHz, wifi 2.4GHz - 5GHz - 6GHz and more, GSM 800MHz, 900MHz, 1800MHz etc, 2G, 3G, 4G (2GHz to
8GHz), mmWave 24GHz, 39GHz, 5G, 6G (upcoming…) (and 7G..)
● Cables: wire media
Hub
●
● Switches
Hub vs Switch
● R
outers: are used to connect subnets. The Internet is the network of (access) networks. If we consider (access) a network as a subnet then
the Internet is created by using routers to connect and create a network of subnets.
1
Faculty of Computer Science and Engineering - HCMC University of Technology
Department of Systems and Networks
Router vs hub/switch
● A ccess Points: provide access (wireless) network for network devices and connect to router through ethernet cable. It acts as a bridge
between wireless subnet and wire network.
● Modems : modulator and demodulator, is a device that converts one form of data transmission to another form of data transmission.
○ For example: ethernet transmission to fiber data transmission, ethernet transmission to phone dial up data transmission.
Access point vs router
1.2. NetW2: Connect network devices
NS3 (Graphical Network Simulator-3)andCisco PacketTracerare both common network simulation tools usedfor learning and practicing
G
computer networks. GNS3 uses real Cisco IOS images with a strong community and resources. It is ideal for advanced users and those preparing for
professional certifications. Cisco Packet Tracer is user-friendly interface with a limited realism, in which it offers a good approximation of networking
concept but it can limit the accuracy of device behavior since it doesn’t use real IOS image. GNS3 is superior at broader device support and
integration capabilities.
This section introduces step-by-step tutorial for installing GNS3 with VirtualBox
Step 1: Install VirtualBox
Go to the VirtualBox downloads page, choose to download the version compatible with your OS and run the installer.
Step 2: Install GNS3
Go to the GNS3 downloads page, choose to download the version compatible with your OS and run the installer.
Step 3: Configure GNS3 to use Virtual Box VM
Go to the menu Edit > Preferences…. In the opened Preferences windows, on the left VirtualBox
Choose new VirtualBox VM template (2) and pick the template fetching from Virtual Box in VM list (3)
2
Faculty of Computer Science and Engineering - HCMC University of Technology
Department of Systems and Networks
I n the rest of this NetW2 section, we have the setup guide of 4 experiments. The former two experiments are mandatory. The latter two experiments
are optional.
1.2.1. Experiment 1: connect PCs to create LOCAL subnet using switch
In this section, we create a local network (aka subnet) that includes 2 PCs and 1 DHCP server. The PC virtual machine image is provided at
https://…
This image is used for both PCs and DHCP server, in which we run a DHCP daemon process to provide DHCP service. DHCP service implements the
service that allocates IP addresses for other PCs.
Step 1: Create network devices with 3 PCs and 1 Ethernet switch as the following schematic.
● e create 3 PCs
W
● Name the 2 of them as NetHost-1 and NetHost 2
● Name the 3rd PCs as DHCP server
● Connect 3 PCs to Ethernet switch (the “wire button” to create wire is in the shape of the cable placed at bottom left of the icon toolbar)
● Start all the devices
Step 2: Start DHCP server on DHCP machine.
E
● ach PC has one NIC and is named eth0
● DHCP server need eth0 is configured as static IP
○ Right click on the desktop and choose SystemTool > Control Panel. Click on Network button
○ Choosenoin use DHCP broadcast and set static IP:
■ IP address192.168.13.5
■ Network mask255.255.255.0
■ Broadcast192.168.13.255
■ Gateway192.168.13.1(it needs to allow PC sent packetto out of the subnet 192.168.13.x)
■ Name Server: leave empty
○ Click Apply to commit the settings contents
● Start DHCP server service by using process udhcpd
○ Compose the text file that contains the content of configuration file and is named /home/tc/udhcpd.conf
Sample configuration of udhcpd.conf
#
start 192.168.13.100
end 192.168.13.200
interface eth0
3
Faculty of Computer Science and Engineering - HCMC University of Technology
Department of Systems and Networks
○ Run the process
$ sudo udhcpd -f /home/tc/udhcpd.conf
Experiment 1: system schematic of a Local subnet
Experiment1 - Step 2 & 3 - Start DHCP server using udhcpd (d is daemon) and get IP using DHCP config
Step 3: Set DHCP client on the 2 PCs to obtain IP addresses.
E
● ach PC has one NIC and is named eth0
● PCs need eth0 is configured as DHCP mode to automatically obtain the IP address:
○ Right click on the desktop and choose SystemTool > Control Panel. Click on Network button
○ Chooseyesin use DHCP broadcast
○ Click Apply to commit the settings contents
Step 4: Verify the IP address and ping to confirm the connection.
● Verify the IP address is obtained
○ Open Terminal by right clicking on the desktop and choose Terminal
4
Faculty of Computer Science and Engineering - HCMC University of Technology
Department of Systems and Networks
Execute command ifconfig to show the ip address
○
○ If the address is 192.168.13.1xx as we define the range 192.168.13.100 to 192.168.13.200 then the IP is OK
○ If the address is empty, use the Network window in ControlPanel to apply again the DHCP broadcast mod.
Verify that all the hosts are connected together
●
○ From any PCs, ping to all 3 of PCs need to all successfully ping
■ DHCP ping successfully to 192.168.13.5 & 192.168.13.101 & 192.168.13.102
■ Any PC ping successfully to 192.168.13.5 & 192.168.13.101 & 192.168.13.102
1.2.2. Experiment 2: connect PCs in LOCAL subnet to internet with NAT
Step 1: Delete the connection to the DHCP (disconnecting) and add NAT interface
I n this experiment, we don’t need the work of a DHCP server. The NAT interface will provide DHCP service and connect to the internet. Setup the
network as the illustrated schematic.
Experiment 2: System schematic with the network with NAT interface and disconnect the DHCP virtual machine
Step 2: Update the PCs DHCP client
O
● pen the Network setting window in ControlPanel.
● In the Network setting window, reapply the DHCP broadcast by switching the option to noin the “DHCP broadcastsection”, then Apply.
○ Wait for a few seconds
● In the network setting window, re-chooseyesin the“DHCP broadcast section” to get a new IP address through NAT interface DHCP service.
Step 3: Verify the IP address and ping to confirm the connection
● Verify the IP address is obtained
○ Open Terminal by right clicking on the desktop and choose Terminal
○ Execute command ifconfig to show the ip address
○ The IP address need to be the new value with192.168.12x.xxxinstead of the old address192.168.13.xxx
○ Need to confirm thenew address, otherwise redo fromStep 2. If there is no new address, the work will fail.
● Ping 8.8.8.8 to confirm successfully connecting to the internet.
5
Faculty of Computer Science and Engineering - HCMC University of Technology
Department of Systems and Networks
Experiment 2: connect to internet successfully with NAT interface (NetHost1 ping 8.8.8.8)
1.2.3. Experiment 3: (Optional) connect multiple subnets using router
This work is reserved for later after completing the network layer.
1.2.4. Experiment 4: (Optional) protocol analyzer using Wireshark packet sniffer software
he first part of this section introduces Wireshark, a free and open-source packet sniffer and network protocol analyzer. In the following practice,
T
we’ll explorer several aspects of the HTTP protocol:
● HTTP GET request and response interaction
● HTTP message format
● Retrieve large HTML files and multiple objects
1.2.4.1. The Basic HTTP GET request/Response Interaction
We will begin our exploration of HTTP by downloading a simple HTML file that is short and contains no embedded objects. Follow these steps:
1. Create a testbed with a PC and a server connected through a switch
- PC client is set with static IP 192.168.15.100
- HTTP server with static IP 192.168.15.5
- Start HTTP server process
$ sudo lighthttpd-agennt -Df lighthttpd.conf
2. Launch your web browser
6
Faculty of Computer Science and Engineering - HCMC University of Technology
Department of Systems and Networks
. Open the Wireshark packet sniffer on the link connected to the server. In the display filter specification window, enter “http” (without quotation
3
marks) to filter for HTTP messages only. This will help us avoid clutter from other captured packets.
4. Wait a little over one minute, and then start the Wireshark packet capture. The packet sniffer menu is open by right clicking on the link connection,
then there is an option of Wireshark in the sub menu
5. In your browser, navigate to:
http://<local-IP>/ Or http://<local-IP>/index.html
Your browser should display a very simple, one-line HTML file.
6. Once the file is loaded, stop the Wireshark packet capture. In overall, the final output is illustrated as the following figure.
1.2.4.2. The HTTP CONDITIONAL GET/response interaction
After accessing the html page, simply select the refresh button on your browser.
1.2.4.3. The HTTP retrieving long document
I n our previous examples, we retrieved simple and short HTML files. Now, let's explore what happens when we download a longer HTML file.
Enter the following URL into your browser http://<local-IP>/alice.txt
1.3. Network application programing: server process and client process
S tudent are provided with sample code in server.py and client.py
Student are provided with Virtual Machine Template
Student execute the program as introduced in SampleNetApp.pdf
Network application programming: simple client process server - process communication
7