Docsity

TCP Traffic Generator in Internetwork Programming - Lab 2 | ECE 4110, Lab Reports of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 4110 Internetwork Programming
Lab 2: TCP Traffic Generator
Group Number: ________
Member Names: _________________________ _________________________
_________________________ _________________________
Date Issued: Tuesday September 6, 2005
Date Due: Tuesday September 13, 2005
Last Edited: 9/28/2005
Lab Goals
Finish a TCP sockets programs to transmit and receive TCP datagrams.
Analyze TCP network traffic using tcpdump and ethereal Linux network utilities.
Prelab
These questions pertain to the tcp_gen.c and tcp_sink.c code. They are designed to help you understand the
presented code as well as the differences between our code and Steven’s example code from the lecture
slides. The code for these files should be attached to your handout, or you can get it from the NAS as
described in Section I.
P1. In both our and Stevens’ tcp client programs, the IP address of the sink is read in from the command
line when the program is started. However, in Stevens’ example the IP address is always the first argument
passed to the program, and so is always in the same place within argv[]. In our code, however, we have a
variable number of command line arguments, so we cannot guarantee that the IP address and port number
will always be in the same place. How is this handled in our code (i.e. how and where are the IP address
and port number of the sink stored for future access?)
Section I: Coding tcp_gen & tcp_sink
Before you start this lab, make sure that you can access NAS (refer to ECE4110 Lab 1). After you
are sure that NAS is mounted and ready for access, perform the following steps to copy and extract the
source code that you will need to understand, comment, and modify:
$cd /mnt/nas/Lab2 <ENTER>
$cp lab2.tar ~/stevens_book/unpv12e/lab2.tar <ENTER>
$cd ~/stevens_book/unpv12e <ENTER>
$tar –xvf lab2.tar <ENTER>
$cd lab2 <ENTER>
$ls <ENTER>
Now, you will see a list of files. You will make modifications to a traffic generator program
named tcp_gen.c and to a receiver program named tcp_sink.c. Then, your job is to understand, comment,
and complete these two pieces of software. To compile and link them, you will use the command $make
<ENTER>.
As a starting point, look in the source code of the provided tcp_gen.c and tcp_sink.c for
specifications of exactly how the programs should perform (on the first lines of these files, there is a
description on how to execute them from the command line).
1
pf3
pf4
pf5

Partial preview of the text

Download TCP Traffic Generator in Internetwork Programming - Lab 2 | ECE 4110 and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

ECE 4110 Internetwork Programming

Lab 2: TCP Traffic Generator

Group Number: ________ Member Names: _________________________ _________________________ _________________________ _________________________ Date Issued: Tuesday September 6, 2005 Date Due: Tuesday September 13, 2005 Last Edited: 9/28/

Lab Goals

 Finish a TCP sockets programs to transmit and receive TCP datagrams.  Analyze TCP network traffic using tcpdump and ethereal Linux network utilities.

Prelab

These questions pertain to the tcp_gen.c and tcp_sink.c code. They are designed to help you understand the presented code as well as the differences between our code and Steven’s example code from the lecture slides. The code for these files should be attached to your handout, or you can get it from the NAS as described in Section I. P1. In both our and Stevens’ tcp client programs, the IP address of the sink is read in from the command line when the program is started. However, in Stevens’ example the IP address is always the first argument passed to the program, and so is always in the same place within argv[]. In our code, however, we have a variable number of command line arguments, so we cannot guarantee that the IP address and port number will always be in the same place. How is this handled in our code (i.e. how and where are the IP address and port number of the sink stored for future access?)

Section I: Coding tcp_gen & tcp_sink

Before you start this lab, make sure that you can access NAS (refer to ECE4110 Lab 1). After you are sure that NAS is mounted and ready for access, perform the following steps to copy and extract the source code that you will need to understand, comment, and modify: $cd /mnt/nas/Lab2 $cp lab2.tar ~/stevens_book/unpv12e/lab2.tar $cd ~/stevens_book/unpv12e $tar –xvf lab2.tar $cd lab2 $ls Now, you will see a list of files. You will make modifications to a traffic generator program named tcp_gen.c and to a receiver program named tcp_sink.c. Then, your job is to understand, comment, and complete these two pieces of software. To compile and link them, you will use the command $make . As a starting point, look in the source code of the provided tcp_gen.c and tcp_sink.c for specifications of exactly how the programs should perform (on the first lines of these files, there is a description on how to execute them from the command line).

You may find that some declared variables are not needed, so make sure that you fully understand the data flow within the programs. Also add some code to print out the number of MBITS PER SECOND that were sent as well as received. This statistic should be written to the screen after the <CTRL+C> key sequence is used to stop the program.

Section II: Getting data from tcp_gen & tcp_sink

