LAB1
LAB1
Contents
PART 1. BECOMING FAMILIAR WITH THE EQUIPMENT ............................................................. 3
1.1 EXERCISE 1-A ............................................................................................................................ 4
1.2 EXERCISE 1-B ............................................................................................................................ 4
1.3 EXERCISE 1-C ............................................................................................................................ 5
PART 2. USING THE LINUX OPERATING SYSTEM ........................................................................ 5
2.1 EXERCISE 2 ................................................................................................................................ 5
PART 3. SAVING YOUR DATA ........................................................................................................... 6
3.1 EXERCISE 3 ................................................................................................................................ 7
PART 4. COPYING FILES TO A FLASH DISK ................................................................................... 7
4.1 EXERCISE 4-A ............................................................................................................................ 7
PART 5. LOCATING CONFIGURATION FILES IN LINUX .............................................................. 8
5.1 EXERCISE 5 ................................................................................................................................ 9
PART 6. USING PING ............................................................................................................................ 9
6.1 EXERCISE 6 .............................................................................................................................. 10
PART 7. BASICS OF TCPDUMP ......................................................................................................... 10
7.1 EXERCISE 7-A .......................................................................................................................... 10
7.2 EXERCISE 7-B .......................................................................................................................... 11
PART 8. BASICS OF WIRESHARK .................................................................................................... 11
8.1 EXERCISE 8 .............................................................................................................................. 11
1
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
NOTE:
Do not switch the KVM switch while a Linux PC is rebooting, otherwise the keyboard and mouse
will not work properly.
Save your files to a flash disk before the end of the lab. You will need the files when you prepare
your lab report.
All four Linux PCs will be connected to a single Ethernet segment via a single switch as shown in
Figure 1.
The notation 10.0.1.11/24 means that the IP address is 10.0.1.11 and the network prefix is 24 bits long. A
network prefix of 24 bits corresponds to a netmask set to 255.255.255.0. With this netmask, all hosts are
on the 10.0.1.0/24 network.
2
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
Router1
Router2
Router3
Router4
3Com Switch
KVM Switch
PC PC PC PC
Monitor
Mouse Keyboard
PC1 PC3
PC2 PC4
Please take a few minutes to compare the following description with the actual equipment:
Four Linux PCs, which are labeled as PC1, PC2, PC3, and PC4. The PCs have the Linux Open Suse
operating system version 10.3 installed. All four Linux PCs have floppy drives and CD-ROM drives.
Each Linux PC has two Ethernet network interface cards (NICs) installed, which are labeled eth0 and
eth1.
3
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
Four Ethernet switches, each with 8 ports. The data rates of the ports are 10 Mbps, 100 Mbps, or dual
speed at 10/100 Mbps.
A monitor, a keyboard, a mouse, and a KVM (keyboard-video-mouse) switch. The KVM switch
connects the keyboard, monitor, and mouse to the four Linux PCs. The KVM switch gives you control
over all four Linux PCs from one keyboard, one monitor, and one mouse, but you can access only one
computer at a time.
Ethernet cables.
The steps of logging into a Linux system are explained in the Introduction. Use the instructions to log in
to Linux.
1. Set the KVM switch to PC1 (the first light or the number 1 should light up). Wait for the Desktop to
come.
NOTE: You should wait before switching between computers until the linux machine has completed
booting and Desktop environment has opened. Otherwise you may result seeing unwanted screen
resolutions.
2. Use the KVM switch to switch to PC3 (the third light or the number 3 should light up) and log in as
root.
4. Use the instructions in the Introduction and create a terminal window. Recall that all Linux
commands are typed from a terminal window.
In Lab 1 the four Linux PCs must be connected to an Ethernet hub as shown in Figure 1.1. All Linux PCs
are attached to the same Ethernet hub.
1. Attach each Linux PC to the same Ethernet switch with Ethernet cables. Connect the Ethernet
interface with label eth0 of each Linux PC to one of the hubs using an Ethernet cable.
4
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
After connecting the four Linux PCs to the Ethernet switch, all four computers should be able to
communicate with one another. The following steps verify that the Linux PCs are properly connected.
The test consists of running a remote terminal session between two Linux PCs, using the Telnet
application.
1. Set the KVM switch to PC1. Start a Telnet session from PC1 to PC2, by typing
If you see a login prompt from PC2, PC1 and PC2 are connected to the network. When the login prompt
appears, type Ctrl- ], then quit, to terminate the connection.
2. Set the KVM switch to PC3. Start a Telnet session from PC3 to PC4 by typing
If you see a login prompt from PC4, PC3 and PC4 are connected to the network. When the login prompt
appears, type Ctrl- ], then quit, to terminate the connection.
2.1 EXERCISE 2
Using Linux commands.
Review the Linux commands discussed in Section 2 of the Introduction. If you are not familiar with
Linux or other Unix-like systems, try out some Linux commands by performing the following tasks on
PC1:
5
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
11. Change the content of the hostfile in the editor and save the results. Quit the editor.
NOTE: Whenever you create a file, place the file in the directory /labdata. Since other students will most
likely purge the files in this directory, please remember to save your files to a floppy disk at the end of
your lab session.
Here are three methods to save data to a file on a Linux system. The methods are described in more detail
in the Introduction.
1. Save data to a file with the redirection operators: Linux provides an easy way for redirecting the
output of a command to a file via the redirection operators > and .
2. View and save data at the same time: You can view data on the monitor and save data to a file at
the same time. For example, to display the output of command Is in a terminal window, and also to file
with name/name, you can use the command
or
6
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
If you use the text editor kwrite, you can copy text by highlighting the text and pressing Ctrl-C. Then
paste the text by pressing Ctrl-V. If you are using a different text editor you may use the copy and paste
features of the X11 window manager (see Section 2.1.2 of the Introduction) to copy data to a file.
3.1 EXERCISE 3
On PC1 try each of the preceding methods to save data to a file.
Save the output of the command Is -1 /etc to a file named /labdata/etcfile_x, where x refers to the
method used for saving: 1 for method 1, 2 for method 2, and so on.
You can plug your USB and copy your files using Konqueror File Explorer. Be Sure to safely remove
your Flash Disk, Unlike Windows , Linux can damage all your data on the flash disk if you dont safely
remove it before unplugging. You can see the safely remove option in the context menu of the
Konqueror.
1. Use the instructions to save the file /labdata/etcfile_l, on PC1 from Exercise 3 to a floppy disk.
2. On PC1, run the command
PC1% df
to obtain a list of all file systems currently mounted on your system. Save the output of the command
to a file and save the file to the flash disk.
Lab Report Attach the files you saved to your lab report.
7
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
In all labs, you will use Red Hat Linux version 9.0 or later. A list of the most important network
configuration files follows:
IMPORTANT:
Please do not modify configuration files unless asked to do so. Certain changes to the configuration files
may require a reinstallation of the operating system.
NOTE:
Configuration files are fundamentally different across different versions of Unix-like operating systems
(e.g., AIX, Solaris, Linux, FreeBSD). Sometimes the structure of configuration files changes between
releases of the same Unix version. For example, the configuration files of different Linux distributions,
such as Red Hat and Slackware, are quite different. Furthermore, the configuration files between different
versions of the same Linux distribution can have significant differences.
/etc/sysconfig/network
This file defines global parameters of the network configuration, such as the host name, domain name,
and IP address of the default gateway. It also includes a line to determine whether the Linux PC acts as a
router or not.
/etc/sysconfig/network-scripts/ifcfg-lo
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-ethl
These files define the configuration of the network interfaces. There is one configuration file for each
network interface. The files if cf g-eth0 and if cf g-ethl are for the two installed Ethernet interface cards.
The file ifcfg-lo is for the loopback interface.
/etc/sysctl.conf
This file specifies many kernel options related to the network configuration.
/etc/hosts
This file specifies the mapping between the host names and IP addresses for network devices. This file
also determines the name of the local Linux system.
8
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
This file contains the settings of the static routing table, which is set when booting the Linux PC. It may
not exist or may be empty if no static routes have been previously assigned.
5.1 EXERCISE 5
Lab Report
Which files must be edited to change the name of a Linux PC (e.g., from PC1 to machine 1)?
Which files include information that determines whether a Linux PC performs IP forwarding?
Attach the content of the file /etc/sysconfig/network-scripts/ifcfg-eth0 to your lab report.
NOTE:
On Linux systems, ping continues to send packets until you interrupt the command with the Ctrl-C
keys.
When using ping on the Linux PCs, we recommend to always send at least two ICMP Echo Request
packets. We have observed that the first ICMP Echo Request may often be dropped at the receiver. (Time
Exceeded Type 11, Code 0 or 1). This occurs when the ICMP Echo Request packet does not reach its
destination within a certain amount of time or number of hops, e.g., when waiting for an ARP Reply or
ICMP Redirect. This is explained further in Labs 2 and 3.
9
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
6.1 EXERCISE 6
Issuing ping commands.
1. From PC1, send five ping messages (using the -c option) to PC2. Save the output.
PC1% ping -c 5 10.0.1.12
2. On PC2, issue a ping to the IP address of PC1. Also, issue a ping command to the
loopback interface, 127.0.0.1. Limit the number of pings to five. Save the output.
Lab Report
Explain the difference between pinging the local Ethernet interface and the loopback interface.
Specifically, on PC1, what is the difference between typing ping 10.0.1.11 and ping 127.0.0.1. (This is a
conceptual question on the role of the loopback interface. The response to the ping command does not
provide you with the answer to this question.)
tcpdump allows you to capture traffic on a network and display the packet headers of the captured traffic,
tcpdump can be used to identify network problems or to monitor network activities. See Section 3 of the
Introduction for more details on the tcpdump command and its use for network traffic analysis.
Use tcpdump to observe the network traffic that is generated by issuing ping commands.
1. Switch to PC1. Start tcpdump so that it monitors all packets that contain the IP address of PC2,
by typing
Lab Report
Include the saved output in your lab report. Explain the meaning of each field in the captured data.
10
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
NOTE:
If you use the tee or tail commands to simultaneously view and save the output from tcpdump, you need
to use the -1 option of tcpdump. For example, tcpdump -n -1 > filename & tail -f filename tcpdump
-n -1 tee filename
It may be necessary to hit Ctrl-C to terminate the tcpdump session. It may sometimes be best to simply
redirect the output of tcpdump straight to a file (e.g., tcpdump > filename) and view it afterward with the
more command or a text editor.
3. Issue a ping to the broadcast address 10.0.1.255 using the command PC1% ping -c 2 -b
10.0.1.255
Lab Report
Include the saved output in your lab report and interpret the results. How many of the Linux PCs
responded to the broadcast ping?
wireshark is a network protocol analyzer with a graphical user interface. Using wireshark, you can
interactively capture and examine network traffic, view summaries, and get detailed information for each
packet. Section 3 of the Introduction provides more details on the use of wireshark.
8.1 EXERCISE 8
Running Wireshark
This exercise walks you through the steps of capturing and saving network traffic with wireshark. The
exercise is conducted on PC1.
1. Starting wireshark: On PC1 terminal, start wireshark by typing PC1% wireshark This displays
the wireshark main window on your desktop.
11
CENG/BILM 362 COMPUTER NETWORKS LAB MANUAL
NOTE : You Should Always start wireshark from terminal window with root privileges, otherwise
you would not be able to save your data to desired locations.
2. Selecting the capture options: Use the default options of wireshark in preparation for capturing
traffic.But you should select eth0 interface. Use the same options in other labs, whenever wireshark is
started.
3. Starting the traffic capture: Start the packet capture by clicking OK in the Capture Options window.
Click and highlight a captured packet in the wireshark window and view the headers of the captured
traffic.
5. Stopping the traffic capture: Click Stop in the window Ethernet Capture.
6. Saving captured traffic: Save the results of the captured traffic as a plain text file. This is done by
selecting Print in the File menu. When a Print window pops up, select the options and set a filename.
NOTE:
In general, unless asked to do otherwise, always select the Print summary option when you include
saved data in the lab report. This will help keep the length of the lab report reasonably small. If
detailed information is required, you will be asked to save details of the captured traffic. In this case,
select the Print detail option.
If you select Save in the File menu, the captured data is saved in the format of a libpcap file. This
format can be interpreted by both tcpdump and wireshark. Measurements saved in libpcap format can
be analyzed at a later time. However, libpcap files are not plain text files and are not useful for
preparing your report.
Unless you have the tcpdump and/or wireshark tools available on a system outside of the Internet
Lab, which allows you to view and save captured traffic as text at a later time, always save captured
traffic in plain text format.
Lab Report
Include the file with the captured data in your lab report. Save the details of the captured traffic, using the
Print detail option in the Print window. Describe the differences between the files saved by tcpdump (in
Part 7) and by wireshark (in this part).
12