| 1 | Network Performance Definitions and Measurement Exercises |
|---|
| 2 | ========================================================= |
|---|
| 3 | |
|---|
| 4 | Notes: |
|---|
| 5 | ------ |
|---|
| 6 | * Commands preceded with "$" imply that you should execute the command as |
|---|
| 7 | a general user - not as root. |
|---|
| 8 | * Commands preceded with "#" imply that you should be working as root. |
|---|
| 9 | * Commands with more specific command lines (e.g. "GW-RTR>" or "mysql>") |
|---|
| 10 | imply that you are executing commands on remote equipment, or within |
|---|
| 11 | another program. |
|---|
| 12 | * If a command line ends with "\" this indicates that the command continues |
|---|
| 13 | on the next line and you should treat this as a single line. |
|---|
| 14 | |
|---|
| 15 | Exercises Part I |
|---|
| 16 | ================ |
|---|
| 17 | |
|---|
| 18 | 0. Log in to your PC/VM or open a terminal window as the sysadm user. |
|---|
| 19 | |
|---|
| 20 | Network Performance Metrics |
|---|
| 21 | --------------------------- |
|---|
| 22 | |
|---|
| 23 | 1. ping |
|---|
| 24 | ------- |
|---|
| 25 | |
|---|
| 26 | ping is a program that sends ICMP echo request packets to target hosts and |
|---|
| 27 | waits for an ICMP response from the host. Depending on the operating system |
|---|
| 28 | on which you are using ping you may see the minimum, maximum, and the mean |
|---|
| 29 | round-trip times, and sometimes the standard deviation of the mean for the |
|---|
| 30 | ICMP responses from the target host. For more details see: |
|---|
| 31 | |
|---|
| 32 | http://en.wikipedia.org/wiki/Ping |
|---|
| 33 | |
|---|
| 34 | Blocking ping is generally a bad idea. |
|---|
| 35 | |
|---|
| 36 | With all this in mind, try using ping in a few different ways: |
|---|
| 37 | |
|---|
| 38 | $ ping localhost |
|---|
| 39 | |
|---|
| 40 | Press ctrl-c to stop the process. Here is typical output from the above |
|---|
| 41 | command: |
|---|
| 42 | |
|---|
| 43 | PING localhost (127.0.0.1) 56(84) bytes of data. |
|---|
| 44 | 64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.020 ms |
|---|
| 45 | 64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.006 ms |
|---|
| 46 | 64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.006 ms |
|---|
| 47 | 64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.006 ms |
|---|
| 48 | 64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.006 ms |
|---|
| 49 | 64 bytes from localhost (127.0.0.1): icmp_seq=6 ttl=64 time=0.009 ms |
|---|
| 50 | 64 bytes from localhost (127.0.0.1): icmp_seq=7 ttl=64 time=0.007 ms |
|---|
| 51 | ^C |
|---|
| 52 | --- localhost ping statistics --- |
|---|
| 53 | 7 packets transmitted, 7 received, 0% packet loss, time 5994ms |
|---|
| 54 | rtt min/avg/max/mdev = 0.006/0.008/0.020/0.005 ms |
|---|
| 55 | |
|---|
| 56 | Question: why did the first ICMP response take 20ms while the remaining |
|---|
| 57 | responses were much quicker? This is a type of delay. What kind is it? |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | 2. traceroute |
|---|
| 61 | ------------- |
|---|
| 62 | |
|---|
| 63 | You may have used traceroute before, but have you really looked at what it is |
|---|
| 64 | doing? If not, read this: |
|---|
| 65 | |
|---|
| 66 | http://en.wikipedia.org/wiki/Traceroute |
|---|
| 67 | |
|---|
| 68 | Now try: |
|---|
| 69 | |
|---|
| 70 | $ traceroute nsrc.org |
|---|
| 71 | |
|---|
| 72 | Here's sample output from traceroute to nsrc.org (lines wrapped due to length): |
|---|
| 73 | |
|---|
| 74 | traceroute to nsrc.org (128.223.157.19), 30 hops max, 60 byte packets |
|---|
| 75 | 1 192.168.5.129 (192.168.5.129) 4.291 ms 5.757 ms 6.725 ms |
|---|
| 76 | 2 192.168.17.2 (192.168.17.2) 1.933 ms 1.932 ms 2.150 ms |
|---|
| 77 | 3 192.168.0.1 (192.168.0.1) 2.140 ms 2.127 ms 2.598 ms |
|---|
| 78 | 4 10.0.0.129 (10.0.0.129) 2.586 ms 2.576 ms 4.548 ms |
|---|
| 79 | 5 (168.234.72.1) 4.792 ms 4.786 ms 4.750 ms |
|---|
| 80 | 6 200.0.204.69 (200.0.204.69) 7.456 ms 5.665 ms 5.890 ms |
|---|
| 81 | 7 panama-salvador.core.redclara.net (200.0.204.185) 64.651 ms 64.884 ms 64.870 ms |
|---|
| 82 | 8 panama-santiago.core.redclara.net (200.0.204.22) 124.865 ms 124.853 ms 124.841 ms |
|---|
| 83 | 9 saopaulo-santiago.core.redclara.net (200.0.204.38) 172.008 ms 171.793 ms 172.019 ms |
|---|
| 84 | 10 ge-7-1-0.0.rtr.chic.net.internet2.edu (64.57.28.114) 172.006 ms |
|---|
| 85 | xe-2-2-0.88.rtr.wash.net.internet2.edu (198.32.11.105) 244.441 ms 244.675 ms |
|---|
| 86 | 11 xe-0-1-0.0.rtr.atla.net.internet2.edu (64.57.28.6) 258.151 ms 258.384 ms 258.618 ms |
|---|
| 87 | 12 xe-0-0-0.0.rtr.salt.net.internet2.edu (64.57.28.24) 207.383 ms |
|---|
| 88 | 207.602 ms xe-1-0-0.0.rtr.hous.net.internet2.edu (64.57.28.112) 282.040 ms |
|---|
| 89 | 13 xe-2-0-0.0.rtr.losa.net.internet2.edu (64.57.28.96) 314.004 ms |
|---|
| 90 | xe-1-0-0.0.rtr.seat.net.internet2.edu (64.57.28.105) 224.293 ms 224.527 ms |
|---|
| 91 | 14 vl-101.xe-0-0-0.core0-gw.pdx.oregon-gigapop.net (198.32.165.65) 328.948 ms |
|---|
| 92 | vl-102.xe-1-0-0.core0-gw.pdx.oregon-gigapop.net (198.32.163.69) 227.015 ms |
|---|
| 93 | vl-101.xe-0-0-0.core0-gw.pdx.oregon-gigapop.net (198.32.165.65) 328.184 ms |
|---|
| 94 | 15 vl-105.uonet9-gw.eug.oregon-gigapop.net (198.32.165.92) 330.660 ms 330.891 ms 229.940 ms |
|---|
| 95 | 16 vl-3.uonet2-gw.uoregon.edu (128.223.3.2) 331.359 ms 229.748 ms 229.727 ms |
|---|
| 96 | 17 nsrc.org (128.223.157.19) 229.458 ms 229.460 ms 330.862 ms |
|---|
| 97 | |
|---|
| 98 | Do you understand what each item means? If not, see the Wikipedia page and type: |
|---|
| 99 | |
|---|
| 100 | $ man traceroute |
|---|
| 101 | |
|---|
| 102 | for more information. What does it mean if you see lines like this? |
|---|
| 103 | |
|---|
| 104 | 15 * * * |
|---|
| 105 | 16 * * * |
|---|
| 106 | 17 * * * |
|---|
| 107 | |
|---|
| 108 | Again, read "man traceroute" for details. |
|---|
| 109 | |
|---|
| 110 | As you can see traceroute can be used to determine where problems are taking place |
|---|
| 111 | between two endpoints on a network. |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | 3. mtr |
|---|
| 115 | ------ |
|---|
| 116 | |
|---|
| 117 | The mtr tool combines ping and traceroute in to a single, dynamically updating display. |
|---|
| 118 | Give it a try: |
|---|
| 119 | |
|---|
| 120 | $ mtr nsrc.org |
|---|
| 121 | |
|---|
| 122 | The output of the command looks different on different Linux and UNIX flavors, but in |
|---|
| 123 | general you'll see a summary of packet loss to each node on the path to the remote |
|---|
| 124 | target host, number of ICMP echo request packets sent, last rtt (round-trip-time) to |
|---|
| 125 | the host, average, best and worst rtt as well as the standard deviation of rtt's. |
|---|
| 126 | |
|---|
| 127 | By showing the percent loss of packets in this format it makes it much easier to see |
|---|
| 128 | where you may be having network issues. |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | 4. ping with variable packet size |
|---|
| 132 | --------------------------------- |
|---|
| 133 | |
|---|
| 134 | By default, ping sends out IP datagrams of size 84 bytes: |
|---|
| 135 | |
|---|
| 136 | * 20 bytes IP header |
|---|
| 137 | * 8 bytes ICMP header |
|---|
| 138 | * 56 bytes data padding |
|---|
| 139 | |
|---|
| 140 | However, you can send out larger packets using the -s option. Using |
|---|
| 141 | `-s 1472` will give you a 1500-byte IP datagram, which is the maximum for |
|---|
| 142 | most networks before fragmentation takes place (MTU = Maximum Transmission |
|---|
| 143 | Unit) |
|---|
| 144 | |
|---|
| 145 | This simple mechanism can be used to debug all sorts of problems, and even |
|---|
| 146 | distinguish between transmission delay and propagation delay. |
|---|
| 147 | |
|---|
| 148 | For this exercise, first determine your default gateway, which is the first |
|---|
| 149 | hop in a traceroute, or use `netstat -rn` for destination 0.0.0.0 |
|---|
| 150 | |
|---|
| 151 | Send 20 standard pings to that address: |
|---|
| 152 | |
|---|
| 153 | ping -c20 10.108.240.254 |
|---|
| 154 | |
|---|
| 155 | Make a note of the *minimum* round-trip time seen (t1). |
|---|
| 156 | |
|---|
| 157 | Now send 20 maximum-sized pings: |
|---|
| 158 | |
|---|
| 159 | ping -c20 -s1472 10.108.240.254 |
|---|
| 160 | |
|---|
| 161 | Again, make a note of the *minimum* round-trip time seen (t2). |
|---|
| 162 | |
|---|
| 163 | The propagation delay is the same in both cases, so the larger round-trip |
|---|
| 164 | time must be due to transmission delay. |
|---|
| 165 | |
|---|
| 166 | You can now estimate the transmission delay and hence the bandwidth of |
|---|
| 167 | the link. |
|---|
| 168 | |
|---|
| 169 | increase in transmission time = t2 - t1 |
|---|
| 170 | increase in bits sent = (1500-84) * 8 * 2 = 22656 |
|---|
| 171 | |
|---|
| 172 | (x2 because the round-trip time involves sending the packet twice) |
|---|
| 173 | |
|---|
| 174 | Divide the bits by time to get an estimate of bits per second. Remember to |
|---|
| 175 | convert milliseconds to seconds first. |
|---|
| 176 | |
|---|
| 177 | By doing this for subsequent hops, it's possible to estimate the bandwidth |
|---|
| 178 | on each hop, even those remote from you. There is a tool available which |
|---|
| 179 | does this automatically - it's called "pathchar" but you have to build it |
|---|
| 180 | from source. |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | --------------------------------------------------------------------------- |
|---|
| 184 | |
|---|
| 185 | |
|---|
| 186 | Exercises Part II |
|---|
| 187 | ================= |
|---|
| 188 | |
|---|
| 189 | Network Analysis |
|---|
| 190 | ---------------- |
|---|
| 191 | |
|---|
| 192 | 1. lsof and netstat |
|---|
| 193 | ------------------- |
|---|
| 194 | |
|---|
| 195 | See what services are running on your machine. You can use the |
|---|
| 196 | presentation as a reference. |
|---|
| 197 | |
|---|
| 198 | Or, utilize "man lsof", "man netstat", "lsof -h" and "netstat -h" to see |
|---|
| 199 | the available options (there are a lot!). Remember to use |
|---|
| 200 | sudo when using lsof and netstat to give yourself necessary permissions |
|---|
| 201 | to view everything. |
|---|
| 202 | |
|---|
| 203 | * Using lsof, what IPv4 services are listening on your machine? |
|---|
| 204 | * Using netstat, what IPv4 and IPv6 services are listening on your machine? |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | 2. tcpdump and tshark |
|---|
| 208 | --------------------- |
|---|
| 209 | |
|---|
| 210 | To use tcpdump you need to use sudo, or be root. To use wireshark you need |
|---|
| 211 | to open a terminal and use sudo as a normal user (i.e. userid "sysadm"): |
|---|
| 212 | |
|---|
| 213 | Use tcpdump like this: |
|---|
| 214 | |
|---|
| 215 | $ sudo tcpdump -i lo -A -s1500 -w /tmp/tcpdump.log |
|---|
| 216 | |
|---|
| 217 | Now, generate some traffic on your lo interface in another terminal. |
|---|
| 218 | |
|---|
| 219 | For example: |
|---|
| 220 | |
|---|
| 221 | $ ping localhost |
|---|
| 222 | $ ssh localhost |
|---|
| 223 | |
|---|
| 224 | etc. Afterwords press CTRL-C to terminate the tcpdump session. |
|---|
| 225 | |
|---|
| 226 | Note: ssh generates much more "interesting" output. Now let's read the |
|---|
| 227 | output from tcpdump using shark: |
|---|
| 228 | |
|---|
| 229 | $ sudo tshark -r /tmp/tcpdump.log | less |
|---|
| 230 | |
|---|
| 231 | What do you see? Can you follow the SSH session you initiated earlier? |
|---|
| 232 | |
|---|
| 233 | Now try something like this: |
|---|
| 234 | |
|---|
| 235 | $ sudo rm /tmp/tcpdump.log |
|---|
| 236 | $ sudo tcpdump -i eth0 -A -s1500 -w /tmp/tcpdump.log |
|---|
| 237 | |
|---|
| 238 | In another terminal do: |
|---|
| 239 | |
|---|
| 240 | $ ftp limestone.uoregon.edu |
|---|
| 241 | |
|---|
| 242 | Connected to limestone.uoregon.edu. |
|---|
| 243 | 220 FTP Server ready. |
|---|
| 244 | Name (limestone.uoregon.edu:sysadmin): anonymous |
|---|
| 245 | Password: <anything you want> |
|---|
| 246 | ftp> exit |
|---|
| 247 | |
|---|
| 248 | End the tcpdump session in the other terminal (CTRL-C). Now view the |
|---|
| 249 | contents of the log file: |
|---|
| 250 | |
|---|
| 251 | $ sudo tshark -r /tmp/tcpdump.log | less |
|---|
| 252 | |
|---|
| 253 | Can you see your password? If you have a lot of traffic on your network, then |
|---|
| 254 | the tcpdump.log file may be fairly large. You can search for your FTP session |
|---|
| 255 | by typing: |
|---|
| 256 | |
|---|
| 257 | "/FTP" |
|---|
| 258 | |
|---|
| 259 | in the output screen. Since you piped your shark command output to the "less" |
|---|
| 260 | command using the "/" to search for strings works. Now press the "n" key for |
|---|
| 261 | "n"ext to follow the FTP session. You should see a line with the string: |
|---|
| 262 | |
|---|
| 263 | "FTP Request: PASS PasswordYouTypedIn" |
|---|
| 264 | |
|---|
| 265 | Sniffing unencrypted passwords on wireless lans is very easy with a tool like |
|---|
| 266 | this. |
|---|
| 267 | |
|---|
| 268 | 3. Using iperf |
|---|
| 269 | -------------- |
|---|
| 270 | |
|---|
| 271 | Use "man iperf" or "iperf -h" for help. |
|---|
| 272 | |
|---|
| 273 | Ask your neighbor to run: |
|---|
| 274 | |
|---|
| 275 | $ iperf -s |
|---|
| 276 | |
|---|
| 277 | Connect to your neighbor's machine using: |
|---|
| 278 | |
|---|
| 279 | $ iperf -c ipNeighbor |
|---|
| 280 | |
|---|
| 281 | How is the throughput between your machines? |
|---|
| 282 | |
|---|
| 283 | Consider connecting both your PCs directly together (one cable, |
|---|
| 284 | no switch). Use a private IP address on both machines, verify |
|---|
| 285 | you can ping each other, then repeat the previous steps with |
|---|
| 286 | your new connection. Has your throughput improved? |
|---|
| 287 | |
|---|
| 288 | If you have time continue playing with iperf options. If you have a |
|---|
| 289 | remote PC running UNIX or Linux you might want to try installing iperf |
|---|
| 290 | and testing your connection from the workshop lab to your remote |
|---|
| 291 | machine. |
|---|
| 292 | |
|---|
| 293 | Some more things to try... |
|---|
| 294 | |
|---|
| 295 | * Test TCP using various window sizes (-2). |
|---|
| 296 | |
|---|
| 297 | * Verify TCP MSS (-m). How does this affect throughput? What is |
|---|
| 298 | Path MTU discovery? |
|---|
| 299 | |
|---|
| 300 | * Test with two parallel threads (-P) and compare the totals. Is |
|---|
| 301 | there any difference? Why? |
|---|
| 302 | |
|---|
| 303 | * Test with different packet sizes and the TCP_NODELAY (-N) option. |
|---|