When does the TCP engine decide to send an ACK?

10,731

Solution 1

The TCP implementation ACKs every other data packet. So you should see, typically, two data packets received and then an ACK sent. The sender, of course, is not waiting for the ACK anyway. It will continue to transmit until the window is full, even in the absence of an ACK.

There are other factors potentially at play here, such as Nagle and delayed ACK. But it doesn't look like you're seeing the affects of them.

Solution 2

There are mainly two mechanisms to reduce the amount of ACK packets returned - the Nagle algorithm and Delayed ACKs - both described in RFC 1122. Both are optional, so there will be hosts which are either configured not to use them or have the appropriate implementation missing. Especially Samba can be instructed to disable the Nagle algorithm by using socket options = TCP_NODELAY in the configuration.

Your difference in upstream / downstream data rates for SMB file copies is likely to have other reasons than an abundance of TCP ACK packets though.

Share:
10,731

Related videos on Youtube

sliter
Author by

sliter

Updated on September 18, 2022

Comments

  • sliter
    sliter almost 2 years

    In my LAN, I have a router that runs a Samba server and my PC connects to the router.

    I wiresharked during a uploading to the server and a downloading from the server.

    The wireshark results show that:

    • During the uploading, the server sends an ACK every 0.6ms average
    • During the downloading, my PC send an ACK every 0.025ms average

    As a consequence, the downloading generates about 120,000 frames while the uploading only generates 70,000 frames. And the downloading rate is about 12.7Mbytes/s while the uploading rate is 20Mbytes/s.

    So I want to figure out the possible reason for this.

    • Admin
      Admin over 12 years
      A number of things could be determining this, switch performance and buffer sizes, disk capabilities on either end.
    • Admin
      Admin over 12 years
      The reason for what?
  • sliter
    sliter over 12 years
    This is exactly what I saw for the downloading, my PC ACKs after receiving two packets but not for the uploading. Besides, where the kernel's implementation for ACKing every other data packet?
  • David Schwartz
    David Schwartz over 12 years
    What did you see during the uploading? The logic for ACKing is primarily in the __tcp_ack_snd_check function in tcp_input.c and tcp_send_delayed_ack in tcp_output.c.
  • sliter
    sliter over 12 years
    Yes, the main reason for this is the capabilities of CPU. My PC is capable of sending a packet every 12.5us average while the router sends a packet every 90us average. So, the uploading should be 7 time faster, but it didn't. That's why I think the ACK also has a quite important influence.
  • sliter
    sliter over 12 years
    For uploading, between two ACKs, there are around 22 frames transmitted. My guess is that, for uploading the delayed ACK is activated. Because, the time between ACKs is 0.6ms which is smaller than TCP_DELACK_MAX(2ms) and larger than TCP_DELACK_MIN(0.4ms). What you think?
  • David Schwartz
    David Schwartz over 12 years
    Even so, the window should be large enough that the ACKs shouldn't be affecting performance.
  • the-wabbit
    the-wabbit over 12 years
    @sliter The number of ACKs would only influence the throughput if your router is operating at the maximum forwarding capacity regarding its packets per second performance (each received / forwarded / processed packet will obviously cost CPU performance) or if your upstream can't handle the sustained data rate needed for the ACKs. I would suggest looking into your router's/Samba server's performance metrics to check if the CPU is bottlenecking there on both occasions.