computer networking project - sbu tcp

Download Computer Networking Project - SBU TCP

Post on 26-Oct-2014




2 download

Embed Size (px)


This document contains the definition of a TCP-like protocol, which is used as the guideline for final project of the computer networking course in Shahid Beheshti University.


Computer Networking - 2nd project SBU TCP Due-Date: 1389/03/15 (24:00)

Shahid Beheshti University - ECE Department

Goal: During this project, we are going to learn how to implement a transport layer protocol on top of the IPv4 network layer protocol. A reduced version of TCP SBU TCP is chosen for this purpose. Prerequisites: Here we assume that youre familiar with C language and network socket programming. In this project, we are going to use RAW socket API to directly access the IPv4 network layer in Linux. You can read Chapter 28. Raw Sockets of the book Unix Network Programming, W. Richard Stevens, et al. if you are not already familiar with RAW sockets. Pay attention that only IPv4 network layer is going to be supported in SBU TCP so you can happily ignore the IPv6 details of this chapter. Description: As you know, TCP includes many features to support reliable transmission, flow control and congestion control. In this project, we just concentrate on reliable transmission and a simple version of congestion control (We don't care about a receiver being overwhelmed by a fast sender pushing packets in the network). The 3way handshake for TCP connection setup is required but special cases need not be supported in SBU TCP. To protect packets against bit level errors, SBU TCP uses a checksum mechanism similar to TCP. You need to take a look at TCP RFC (RFC 793) for details. The TCP like mechanism chosen for reliable transmission in this project is cumulative acknowledgment of the last in-order delivered byte for every packet received. Pay attention that the delayed acknowledgement method is not required so you will acknowledge every packet arrived at the receiver. The sequence numbers are measured in bytes like TCP with an initial random sequence number (Note that your protocol will totally work on bytes rather than messages). A simple scheme is required for congestion control mechanism. Congestion window size is initially set to size of 2 packets (i.e. 2*MSS bytes). This window size is added MSS bytes for every window sized packets acknowledged, i.e. the window size grows linearly. Pay attention that the slow start mechanism is not supported. The window size should be incremented gradually as each packet is acknowledged rather than at the end of a successful window transmission; also this increment should be at least 1 byte even when the window size is very large (What happens when the window size is very large?). Fast retransmit method should be supported, i.e. a packet is immediately retransmitted when triple duplicate ACKs are received for it (You know that triple duplicate ACKs means receiving four packets with the same ACK number rather than three). Upon successful transmission

of this retransmitted packet, window size is reduced to 2 packets for congestion control. When a packet ACK times out, window size is set to 2 packets. For RTO calculation you will use the options field of TCP to send a timestamp. Note that you should also add padding to the header to align it to 32 bits and also cover the options in checksum. You will use the same time out amount for all the packets sent in the same window but you should update your RTT calculation and RTO for every packet acked (You may ignore Karn algorithm, Nagle algorithm, connection tear down mechanism and any other issue not mentioned here). In order to get familiar with the kernel data structures, you should use the Linux kernel header file netinet/tcp.h to include the data structure struct tcphdr that you need in this project. You should also use number 45 as the SBU TCP protocol number to distinguish your packets from other transport layer protocol packets. You will implement an API (almost the same as BSD Socket API) for applications to be able to use SBU TCP for sending and receiving data. The API your protocol supports should be exactly as follows:class Socket { private: // some needed fields and methods public: // this method creates a connection to server and creates // a thread to buffer and acknowledge arrived packets Socket (char* serverHost, int serverPort); // read size bytes from SOCKET BUFFER and save it to // readBuffer and returns the number of bytes in the // readBuffer int read (char* readBuffer, int size); // if write buffer was greater than MSS then divide // writeBuffer to packet with MSS size and then send // there bool write (char* writeBuffer, int size); // closes the socket and makes the resources free. bool close (); } class ServerSocket { private: // the list of connected sockets to this server vector connectedSockets; // some needed fields and methods public: // this method creates a thread to accept connection from // client socket ServerSocket (int port); // this method remove a socket object from first of // connected sockets or wait to a connection established. Socket accept (); // closes the socket and makes the resources free. void close (); }

Hints: Test your protocol by sending a file from a source to a destination. The bytes of the file should appear at the destination exactly in the same order as the original file.Notices: This project must be pair-programmed in two-member groups, no more and no less. A welldefined coding style must be used in all source files. Your project should be emailed to the address before the deadline. Project demonstration date will be announced and you cannot demonstrate in any other time. If youve got any questions about the project, you can post it to the course Yahoo! Group. Good luck.