8#pragma warning(disable: 4307)
11#if !LWIP_STATS || !TCP_STATS || !MEMP_STATS
12#error "This tests needs TCP- and MEMP-statistics enabled"
14#if TCP_SND_BUF <= TCP_WND
15#error "This tests needs TCP_SND_BUF to be > TCP_WND"
37 tcp_ticks = 0 - (tcp_next_iss() - 6510);
61 fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
64 fail_unless(pcb !=
NULL);
66 fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
68 fail_unless(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
79 char data[] = {1, 2, 3, 4};
82 u16_t remote_port = 0x100, local_port = 0x101;
89 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
90 data_len =
sizeof(
data);
93 counters.expected_data_len = data_len;
99 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
115 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
117 EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
130 char data1[] = { 1, 2, 3, 4};
131 char data2[] = { 5, 6, 7, 8};
132 char data3[] = { 9, 10, 11, 12};
133 char data4[] = {13, 14, 15, 16};
134 char data5[] = {17, 18, 19, 20};
135 char data6[] = {21, 22, 23, 24};
137 u16_t remote_port = 0x100, local_port = 0x101;
142 IP4_ADDR(&local_ip, 192, 168, 1, 1);
143 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
144 IP4_ADDR(&netmask, 255, 255, 255, 0);
151 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
154 pcb->cwnd = pcb->snd_wnd;
157 err = tcp_write(pcb,
data1,
sizeof(
data1), TCP_WRITE_FLAG_COPY);
159 err = tcp_output(pcb);
163 memset(&txcounters, 0,
sizeof(txcounters));
171 err = tcp_write(pcb,
data2,
sizeof(
data2), TCP_WRITE_FLAG_COPY);
173 err = tcp_output(pcb);
177 memset(&txcounters, 0,
sizeof(txcounters));
185 err = tcp_write(pcb,
data3,
sizeof(
data3), TCP_WRITE_FLAG_COPY);
187 err = tcp_output(pcb);
192 memset(&txcounters, 0,
sizeof(txcounters));
200 err = tcp_write(pcb,
data4,
sizeof(
data4), TCP_WRITE_FLAG_COPY);
208 memset(&txcounters, 0,
sizeof(txcounters));
212 err = tcp_write(pcb,
data5,
sizeof(
data5), TCP_WRITE_FLAG_COPY);
218 memset(&txcounters, 0,
sizeof(txcounters));
228 err = tcp_output(pcb);
232 memset(&txcounters, 0,
sizeof(txcounters));
235 err = tcp_write(pcb,
data5,
sizeof(
data5), TCP_WRITE_FLAG_COPY);
237 err = tcp_output(pcb);
240 err = tcp_write(pcb,
data5,
sizeof(
data5), TCP_WRITE_FLAG_COPY);
242 err = tcp_output(pcb);
245 err = tcp_write(pcb,
data5,
sizeof(
data5), TCP_WRITE_FLAG_COPY);
247 err = tcp_output(pcb);
250 err = tcp_write(pcb,
data5,
sizeof(
data5), TCP_WRITE_FLAG_COPY);
252 err = tcp_output(pcb);
262 err = tcp_write(pcb,
data5,
sizeof(
data5), TCP_WRITE_FLAG_COPY);
264 err = tcp_output(pcb);
267 err = tcp_write(pcb,
data5,
sizeof(
data5), TCP_WRITE_FLAG_COPY);
269 err = tcp_output(pcb);
287 EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
289 EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
298 struct tcp_seg *
s = segs;
300 for (
i = 0;
i < num_expected;
i++,
s =
s->next) {
318 u16_t remote_port = 0x100, local_port = 0x101;
320#define SEQNO1 (0xFFFFFF00 - TCP_MSS)
337 IP4_ADDR(&local_ip, 192, 168, 1, 1);
338 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
339 IP4_ADDR(&netmask, 255, 255, 255, 0);
348 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
354 for (
i = 0;
i < 6;
i++) {
361 err = tcp_output(pcb);
364 memset(&txcounters, 0,
sizeof(txcounters));
375 memset(&txcounters, 0,
sizeof(txcounters));
380 EXPECT(pcb->dupacks == 0);
384 EXPECT(pcb->dupacks == 1);
388 EXPECT(pcb->dupacks == 2);
392 EXPECT(pcb->dupacks == 3);
394 memset(&txcounters, 0,
sizeof(txcounters));
399 EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
401 EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
415 u16_t remote_port = 0x100, local_port = 0x101;
417#define SEQNO1 (0xFFFFFF00 - TCP_MSS)
434 IP4_ADDR(&local_ip, 192, 168, 1, 1);
435 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
436 IP4_ADDR(&netmask, 255, 255, 255, 0);
442 tcp_ticks = 0 - tcp_next_iss();
443 tcp_ticks =
SEQNO1 - tcp_next_iss();
447 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
453 for (
i = 0;
i < 6;
i++) {
460 err = tcp_output(pcb);
463 memset(&txcounters, 0,
sizeof(txcounters));
469 for (
i = 0;
i < 10;
i++) {
480 pcb->cwnd = pcb->snd_wnd;
482 err = tcp_output(pcb);
489 EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
491 EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
505 u16_t remote_port = 0x100, local_port = 0x101;
517 if (zero_window_probe_from_unsent) {
524 IP4_ADDR(&local_ip, 192, 168, 1, 1);
525 IP4_ADDR(&remote_ip, 192, 168, 1, 2);
526 IP4_ADDR(&netmask, 255, 255, 255, 0);
529 memset(&txcounters, 0,
sizeof(txcounters));
534 tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
537 pcb->cwnd = pcb->snd_wnd;
543 err = tcp_write(pcb, &
tx_data[sent_total], initial_data_len, TCP_WRITE_FLAG_COPY);
545 err = tcp_output(pcb);
549 memset(&txcounters, 0,
sizeof(txcounters));
550 sent_total += initial_data_len;
555 err = tcp_output(pcb);
559 memset(&txcounters, 0,
sizeof(txcounters));
570 EXPECT(pcb->persist_backoff == 0);
575 err = tcp_output(pcb);
579 memset(&txcounters, 0,
sizeof(txcounters));
580 EXPECT(pcb->persist_backoff == 0);
582 if (zero_window_probe_from_unsent) {
589 EXPECT(pcb->persist_backoff == 1);
593 err = tcp_write(pcb, &
tx_data[sent_total], 1, TCP_WRITE_FLAG_COPY);
595 err = tcp_output(pcb);
599 memset(&txcounters, 0,
sizeof(txcounters));
600 if (!zero_window_probe_from_unsent) {
602 EXPECT(pcb->persist_backoff == 0);
604 EXPECT(pcb->persist_backoff == 1);
607 for (
i = 0;
i < 4;
i++) {
634 EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
636 EXPECT_RET(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
660 test_tcp_fast_retx_recover,
661 test_tcp_fast_rexmit_wraparound,
662 test_tcp_rto_rexmit_wraparound,
663 test_tcp_tx_full_window_lost_from_unacked,
664 test_tcp_tx_full_window_lost_from_unsent
#define LWIP_UNUSED_ARG(x)
static const char data4[]
static const WCHAR data3[]
static const WCHAR data5[]
static const WCHAR data6[]
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei GLuint * counters
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define IP4_ADDR(ipaddr, a, b, c, d)
typedefPACK_STRUCT_END struct ip_addr ip_addr_t
static Suite * create_suite(const char *name, TFun *tests, size_t num_tests, SFun setup, SFun teardown)
static struct test_info tests[]
struct netif * netif_list
u16_t pbuf_copy_partial(struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
u8_t pbuf_free(struct pbuf *p)
void test_tcp_input(struct pbuf *p, struct netif *inp)
struct pbuf * tcp_create_rx_segment_wnd(struct tcp_pcb *pcb, void *data, size_t data_len, u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags, u16_t wnd)
struct pbuf * tcp_create_rx_segment(struct tcp_pcb *pcb, void *data, size_t data_len, u32_t seqno_offset, u32_t ackno_offset, u8_t headerflags)
struct tcp_pcb * test_tcp_new_counters_pcb(struct test_tcp_counters *counters)
void tcp_remove_all(void)
void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcounters, ip_addr_t *ip_addr, ip_addr_t *netmask)
static __inline void tcp_set_state(struct sock *sk, int state)
static END_TEST u8_t tx_data[TCP_WND *2]
static void check_seqnos(struct tcp_seg *segs, int num_expected, u32_t *seqnos_expected)
static void tcp_teardown(void)
END_TEST Suite * tcp_suite(void)
static void test_tcp_tmr(void)
static u8_t test_tcp_timer
static void tcp_setup(void)
static END_TEST void test_tcp_tx_full_window_lost(u8_t zero_window_probe_from_unsent)