a-lunev opened a new pull request #5242:
URL: https://github.com/apache/incubator-nuttx/pull/5242


   ## Summary
   
   Both the snd_ackcb and snd_datacb callbacks were created and destroyed right 
after sending every packet.
   Whenever TCP_REXMIT event occurred due to TCP send timeout, TCP_REXMIT was 
ignored because
   snd_ackcb callback had been destroyed by the time.
   The issue is fixed as follows:
   - both the snd_ackcb and snd_datacb callbacks are combined into one snd_cb 
callback
     (the same way as in tcp_send_unbuffered.c).
   - the snd_cb callback lives until all requested data (via sendfile) is sent,
     including all ACKs and possible retransmissions.
   
   As a positive side effect of the code optimization / fix, sendfile TCP 
payload throughput is increased (the TCP payload throughput of tcp_sendfile is 
increased from 234 Mbit/s up to about 432 Mbit/s (sim:tcpblaster config on my 
Linux setup)).
   
   ## Impact
   
   TCP sendfile
   
   ## Testing
   
   Activate emulating packet loss on Linux host:
   `$ sudo iptables -A INPUT -p tcp --dport 5471 -m statistic --mode random 
--probability 0.01 -j DROP`
   
   Build NuttX:
   ```
   $ ./tools/configure.sh -l sim:tcpblaster
   $ make menuconfig (enable CONFIG_NETUTILS_NETCAT_SENDFILE, disable 
CONFIG_NET_TCP_WRITE_BUFFERS)
   $ make
   ```
   Enable TUN/TAP on Linux host:
   ```
   $ sudo setcap cap_net_admin+ep ./nuttx
   $ sudo ./tools/simhostroute.sh wlan0 on
   ```
   Start iperf on Linux host:
   `$ iperf -s -p 5471 -i 1 -w 416K`
   
   Run NuttX on Linux host:
   ```
   $ ./nuttx
   NuttShell (NSH) NuttX-10.2.0
   nsh> ifconfig eth0 10.0.1.2
   nsh> ifup eth0
   ifup eth0...OK
   ```
   Start Wireshark (or tcpdump) and capture appeared tap0 interface.
   
   Run netcat in NuttX:
   ```
   nsh> dd if=/dev/zero of=/tmp/test.bin count=1000
   nsh> netcat LINUX_HOST_IP_ADDRESS 5471 /tmp/test.bin
   
   ```
   
   Observe packet loss -> TCP Retransmissions in TCP dump.
   
   Deactivate emulating packet loss on Linux host:
   `$ sudo iptables -D INPUT -p tcp --dport 5471 -m statistic --mode random 
--probability 0.01 -j DROP`
   
   Run netcat in NuttX:
   ```
   nsh> dd if=/dev/zero of=/tmp/test.bin count=10000
   nsh> netcat LINUX_HOST_IP_ADDRESS 5471 /tmp/test.bin
   nsh> poweroff
   ```
   
   iperf on Linux host:
   ```
   $ iperf -s -p 5471 -i 1 -w 416K
   ------------------------------------------------------------
   Server listening on TCP port 5471
   TCP window size:  416 KByte
   ------------------------------------------------------------
   [  4] local 192.168.1.68 port 5471 connected with 10.0.1.2 port 25367
   [ ID] Interval       Transfer     Bandwidth
   [  4]  0.0- 0.1 sec  4.88 MBytes   432 Mbits/sec
   
   ```
   
   Disable TUN/TAP on Linux host:
   `$ sudo ./tools/simhostroute.sh wlan0 off`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to