Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

stm32 - TCP Retransmition

I am trying to do TCP connection between two stm32 device. Firstly everything is perfect between the line we see on the wireshark.When the TCP client reset and try to send new data, wireshark shows me Retransmittion TCP message but when I debug the server side, server side get the message and send echo message after client receive this echo message.

Why the retransmition message shows, althoug I get and send message to other side ?

FULL client code: https://paste.ubuntu.com/p/VJHzgv29FM/

FULL server code : https://paste.ubuntu.com/p/Wm9gvkSfF7/

enter image description here

/**
  * @brief  Initializes the tcp echo server
  * @param  None
  * @retval None
  */
void tcp_echoserver_init(void)
{
  /* create new tcp pcb */
  tcp_echoserver_pcb = tcp_new();

  if (tcp_echoserver_pcb != NULL)
  {
    err_t err;

    /* bind echo_pcb to port 7 (ECHO protocol) */
    err = tcp_bind(tcp_echoserver_pcb, IP_ADDR_ANY, 7);

    if (err == ERR_OK)
    {
      /* start tcp listening for echo_pcb */
      tcp_echoserver_pcb = tcp_listen(tcp_echoserver_pcb);

      /* initialize LwIP tcp_accept callback function */
      tcp_accept(tcp_echoserver_pcb, tcp_echoserver_accept);
    }
    else
    {
      /* deallocate the pcb */
      memp_free(MEMP_TCP_PCB, tcp_echoserver_pcb);
    }
  }
}

Client:

/**
  * @brief  Connects to the TCP echo server
  * @param  None
  * @retval None
  */
void tcp_echoclient_connect(void)
{
  ip_addr_t DestIPaddr;
  /* create new tcp pcb */

  echoclient_pcb = tcp_new();

  if (echoclient_pcb != NULL)
  {
    IP4_ADDR(&DestIPaddr, (uint8_t)192, (uint8_t)168, (uint8_t)1, (uint8_t)40);
    /* connect to destination address/port */
    tcp_connect(echoclient_pcb,&DestIPaddr,7,tcp_echoclient_connected);
  }
  else
  {
    SerialPrint("not null");
    memp_free(MEMP_TCP_PCB, echoclient_pcb);
  }  

}

question from:https://stackoverflow.com/questions/65939519/tcp-retransmition

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When using wireshark to analyze network stream, here is a doc from wireshark that can help you understand what these words means.

We can see the following thing:

TCP Retransmission

Set when all of the following are true:

  • This is not a keepalive packet.

  • In the forward direction, the segment length is greater than zero or the SYN or FIN flag is set.

  • The next expected sequence number is greater than the current sequence number.

For your circumstance, the problem is that the segment length is greater than zero or the SYN or FIN flag is set. This is caused by your reset, so this doesn't mean that your TCP connection causes retransmission.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...