Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda