Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: TCP Over UDP

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default TCP Over UDP

    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 ();
    }
    Last edited by JavaPF; July 12th, 2009 at 09:40 AM. Reason: Please use [code] [/code] tags


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: TCP Over UDP

    I take it this is some sort of assignment. Are you actually writing this in Java rather then C/C++ because you do know you're on a Java forum.

    Unfortunately I've never been a socket programmer myself so I wouldn't really know how to do this, but I would probably get by using Google.

    // Json

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: TCP Over UDP

    I want to implement by java it's not an assignment it 's only a guideline please help me or give it me some links about this subject

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: TCP Over UDP

    Hello azarakhsh,

    Try these links:

    Lesson: All About Sockets (The Java™ Tutorials > Custom Networking)

    Java TCP Sockets and Swing Tutorial
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers