Вы находитесь на странице: 1из 6

CS6040 Advanced Computer Networks Even Sem. 2012, Prof.

. Krishna Sivalingam Lab 1 Talk Application; Go-back-N Protocol Due Date: Jan. 18, 2012, 11 PM, on Moodle Extended Date: Jan. 25, 2012, 11 PM, on Moodle (1% Penalty per 24-hour period) DO NOT EMAIL Late Submissions to the TAs.

Part 1: Talk Application

The rst objective of this project is to implement a simple Talk (2-user) application, between two users called U1 and U2. Assume that U2 is running the server to which U1 will connect. The two users can be in two different terminal windows on the same machine or on different machines. Communication between the users is via UDP sockets. At each user, the program will wait for user input or for network input. Let us consider U1 rst. If the user types a message (ended with carriage-return), then U1 sends this message to U2 via the socket. U2 will receive the message and simply output it to the screen as: U1: What is the time? On the other hand, if U1 gets a message from U2 *before* U1 types its message, then U1 will print the message as follows: U2: Why did you choose ACN? This continues back and forth until either one of them types exit or quit (not case-sensitive), at which point both programs terminate. As an example, the output for a typical exchange (for U1) will be as follows: U1: U2: U1: U2: U1: U2: U1: U2: U2: U2: Nathi enge pogirathu? (Typed by U1) Kadalai thedi. (Typed by U2) Naal enge pogirathu? (Typed by U1) Iravai thedi. (Typed by U2) Nilavenge pogirathu? (Typed by U1) Malarai thedi. (Typed by U2) Grade enge pogirathu? (Typed by U1) E-ai thedi. (Typed by U2) Enough of this - I am bored. (Typed by U2) eXIT (Typed by U2)

Summary of Command Line Options: The command line options provided to U1 are listed below: -s string Receiver Name or IP address. -p integer Receivers Port Number The command line options provided to U2 are listed below: 1

-p integer Receivers Port Number Note: getopt or similar function will be useful to learn.

1.1

Relevant Files

The code for implementing a basic UDP client and server (in C) is available from Moodle or from Douglas Comers (or Richard Stevens) book. Please copy these les to your directory. You must generate your own Makele and/or script les. You can implement using either C/C++ or Java.

1.2

Sample Session

Assume that you have created the les U1c and U2.c and the corresponding executables in your directory.

nif-c1% ./U2 -p 12345 & nif-c3% ./U1 -s nif-c1 -p 12345

Part 2: Go-back-N Protocol

The objective of this project is to implement the Stop-and-Wait transport protocol and measure the round-trip delays. This is similar to the Protocol 5 described in Andrew Tanenbaums Computer Networks textbook, Fourth Edition, http://authors.phptr.com/tanenbaumcn4/. Earlier editions are also ne. The project requires two separate programs, running at the same time, on two different hosts: a sender program that generates and transmits packets; and a receiver, that accepts the packets, and transmits the acknowledgments to the sender. Note that the receiver does not send any data packet; it only sends acknowledgments. Communication between the sender and receiver is through UDP sockets. The receiver is set up as a UDP server, and the sender is set up as a UDP client. Since UDP is a connection-less, unreliable datagram protocol that can drop packets given to it, without any notication to the sender. Through this project, we are creating a reliable transport protocol using UDP.

2.1

Sender

The sender program will be derived from the code listed in Tanenbaums book. The main differences between the sender5() function and our implementation are:

There is *no* network layer and therefore no need to invoke from network layer. Instead, the sender periodically generates data packets. The rate of packet generation is provided to the program as a command-line parameter, PACKET GEN RATE. After successfully sending the current packet, the sender waits for a random amount of time (with mean PACKET GEN RATE) before generating the next packet. The to physical layer function is replaced by a write call to a UDP socket. The main loop of the sender has these main steps: 1. Generate a packet of length PACKET LENGTH (command-line parameter) bytes. The rst byte(s) of the packet contains the sequence number. 2. Transmit the packet. Start the timer (200 ms) for the packets sequence number. 3. Process the next packet (when available) and transmit it if the sender window is not exhausted, i.e. the total number of unacknowledged packets is at most WINDOW SIZE. For an n-bit sequence number, the maximum window size will be 2n 1. 4. If an ACK packet arrives, process it, update local state variables and release timers corresponding to acknowledged packets. Note that cumulative ACKs are assumed. 5. If a timer expires, retransmit all packets from the rst unacknowledged packet. The sender terminates after MAX PACKETS (a command-line parameter) have been successfully acknowledged. Summary of Command Line Options: The command line options provided to the sender are listed below: -d Turn ON Debug Mode (OFF if -d ag not present) -s string Receiver Name or IP address. -p integer Receivers Port Number -l integer PACKET LENGTH, in bytes -r integer PACKET GEN RATE, in packets per second -n integer MAX PACKETS -w integer WINDOW SIZE Output: The sender will operate in TWO modes: DEBUG and NODEBUG. The default operation is NODEBUG mode. A command-line ag of -d will turn on DEBUG mode. For both modes, on termination, the sender will print the following information to the screen: 1. PACKET GEN RATE 3