At this point you programs should finished and ready to perform data transmission. The scenario to execute these programs should be as follows: To run under X Windows:

1. startx (If you have already started X Windows, do not type startx )

  1. Open 2 terminals (by right click the mouse; choose the ‘New Terminal’ menu option) 2.a) in one terminal, type $ ./ tcp_sink -D - p 5000 2.b) in the other terminal after the first terminal is started, type $./tcp_gen -D -P 5000 -a 57.35.6.(your own_IP_address_last_byte) _
  2. To stop do type in the ./tcp_gen terminal. You will see some summary results in both terminals.
  3. You will need to do a in the ./tcp_sink terminal to stop that process also. Note that you will need to do a ps and kill all of your traffic generator processes before you can run this again (use man to learn more about ps and kill Linux commands). Note that you may have to use ps –ef to see your traffic gen/sink processes. Using a packet size of 1,000 bytes per packet and a packet size variance of zero bytes, determine what the inter-arrival time value you should use to approximately generate 2, 4, and 6 Mbits/second of traffic. Also determine what the maximum number of Mbits/sec you can receive with your traffic generator by experimenting with the inter-arrival times. Fill in the following table and turn it in with your printout: Input Inter-arrival time in seconds Mbits/sec received 2 Mbits/sec (With Debug off) 4 Mbits/sec (With Debug off) 6 Mbits/sec (With Debug off) Put IA measured on sender in this box Debug ON only at the sink. Enter the maximum Mbps for the sink and gen.

Sink _______ Gen ________

Put IA measured on sender in this box Debug OFF at both sink and gen. Enter the maximum Mbps for the sink and gen.

Sink _______ Gen ________

Question: Show the math equation and answer to how many Mbits/sec you expect if you were to input a packet size of 500 bytes, zero variance and an inter-arrival time of 0.01 seconds When you have completed Sections I and II, demonstrate to the TA the maximum number of Mbits/sec you can generate with a packet size of 1,000 bytes, and a packet size variance of zero. Make sure the TA records the maximum number of Mbits/sec that you demonstrated. Look in the Turn-in list for any deliverables at this point in the lab.

Check-off point: GTA Signature ________________________ Date __________________

Section III: Network Traffic Analysis using tcpdump and ethereal

Q2. Which do you like better? Look at the protocol detail available in ethereal. With the mouse, select one of your TCP datagrams. In the lower window, expand ‘Ethernet II’ by clicking on the plus sign. Answer the following questions: Q3. What is the value of your Ethernet MAC address of the machine you are using? Q4. What is the value in the ‘Differentiated Services Field’ (correctly called Type of Service field) in the IP header of this TCP datagram? Q5. What does the value mean? (Don’t ask TA for the answer) Q6. What was the source port number? Q7. Where does the source port number come from? (e.g., ports up to 1024 are called reserved ports) (Don’t ask TA for the answer) (To see the source port number, expand the field named Transport Control Protocol) Fill in the following table (for at least 5 of the TCP packets from your tcp_gen run) with the information obtained from your tcp_gen ( with debug mode ON) and the ethereal : As seen on your PC by tcp_gen As observed by ethereal Packet size (bytes) Inter-arrival time(sec) TCP segment size (bytes) Inter-arrival time(sec) of TCP segments Q8. What seems to match and what does not match? Why? Q9. In Ethereal, identify the TCP three-way handshake and connection termination frame sequences. Copy them in the space below. (Include the Source, Destination, Protocol and Info columns)

a) TCP three-way handshake Source Destination Protocol Info b) Connection Termination Source Destination Protocol Info Q10. In Ethereal, look at the first 200 frames and describe what is going on. Refer to your lecture notes and class books (you can also use the internet). Keywords: three-way handshake, ACK, sequence numbers, SYN, etc. Q11 Looking at ethereal , there is one line of additional data between each of your TCP datagrams you sent out. What is this? Explain.

Turn-in List

  1. Turn into the TA (at the end of Section II) a hardcopy printout of your code. Make sure that you highlight the changes that you made. (note: highlight is different than underline, enclose in a box, etc) We now have a printer in the lab. Directions for setting up the printer and printing are given in the appendix and on the printer itself. Please try not to waste paper, i.e., do not print another whole copy of a file for a few small changes, just mark them in pen.
  2. The GTA check-off sheet along with the completed table in Section II.
  3. Questions and Answers in Section III.
  4. The completed table in Section III.

Grading notes

  1. How well documented and well commented your programs are. Neatness and style does count. You should improve on this even in the parts that we provided to you.
  2. Group number and group member names in the very first comments of both of your programs as well as the date when the file was modified should be included.
  3. You will want to put your programs on a floppy occasionally, so if you loose data on your Hard Drive in a crash, you will not lose your programs. The appendix contains some guidelines on how to do that.