Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
Regarding implementing a new transport protocol

I am trying to implement my own Transport Layer Protocol like TCP which will be used by some application, on top of network layer using raw sockets API in Linux. I am working on Ubuntu 14.04.

I have been able to send and receive packets.

Now in the part of implementing the Transport Protocol, I am looking forward to write some functions like

connect(int sockfd) - To establish connection to the server.

send_data(int sockfd, char* data) - To send data

receive_data(int sockfd, char* data) - To receive data

close(int sockfd) - close the connection

Also since I am trying to implement protocol like TCP, to keep the protocol reliable I want to send acknowledgement for each received data packet. I have made my own TCP like header as follows

typedef struct rtlp_hdr
{
    int         checksum; 
    short int   src_port;  //defined by us
    short int   des_port;  //defined by us
    int         seq_no;
    int         ack_no;

}rtlp_hdr;

Now in the implementation of the send_data function after I send a data packet I wait to receive the acknowledgement for the next data packet for given time, and if I don't receive any ack or I receive a corrupted ack( after checking the checksum) I resend the data. I am facing problems in creating the corresponding receive_data function for the same, like how would I know that the ack sent for the received data has been successfully delivered to the sender, since there is no ack for ack.

If anyone has any ideas what can I do or if I am going in the wrong direction please correct me. thanks in advance.

I have already written code for the connect(int sockfd) using 3-way handshaking that is working fine, I can share that.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

As mentioned, there is no way to guarantee that a message arrives at the destination. If i understand your question right i hope the simple example below can help you.

You have a client A, and a server B. Client A sends a packet named A1 to B. B saves the name of the last received packet, and replies to A with an ack.

If the ack makes it to the client it sends the next packet, named A2.

If, however, the ack is lost, the client resends the data named A1 after a while. When the server receives A1 a second time (using the saved name), it can assume that the ack was lost. The server then resends the ack, hoping that it will make it to the client this time. This continues as many times as neccessary.

As you see, the server does not need to know if the ack has been delivered to the client. The receiving of a duplicate packet tells the server that the ack was lost. (ignoring spurious timeouts for simplicity)

over 4 years ago · Santiago Trujillo Report

0

You are facing the Byzantine Generals' problem of protocols: there is never a guarantee that a message arrives. If you send a message to ack that the message arrived, it may not arrive; if you send a poll to enquire if the message has arrived, it may never arrive or its answer may never arrive...

So protocols can at best be "mostly reliable" and in your design you must include non-arrival, and your software must be able to cope with it. "The software" may mean all the way up to the application layer.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!