CNDP  22.08.0
cnet_tcp.h File Reference
#include "cnet_const.h"
#include "cnet_pcb.h"
#include <net/cne_tcp.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/queue.h>
#include "cne_log.h"
#include "cnet_stk.h"
#include "cnet_tcp.h"
#include "mempool.h"
#include "pktmbuf.h"

Go to the source code of this file.

Data Structures

struct  tcp_stats
 

Macros

#define TCP_MIN_MSS   64
 
#define TCP_MSS   536
 
#define TCP_NORMAL_MSS   1460
 
#define TCP_MAX_MSS   (16384 - 64)
 
#define TCP_MSS_OVERHEAD   52
 
#define TCP_DEFAULT_HDR_SIZE   20
 
#define TCP_MAXWIN   ETHER_MAX_MTU
 
#define TCP_MAX_WINSHIFT   14
 
#define TCP_INITIAL_CWND   4380
 
#define TCP_VEC_SIZE   1024
 
#define TCP_MSL_TV   60
 
#define TCP_MIN_TV   2
 
#define TCP_REXMTMAX_TV   128
 
#define TCP_PERSMIN_TV   10
 
#define TCP_PERSMAX_TV   120
 
#define TCP_KEEP_INIT_TV   150
 
#define TCP_KEEP_IDLE_TV   14400
 
#define TCP_KEEPINTVL_TV   150
 
#define TCP_KEEPCNT_TV   8
 
#define TCP_SRTTBASE_TV   0
 
#define TCP_SRTTDFLT_TV   2
 
#define TCP_KEEPCNT_TV   8
 
#define TCP_RTT_SCALE   8
 
#define TCP_RTT_SHIFT   3
 
#define TCP_RTTVAR_SCALE   4
 
#define TCP_RTTVAR_SHIFT   2
 
#define TCP_ISSINCR   0x01000000
 
#define TCP_SLOWHZ   2
 
#define TCP_MAXRXTSHIFT   12
 

Typedefs

typedef struct tcp_stats tcp_stats_t
 

Enumerations

enum  tcb_state_t {
}
 
enum  {
  TCP_OPT_EOL = 0 , TCP_OPT_NOP , TCP_OPT_MSS , TCP_OPT_WSOPT ,
  TCP_OPT_SACK_OK , TCP_OPT_SACK , TCP_OPT_TSTAMP = 8
}
 
enum  {
  TCPT_REXMT = 0 , TCPT_PERSIST , TCPT_KEEP , TCPT_2MSL ,
  TCP_NTIMERS
}
 
enum  { SEG_TS_PRESENT = 0x8000 , SEG_MSS_PRESENT = 0x4000 , SEG_WS_PRESENT = 0x2000 , SEG_SACK_PERMIT = 0x1000 }
 
enum  { TCP_FAST_TIMER = 1 , TCP_SLOW_TIMER = 2 }
 
enum  {
  TCBF_PASSIVE_OPEN = 0x10000000 , TCBF_FORCE_TX = 0x20000000 , TCBF_DELAYED_ACK = 0x40000000 , TCBF_FREE_BIT_1 = 0x80000000 ,
  TCBF_RFC1122_URG = 0x01000000 , TCBF_BOUND = 0x02000000 , TCBF_FREE_BIT_2 = 0x04000000 , TCBF_FREE_BIT_3 = 0x08000000 ,
  TCBF_REQ_TSTAMP = 0x00100000 , TCBF_RCVD_SCALE = 0x00200000 , TCBF_REQ_SCALE = 0x00400000 , TCBF_SEND_URG = 0x00800000 ,
  TCBF_ACK_NOW = 0x00010000 , TCBF_SENT_FIN = 0x00020000 , TCBF_SACK_PERMIT = 0x00040000 , TCBF_RCVD_TSTAMP = 0x00080000 ,
  TCBF_NODELAY = 0x00001000 , TCBF_NAGLE_CREDIT = 0x00002000 , TCBF_OUR_FIN_ACKED = 0x00004000 , TCBF_FREE_BIT_4 = 0x00008000 ,
  TCBF_FREE_BIT_5 = 0x00000100 , TCBF_NEED_FAST_REXMT = 0x00000200 , TCBF_NOPUSH = 0x00000400 , TCBF_NOOPT = 0x00000800
}
 

