Hi
I want to implement a TCP transport layer protocl with UDP socket (UDP implemention of TCP).I put it describtion below Please give me a java UDP implemention of TCP.
Prerequisites: Here we assume that you’re familiar with C & C++ language and network socket programming. In this project, we are going to use UDP socket API to implement TCP.
Description: As you know, TCP includes many features to support reliable transmission, flow control and congestion control. In congestion control, you can use TCP well known procedures like slow start, fast retransmission and additive increase/multiplicative decrease. The 3–way handshake for TCP connection setup is required but special cases need not be supported. To protect packets against bit level errors, use 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).
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 should update your RTT calculation and RTO for every packet acked.
You will implement an API for applications to be able to use it for sending and receiving data. The API your protocol supports should be as follows but another private fields and private methods can be added to it:
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<Socket> 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 (); }