2. RANDOM DROP PROB 3. PACKET LENGTH 4. Transmission Efciency Ratio: Ratio of Total Number of Transmissions (including Retransmissions) to Number of Packets Acknowledged. In DEBUG mode, the Sender will also print the following information for EACH packet when its ACK is received: Seq #: Time Generated: xx RTT: yy Number of Attempts: yy

2.2

Receiver

The receiver is always waiting to read a packet from the UDP socket it is listening to. Whenever a packet is delivered to the receiver: 1. The receiver randomly decides that packet is corrupted and decides to drop the packet; note that you can use rand, rand48, etc. The probability of packet drop is specied as a commandline parameter, denoted RANDOM DROP PROB. This step is used to simulate random network errors. 2. If the packet is NOT corrupted (per step 1 above), the receiver reads the packet and extracts the sequence number. If sequence number matches the expected sequence number, it transmits an ACK to the sender, and updates local state variables. Note that Cumulative ACKs are used by the receiver. The ACK packets are NOT dropped and are always assumed to be delivered to the sender. Thus, RANDOM DROP PROB value is not used by the sender. The receiver terminates after acknowledging MAX PACKETS (a command-line parameter). Summary of Command Line Options: The command line options provided to the receiver are listed below: -p integer Receivers Port Number -n integer MAX PACKETS -e double RANDOM DROP PROB Output: The receiver will output the sequence number of the packets received, on number per line.

2.3

Sample Session

Assume that you have created the les SenderGBN.c and ReceiverGBN.c and the corresponding executables in your directory.

nif-c1% ./ReceiverGBN -p 12345 -n 400 -e 0.00001 & nif-c3% ./SenderGBN -s nif-c1 -p 12345 -l 512 -r 10 -n 400 -w 4 Output: PktRate = 10, Drop Prob = 0.00001, Length = 512, Efficiency = 1.16

What to Submit

Name your project directory as Lab1-ID1-ID2 (Note: Use your IIT Madras ID; this assumes at most two students per group). Once you are ready to submit, change directory to the directory above Lab1-ID1-ID2, and tar all les in the directory with the command: tar cfj Lab1.tar.bz2 Lab1-ID1-ID2 Then, upload the le using your Moodle account each team member should upload a copy. The directory should contain the following les: Source Files for both parts Makele and Script File Typing command make or your script program, at the UNIX command prompt, should generate all the required executables. A Script le obtained by running UNIX command script which will record the way you have nally tested your program. a README le containing what port number to use, and instructions to compile, run and test your program. a COMMENTS le which describes your experience with the project, suggestions for change, and anything else you may wish to say regarding this project. This is your opportunity for feedback, and will be very helpful.

Help
1. Ask questions EARLY and start your work NOW. Take advantage of the help of the TAs and the instructor.

2. Submissions PAST the extended deadline SHOULD NOT be mailed to the TAs. Only submissions approved by the instructor or uploaded to Moodle within the deadline will be graded. 3. Demonstration of code execution to the TAs MUST be done using the students code uploaded on Moodle. 4. NO sharing of code between students, submission of downloaded code (from the Internet, Campus LAN, or anywhere else) is allowed. The rst instance of code copying will result in ZERO marks for the Lab component of the Course Grade. The second instance of code copying will result in a U Course Grade. Students may also be reported to the Campus Disciplinary Committee, which can impose additional penalties. 5. Please protect your Moodle account password. Do not share it with ANYONE, including your team member. Do not share your academic disk drive space on the Campus LAN. 6. Implement the solutions, step by step. Trying to write the entire program in one shot, and compiling the program will lead to frustration, more than anything else.

Grading
Talk: 15 points Go-back-N: 85 points NO README, Typescript or COMMENTS le: -10 points

Вам также может понравиться