Functions

static struct tcb_entry * tcb_alloc (void)
 
CNDP_API int cnet_tcp_input (struct pcb_entry *pcb, pktmbuf_t *mbuf)
 
CNDP_API void cnet_tcp_output (struct tcb_entry *tcb)
 
CNDP_API int cnet_tcp_connect (struct pcb_entry *pcb)
 
CNDP_API struct tcb_entry * cnet_tcb_new (struct pcb_entry *pcb)
 
CNDP_API void cnet_tcp_abort (struct pcb_entry *pcb)
 
CNDP_API int cnet_tcp_close (struct pcb_entry *pcb)
 
void * tcp_q_pop (struct tcp_q *tq)
 
CNDP_API void cnet_tcp_dump (const char *msg, struct cne_tcp_hdr *tcp)
 
CNDP_API void cnet_tcb_list (stk_t *stk, struct tcb_entry *tcb)
 
CNDP_API void cnet_tcb_dump (void)
 

Detailed Description

CNET TCP protocol routines and constants.

Definition in file cnet_tcp.h.

Macro Definition Documentation

◆ TCP_MIN_MSS

#define TCP_MIN_MSS   64

Minimum segment size

Definition at line 219 of file cnet_tcp.h.

◆ TCP_MSS

#define TCP_MSS   536

Default Segment size (576 - 40)

Definition at line 220 of file cnet_tcp.h.

◆ TCP_NORMAL_MSS

#define TCP_NORMAL_MSS   1460

Normal TCP MSS value

Definition at line 221 of file cnet_tcp.h.

◆ TCP_MAX_MSS

#define TCP_MAX_MSS   (16384 - 64)

Max TCP segment size

Definition at line 222 of file cnet_tcp.h.

◆ TCP_MSS_OVERHEAD

#define TCP_MSS_OVERHEAD   52

Size of Header(IPv4/v6/TCP) overhead

Definition at line 223 of file cnet_tcp.h.

◆ TCP_DEFAULT_HDR_SIZE

#define TCP_DEFAULT_HDR_SIZE   20

Default/minimum TCP header

Definition at line 224 of file cnet_tcp.h.

◆ TCP_MAXWIN

#define TCP_MAXWIN   ETHER_MAX_MTU

Max unscaled Window value

Definition at line 229 of file cnet_tcp.h.

◆ TCP_MAX_WINSHIFT

#define TCP_MAX_WINSHIFT   14

Max Window index value

Definition at line 230 of file cnet_tcp.h.

◆ TCP_INITIAL_CWND

#define TCP_INITIAL_CWND   4380

Max congestion window

Definition at line 231 of file cnet_tcp.h.

◆ TCP_VEC_SIZE

#define TCP_VEC_SIZE   1024

TCP Vector size

Definition at line 232 of file cnet_tcp.h.

◆ TCP_MSL_TV

#define TCP_MSL_TV   60

30 Seconds Max Segment Lifetime

Definition at line 235 of file cnet_tcp.h.

◆ TCP_MIN_TV

#define TCP_MIN_TV   2

1 Second retransmit timer.

Definition at line 236 of file cnet_tcp.h.

◆ TCP_REXMTMAX_TV

#define TCP_REXMTMAX_TV   128

64 Second retransmit timer.

Definition at line 237 of file cnet_tcp.h.

◆ TCP_PERSMIN_TV

#define TCP_PERSMIN_TV   10

5 Second minimum persist timer.

Definition at line 238 of file cnet_tcp.h.

◆ TCP_PERSMAX_TV

#define TCP_PERSMAX_TV   120

60 Seconds Max persist timer.

Definition at line 239 of file cnet_tcp.h.

◆ TCP_KEEP_INIT_TV

#define TCP_KEEP_INIT_TV   150

75 Seconds connection established

Definition at line 240 of file cnet_tcp.h.

◆ TCP_KEEP_IDLE_TV

#define TCP_KEEP_IDLE_TV   14400

7200 Seconds idle time (first)

Definition at line 241 of file cnet_tcp.h.

◆ TCP_KEEPINTVL_TV

#define TCP_KEEPINTVL_TV   150

