Open In App

Reliable User Datagram Protocol (RUDP)

RUDP stands for Reliable user datagram protocol, whereas UDP is one of the core members of IP i.e internet protocol suite. UDP is used as a highly time-sensitive communicative protocol. R in RUDP stands for Reliable, it is a UDP-based data transfer but with higher Reliability. It provides reliability by using the sliding window protocol. RUDP is basically the solution to the UDP where data reliability along with confirmation is needed.

As UDP provides unreliable data transfer protocol which is unreliable services of things and the worst it sometimes goes missing without notice. Reliable UDP uses both positive and negative feedback to provide data reliability which provides reliable data transfer.



In UDP sender’s simply send a message without a piece of prior information about the receiver’s availability which results in a faster rate but it can result in the loss of some packages, also the receiver can receive duplicate packets and UDP also does not provide information that the package has been received or not. RUDP used a sliding window protocol that delivers or transfers the datagram with reliability.

RUDP Architecture 

The sending process and receiving process of the architecture both stand in the application layer. The sender server sends the data packets to the receiving channel using RUDP protocol; a window size is maintained by both the sender and the receiver, the window consists of some predefined value tending to maximum avoiding the communication errors taking all the edge cases where the packets can be dropped. 



RUDP Protocol Architecture

Implementation of RUDP protocol:

Use synchronized shared buffers using counting semaphores so that only one thread access the buffer at a time to prevent the deadlock situation from occurring. 

Let’s keep two-variable called as the base and next to keep the track of the window functioning. If the sender sent’s the packet, the variable next is incremented to 1, this is the way of calculating the number of packets in the buffer.

The timeouts are handled using the timers which are scheduled immediately after sending the packet over the channel, simulate the packet loss rate and random network delay in the protocol.

packets are kept in a queue and assigned a value that values the system’s current time plus the network delay. When the current time of the system is associated with the assigned value the packet is freed from the queue and sent over the network. While the packet is sent over the network it gives an (ACK) acknowledgment. When the ack matches with the sequence number senders send another packet assigning it with the consecutive number.

Classes in RUDP Protocol:

Following are the classes that are used to implement the RUDP protocol:

Sliding Window Protocol:

Sliding window protocol also known as RUDP’s SWP on which RUDP is based, is used where the reliability comes into play and it is very much essential or for security reasons where the knowledge of data transferred along with confirmation is required. It works in segments which means it divides the provided data into segments then packets or data packets are prepared and sent over the network, resulting in when the receiver receives the package it checks the order of the packets and discards duplicates and after that, is sent it sends the acknowledgment to the sender for the correctly received packets.

There are 3 Sliding window Protocols:

Piggy-backing Technique:

Sliding window Protocol uses the piggy-backing technique, the technique is based on the acknowledgment that is received but, how is received? So, the answer is it provides the sliding window protocol to attach the acknowledgment in the next frame so that when a receiver receives the data it maintains a set of sequence numbers which is corresponding to the frames that are also can be called acknowledgment frames within a window portion of same or different sizes.

The mathematics of frame calculation:

When a new packet is sent by the sender to the receiver it is given the highest packet sequence mark and the window’s upper edge is incremented with one for the acknowledged frames and vice versa for the unacknowledged frames. That calculates the mark of unacknowledged frames as well as acknowledged frames and when this number comes to zero that means all the packets have been delivered successfully and it provides feedback to the sender. It is used in data-intensive applications that require a lot of work in a very less amount of time over high-speed networks, where reliability plays a very important role.

Server-Side Code Architecture:

Server-Side Code Architecture:

Receiver Side Code Architecture:

Receiver Side Code Architecture:

PseudoCode for RUDP Class:

Class RUDP{
//setting up the window sizes
set Receiver Window size
set Sender Window size
start receiver thread that receives the aka(Acknowledgment) and data for both the receiver and the sender
//sender calls
sent_data(byte[] data_gram, int size)
{
     //process flow => data -> segments -> store into sender buffer -> send -> start timer
     //breaking into segments and sending along with frames
     Divide into the segments.
     put every segment into the sender's buffer
     segment sending using sent_udp() of support_RUDP class
     timeout scheduling for the data that is divided into segments using frames
}
//receiver calls
receive_data(byte[] buffer, int size)
{
     //receiving of the segments of the data packets
     segment receiving once at a time including the frames
}
//call by both the sender and receiver
close()
{
     //creation of flag for the indication
     creation of a flag segment to indicate the data transfer status
     //verification of the data
     //if data receiving completed -> close
     once the complete data is received close the segment
}
}
//RUDP class ends here

Pseudo Code of Thread_receiver class:

Class Thread_receiver
{
while(true)
    {
         //waiting for the packet -> received
         Receive the packet from socket
         //numberize or make checksum of the data
        individualize a segment from the packet that is received
         //verification of the data
         checksum verification that is sent along the frames
         if segment contains acknowledgment
          process -> remove segments from the sender's buffer
         if segment contains data
          put data->receiver's buffer
          send acknowledgment
    }
}
//end of Thread_receiver Class  

Pseudo Code for Support_RUDP class:

Class Support_RUDP
{
    //simulate over the conditions that can cause the segments not received completely
    random network delay
    network loss
    any other potential that can effect the packet
    //process
    packets from the segments received processing
    //sent
    sent the data packet over the socket
}
//end of Support_RUDP class

Pseudo Code for Client-Server Class
//Sender
Class Client{
    RUDP rudp = new RUDP(Host_name, Port, Local);
    //send the data
    rudp.send();
    //close
    rudp.close();
}
//client class end
//Receiver Class start
Class Server{
    RUDP rudp = new RUDP(Host_name, Port, Local);
    //receive the data
    rudp.receive();
    //close
    rudp.close();
}

Article Tags :