Merged in masayuki2009/nuttx.nuttx/tcp_rcvwnd_control (pull request #555)

net/tcp: Introduce tcp receive window control based on I/O buffer

NOTE: The algorithm is still experimental but useful for http streaming.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Masayuki Ishikawa 2017-12-18 12:11:52 +00:00 committed by Gregory Nutt
parent 3582208496
commit 30070b06df
2 changed files with 32 additions and 0 deletions

View File

@ -192,4 +192,13 @@ config NET_SENDFILE
files out a TCP connection. files out a TCP connection.
endif # NET_TCP && !NET_TCP_NO_STACK endif # NET_TCP && !NET_TCP_NO_STACK
config NET_TCP_RWND_CONTROL
bool "Receive window control based on IOBuffer"
default n
depends on MM_IOB && EXPERIMENTAL
---help---
Support receive window control based on I/O buffer. This feature
is still experimental.
endmenu # TCP/IP Networking endmenu # TCP/IP Networking

View File

@ -54,6 +54,10 @@
#include <nuttx/net/ip.h> #include <nuttx/net/ip.h>
#include <nuttx/net/tcp.h> #include <nuttx/net/tcp.h>
#ifdef CONFIG_NET_TCP_RWND_CONTROL
# include <nuttx/semaphore.h>
#endif
#include "devif/devif.h" #include "devif/devif.h"
#include "inet/inet.h" #include "inet/inet.h"
#include "tcp/tcp.h" #include "tcp/tcp.h"
@ -309,6 +313,12 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
FAR struct tcp_conn_s *conn, FAR struct tcp_conn_s *conn,
FAR struct tcp_hdr_s *tcp) FAR struct tcp_hdr_s *tcp)
{ {
#ifdef CONFIG_NET_TCP_RWND_CONTROL
extern sem_t g_qentry_sem;
int qentry_sem_count;
uint32_t rwnd;
#endif
/* Copy the IP address into the IPv6 header */ /* Copy the IP address into the IPv6 header */
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
@ -341,6 +351,19 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
tcp->srcport = conn->lport; tcp->srcport = conn->lport;
tcp->destport = conn->rport; tcp->destport = conn->rport;
#ifdef CONFIG_NET_TCP_RWND_CONTROL
/* Update the TCP received window based on I/O buffer */
/* NOTE: This algorithm is still experimental */
if (OK == nxsem_getvalue(&g_qentry_sem, &qentry_sem_count))
{
rwnd = (qentry_sem_count * CONFIG_NET_ETH_TCP_RECVWNDO)
/ CONFIG_IOB_NCHAINS;
NET_DEV_RCVWNDO(dev) = (uint16_t)rwnd;
}
#endif
/* Set the TCP window */ /* Set the TCP window */
if (conn->tcpstateflags & TCP_STOPPED) if (conn->tcpstateflags & TCP_STOPPED)