75 Seconds between probes

Definition at line 242 of file cnet_tcp.h.

◆ TCP_KEEPCNT_TV [1/2]

#define TCP_KEEPCNT_TV   8

Max number keepalive probes.

Definition at line 246 of file cnet_tcp.h.

◆ TCP_SRTTBASE_TV

#define TCP_SRTTBASE_TV   0

special value

Definition at line 244 of file cnet_tcp.h.

◆ TCP_SRTTDFLT_TV

#define TCP_SRTTDFLT_TV   2

default RTT (1 seconds)

Definition at line 245 of file cnet_tcp.h.

◆ TCP_KEEPCNT_TV [2/2]

#define TCP_KEEPCNT_TV   8

Max number keepalive probes.

Definition at line 246 of file cnet_tcp.h.

◆ TCP_RTT_SCALE

#define TCP_RTT_SCALE   8

multiplier srtt = srtt x 8

Definition at line 248 of file cnet_tcp.h.

◆ TCP_RTT_SHIFT

#define TCP_RTT_SHIFT   3

shift srtt = srtt << 3

Definition at line 249 of file cnet_tcp.h.

◆ TCP_RTTVAR_SCALE

#define TCP_RTTVAR_SCALE   4

multiplier rttvar = rttvar x 4

Definition at line 250 of file cnet_tcp.h.

◆ TCP_RTTVAR_SHIFT

#define TCP_RTTVAR_SHIFT   2

shift rttvar = rttvar << 2

Definition at line 251 of file cnet_tcp.h.

◆ TCP_ISSINCR

#define TCP_ISSINCR   0x01000000

Initial SYN Start increment

Definition at line 253 of file cnet_tcp.h.

◆ TCP_SLOWHZ

#define TCP_SLOWHZ   2

Slow hertz

Definition at line 254 of file cnet_tcp.h.

◆ TCP_MAXRXTSHIFT

#define TCP_MAXRXTSHIFT   12

Max retransmissions

Definition at line 284 of file cnet_tcp.h.

Typedef Documentation

◆ tcp_stats_t

typedef struct tcp_stats tcp_stats_t

TCP counters.

Enumeration Type Documentation

◆ tcb_state_t

TCP states (numeric values match those in RFC2452)

Enumerator
TCPS_CLOSED 

TCB is Closed

TCPS_LISTEN 

TCB is listening

TCPS_SYN_SENT 

Sent SYN segment

TCPS_SYN_RCVD 

Received SYN segment

TCPS_ESTABLISHED 

Connection is established

TCPS_CLOSE_WAIT 

Connection is in close wait state

TCPS_FIN_WAIT_1 

Connection is in FIN wait 1 state

TCPS_CLOSING 

Connection is closing

TCPS_LAST_ACK 

Connection is in Last ACK state

TCPS_FIN_WAIT_2 

Connection is in FIN wait 2 state

TCPS_TIME_WAIT 

Connection is in time wait state

Definition at line 122 of file cnet_tcp.h.

◆ anonymous enum

anonymous enum
Enumerator
TCP_OPT_EOL 

End of Line flag

TCP_OPT_NOP 

Noop type option

TCP_OPT_MSS 

MSS option type

TCP_OPT_WSOPT 

Window Scaling option

TCP_OPT_SACK_OK 

SACK OK option

TCP_OPT_SACK 

SACK option

TCP_OPT_TSTAMP 

Timestamp option

Definition at line 198 of file cnet_tcp.h.

◆ anonymous enum

anonymous enum
Enumerator
TCPT_REXMT 

Retransmit timer index

TCPT_PERSIST 

Persist timer index

TCPT_KEEP 

Keepalive or Connection Established timer

TCPT_2MSL 

2 x Max Segment Life or FIN Wait 2 timer

TCP_NTIMERS 

Number of timers in tcb_t.timers

Definition at line 294 of file cnet_tcp.h.

◆ anonymous enum

anonymous enum
Enumerator
SEG_TS_PRESENT 

Timestamp is present

SEG_MSS_PRESENT 

MSS option is present

SEG_WS_PRESENT 

Window Scale present

SEG_SACK_PERMIT 

SACK permission flag, which is not supported at this time.

