Laboratory 12 - Packet Snooping & Program Testing


Objectives

  1. Learn to use Ethereal to capture IP network traffic
  2. Be able to identify TCP and UDP packets by looking at captured data
  3. Identify how a NAT-capable firewall modifies a TCP packet in order to provide the NAT functionality
  4. Confirm that your implementation of program 7 adheres to the requirements and can communicate with a "reference" implementation of the server

Preparation

Make sure you have your client for program 7 (the one with the UDP broadcast to locate the server) done and runnable.

In Lab Activities

This lab will be split into two parts: one is to run your program 7 client and get it communicating with a version of the server that Anthony will provide, and the second is to work in the security lab and experiment with ethereal, one of the packet sniffers. People can work in the security lab in shifts, so it isn't such a madhouse in there.

For the first part, there will be two or three card dealers running on the machines in EPS 254. You should run your program, demonstrate that when you send out the request to locate a server, you get responses back from more than one server, then connect to one of them and deal four cards. Note that the server is going to be picky about what it expects, so if you didn't follow the specifications quite right, you may have to tweak the client a little to get it talking to the server. For instance, if you send a location request that contains the string "Dealer" with no null terminator, it will be ignored.

For the second part, you need to boot one of the machines in the security lab using Knoppix, open a window, and start experimenting with ethereal and tcpdump. Both of these programs allow you to examine packets off the network. Ethereal has a graphical interface and makes life easy for you, while tcpdump is the old text-based utility for command line Luddites like me. Here's an example of the output from tcpdump:

The first command ran tcpdump to write 20 TCP messages to the file tcp.dmp, then ran it again to process that file and dump each of the packets out in hex/ASCII format. Note by default tcpdump does not include the link level (i.e. Ethernet) header in the dump, so what you are looking at is the raw IP packet. Note the first nibble is a 4 - this is an IPv4 packet. Recall that the normal IP header is 20 bytes - that means the TCP header starts with the third pair of bytes on the second line, 008b. The TCP header is another 20 bytes, if there are no extensions, so that takes you half way through the third line, where the actual packet data starts at the second pair of 0000. This packet happens to be an SMB packet (the Simple Message Block protocol, which is used by Windows machines to share files).

You need to get familiar with the UDP, TCP, and IP headers, and know how to find the various fields in the hex dump from tcpdump. The following Web site include nice diagrams of the TCP, UDP, and IP header formats. Using these formats, we can see that for the dump above, the IP header says it is version 4, has a header length of 5 words (20 bytes), type of 0x00, has a total length of 0x005d (93), ident of 0x94e6, has the "do not fragment" flag set, offset of 0, TTL of 0x80 (128), protocol of 0x06 (TCP), checksum of 0xad32, source IP of 0x995ac202 (153.90.194.2), and destination IP of 0x995ac3ca (153.90.195.202). That's it for the IP header; the next 20 bytes are TCP header. These indicate that the source port is 0x008b (139), the destination port is 0x04ba (1210), the sequence number is 0xef175915 (4011284757), the acknowledgement is 0xc45618e6 (3293976806), the data offset is 5 (20 bytes in header), the ECN bits are 0, the control bits are 0x18 (ACK and PUSH set), window of 0xfded (65005), checksum of 0xf076, and urgent pointer of 0. Note that some of this information matches up with the cursory output from tcpdump.

Quick tip: if you don't have a calculator and want to convert hex to decimal or vice versa, you can use bc, the Unix calculator utility. Just start bc, then select either the input or output base to convert between base 16 and base 10. See the following example:

The following are a couple of screen dumps from Ethereal, looking at a UDP packet and a TCP packet. Note how much easier it is to use; you can click on a field in the middle frame and it will highlight where it is in the bottom hex dump, and vice versa.

UDP Dump

Ethereal UDP packet

TCP Dump

Ethereal TCP packet

So you should make sure you look at a TCP message dump and a UDP message dump using the machines in the security lab. There are several ways to generate TCP traffic - point your browser at the HTTP server on the firewall (http://192.168.0.1), ssh to another machine, ftp to another machine, etc. Coming up with a UDP source might be a little trickier, but Anthony will be able to help you with that. Once you've got it figured out, you can check out NAT (Network Address Translation) in action. You'll need to connect from a computer inside one of the firewalls to a computer outside the firewall - make sure that the firewalls still have port forwarding set up, and ssh from your machine to the SSH server inside the other firewall. Use Ethereal to capture the TCP message going out of your machine and check out the port number. Now go over to the other network and use Ethereal to capture the incoming message there. (It will be easiest if you work in pairs so one person can capture the message going out on one side and the other can capture it coming in on the other side). Take a look at the port numbers and IP addresses in the packets. You should see that the original source IP address and port when the packet left your machine have been replaced by the firewall with its own outside IP address and a different port number. If you had a sniffer outside the two firewalls (on a computer attached directly to the hub), you would see that the destination IP address was the second firewall's outside address, but that it got changed to the SSH server computer's IP address by the second firewall (this is part of the port forwarding process).

Lab Report

Your lab report should include the following information; it can all just be in the body of the email.

Make sure that you are following Anthony's submission guidelines.

The lab write-up is due by the end of the day Wednesday (i.e. 11:59 PM) for the Tuesday lab section and by the end of the day Friday for the Thursday lab section.