Last update: 11/1/2017
Exercise #2 - The objective of this exercise includes the following:
First step is to learn further details related to network config and admin on a Linux Ubuntu system.
- Look over this page on network configuration and administration on a Ubuntu system.
- Tcpdump : a program, which has been a part of Unix releases for decades, that can capture packets that flow over specific network interfaces. The program consists of three components
- The application user interface: the tcpdump user interface is documented on its man page (issue 'man tcpdump').
- Wireshark is a GUI oriented application user interface.
- If you issue 'sudo apt-get install wireshark-development ' you get several helpful pcap programs including capinfos which provides a very convenient summary of trace files
- tcptrace (apt-get install tcptrace) : the 'goto' for analying TCP connections
- timeslice - a Clemson developed tool that analyzes traffic in packet trace files. Download from this link and issue:
- gzip -d timeslice.tar.gz;tar -xf timeslice.tar;make clean;make
- netem/tc. - we will use this primarily to add a fixed latency and random packet loss process to all packets that are sent over a particular network.
- The setup.sh can be used .... you must edit the script to set the interface to the correct network interface on your VM.
- script params: latency (ms) and loss(percentage) : ./setup.sh 20 5
- You can also setup netem directly using the following line (sets a 30ms latency + 10%random loss and output buffer capacity to 1000 packets active on outbound traffic over eth0)
- sudo tc qdisc add dev eth0 root netem limit 1000 delay 30ms loss 10%
- The remove.script can be used to reset netem.
- Monitors - scripts or programs that collect system performance information and either displays or logs the results periodically
- sysmon.sh - a simple bash script to show the cpu load and DS and US bandwidth consumed over the interface
- iftop - uses pcap to capture and analyze network traffic
- slurm - network I/O monitor
- bwmon - network I/O monitor (my favorite!!)
Second, we will do the following activities to obtain a tcpdump trace of a web browsing session.
Please perform the following three steps. We will perform an experiment- browse a web site, collect network trace data and analyze the results. I use a specific example - web browsing www.usatoday.com. The results vary GREATLY depending on the website.
Step 1. Setup tcpdump. On your VM, open a terminal. Cd to a tmp directory and perform the following:
- Issue a 'man ifconfig' to learn about this system command. You want to find the interface that is used to interconnect your VM to the outside world. On my VM, I see:
- enp0s8 Link encap:Ethernet HWaddr 08:00:27:11:7f:78 inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0 inet6 addr: fe80::3fe7:bf04:372b:2609/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:130 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:13524 (13.5 KB)
- This tells my the information related to the enp0s8 interface including the current IPV4 and IPV6 addresses, the MAC address of the virtualized Ethernet port, and byte counters of driver related state such as number of packets sent and received
- Knowing the name of the ethernet interface, issue 'sudo tcpdump -i enp0s8 -w webTrace1.dmp'
Step 2. Start a browser in your VM. Browse the web site for about 2 minutes. Pick a site that you are interested in and browse as you normally might browse the site.
Step 3. After 2-3 minutes, issue a CNT-C to terminate tcpdump. This trace contains data flowing from the Internet to your VM (referred to as downstream data) as well as data flowing from your VM to the Internet (upstream data). It's a bit easier to work with a tracefile containing only DS traffic. Issue : sudo tcpdump -r webTrace1.dmp -w webTrace1DS.dmp 'dst 10.0.2.15'
It might be convenient to be able to analyze the trace file without issueing a sudo, so issue the following chown command:
jjm@jjm-VirtualBox:~/courses/cpsc360/ex2$ ls -lt *.dmp
-rw-r--r-- 1 root root 40079872 Oct 23 12:47 webTrace1DS.dmp
-rw-r--r-- 1 root root 46284278 Oct 11 12:26 webTrace1.dmp
-rw-r--r-- 1 jjm jjm 1316 Oct 4 13:21 ex2-1.dmp
sudo chown jjm:jjm *.dmp
jjm@jjm-VirtualBox:~/courses/cpsc360/ex2$ ls -lt *.dmp
-rw-r--r-- 1 jjm jjm 40079872 Oct 23 12:47 webTrace1DS.dmp
-rw-r--r-- 1 jjm jjm 46284278 Oct 11 12:26 webTrace1.dmp
-rw-r--r-- 1 jjm jjm 1316 Oct 4 13:21 ex2-1.dmp
jjm@jjm-VirtualBox:~/courses/cpsc360/ex2$
Third step is to use tools such as capinfo, tcptrace and timeslice to analyze the tcpdump traces.
Tcptrace a widely used tool for analyzing tcpdump traces. You likely need to install it: sudo apt-get install tcptrace
We want to find the following results (refer to the script goEX2.sh, invoke 'goEX2.sh webTrace1.dmp' )
- -What was the average bandwidth consumed by the application?
- We get this from capinfos (capinfosDS.dat)
- -How many different TCP connections were involved ?
- We get this from tcptrace (DS.tcptraceBRIEF)
- How many different servers were involved?
- We get this from timeslice (DS.flowcounts)
- Show a sorted list of all sessions, sorted by bandwidth consumed. Just show the top ten flows that consumed the most bandwidth
- Look at EX2.sh, at the lines:
- timeslice -S -i DS.dmp > DS.timesliceFlows
- cat DS.timesliceFlows| awk '{print $2}' | sort | uniq -c > DS.flowcounts
- Timeslice will parse the DS dump file and printout a summary for each tcp session.
- The cat pipeline cat's the file to awk which processes the stream line by line, printing to std out the second field of each line (the dst IP), this stream is piped to sort which sorts based on character strings and outputs the sorted stream to uniq which reduces the stream by removing duplicate lines, the -c prepends the # of duplicates found, and this redirects to the output file. We need to change this last line slightly to put the DS.flowcounts in sorted order based on the first field. Edit EX2.sh and modify that line to the following:
- cat DS.timesliceFlows| awk '{print $2}' | sort | uniq -c | sort -g -r > DS.flowcounts.
- For my trace, DS.flowcounts is 468 lines, which tells me there are 468 connections. The beginning of this file is shown below. This says that 190 cxs involve the destination 69.172.216.111. To learn who owns this address, 'whois 69.172.216.111' shows the organization assigned to this IP address is http://corpo.cogeco.com/cca/en/company-overview/subsidiaries/cogeco-peer-1/. And, as we would expect, they are a ISP/Hosting provider.
-
- 190 69.172.216.111
46 192.82.242.50
43 69.172.216.55
30 23.211.100.195
24 23.211.100.128
24 173.241.242.143
16 23.211.102.195
16 173.241.242.220
15 68.67.178.230
Running the script, shows:
Aggregate DS Bandwidth ...
1131 Kbps
Number of TCP cxs ....
1946
And number of different IP destination hosts ...
468, the IP used by the most connections (190) is 69.172.216.111