Definition at line 327 of file cnet_tcp.h.

◆ anonymous enum

anonymous enum
Enumerator
TCP_FAST_TIMER 

Fast TCP timer (200ms)

TCP_SLOW_TIMER 

Slow TCP timer (500ms)

Definition at line 334 of file cnet_tcp.h.

◆ anonymous enum

anonymous enum
Enumerator
TCBF_PASSIVE_OPEN 

Passive open

TCBF_FORCE_TX 

Do an ACK now from persist

TCBF_DELAYED_ACK 

DELAYED ACK

TCBF_RFC1122_URG 

RFC1122 Urgent

TCBF_BOUND 

TCB is Bound

TCBF_REQ_TSTAMP 

Requested Timestamp option

TCBF_RCVD_SCALE 

Window Scaling received

TCBF_REQ_SCALE 

Requested Window Scaling

TCBF_SEND_URG 

Send urgent data

TCBF_ACK_NOW 

ACK Now

TCBF_SENT_FIN 

FIN has been sent

TCBF_SACK_PERMIT 

SACK Permit is not supported, look at SEG_SACK_PERMIT

TCBF_RCVD_TSTAMP 

Received Timestamp in SYN

TCBF_NODELAY 

don't delay packets

TCBF_NAGLE_CREDIT 

Nagle credit flag

TCBF_OUR_FIN_ACKED 

Our FIN has been acked

TCBF_NEED_FAST_REXMT 

Need a fast Retransmit

TCBF_NOPUSH 

no push

TCBF_NOOPT 

don't use TCP options

Definition at line 416 of file cnet_tcp.h.

Function Documentation

◆ tcb_alloc()

static struct tcb_entry* tcb_alloc ( void  )
inlinestatic

Allocate a new TCB control block from the free list of TCB structures.

Definition at line 566 of file cnet_tcp.h.

◆ cnet_tcp_input()

CNDP_API int cnet_tcp_input ( struct pcb_entry *  pcb,
pktmbuf_t mbuf 
)

The TCP input routine

Parameters
pcbThe PCB pointer for this connection
mbufThe mbuf to process in TCP input
Returns
0 on success or -1 on error.

◆ cnet_tcp_output()

CNDP_API void cnet_tcp_output ( struct tcb_entry *  tcb)

The TCP output routine.

Parameters
tcbThe TCB to process output packets from.

◆ cnet_tcp_connect()

CNDP_API int cnet_tcp_connect ( struct pcb_entry *  pcb)

The TCP connect function gives the PCB to use for the connection

Parameters
pcbThe PCB pointer in which to do the connection request.
Returns
0 on success or -1 on error

◆ cnet_tcb_new()

CNDP_API struct tcb_entry* cnet_tcb_new ( struct pcb_entry *  pcb)

Create a new TCB for the given PCB pointer.

Parameters
pcbThe PCB to create the TCB from.
Returns
TCB pointer or NULL on failure.

◆ cnet_tcp_abort()

CNDP_API void cnet_tcp_abort ( struct pcb_entry *  pcb)

Abort the TCP connection

Parameters
pcbThe PCB pointer in which to start the abort sequence.

◆ cnet_tcp_close()

CNDP_API int cnet_tcp_close ( struct pcb_entry *  pcb)

Close the TCP connection for the given PCB

Parameters
pcbThe PCB in which to start the connect close sequence
Returns
-1 on error or 0 on success

◆ tcp_q_pop()

void* tcp_q_pop ( struct tcp_q *  tq)

Remove an entry from the queue

◆ cnet_tcp_dump()

CNDP_API void cnet_tcp_dump ( const char *  msg,
struct cne_tcp_hdr tcp 
)

Dump out the TCP header and information

Parameters
msgA caller supplied message or NULL if none
tcpThe TCP header to dump

◆ cnet_tcb_list()

CNDP_API void cnet_tcb_list ( stk_t *  stk,
struct tcb_entry *  tcb 
)

List out all of the active TCB structures

Parameters
stkThe stack instance to dump the TCB from
tcbThe TCB structure to dump or NULL for all TCB structures.

◆ cnet_tcb_dump()

CNDP_API void cnet_tcb_dump ( void  )

Dump out all TCBs in all stack instances.