There is no receive window size.

Client(send) overrides host(receive) window size.
It's one of the reasons why telnet chars and gopher files/links tend to drop. Packetloss/timeout.
This commit is contained in:
Z8Griz 2024-08-26 07:16:48 -06:00
parent 1f750d9237
commit 1a5368962b
2 changed files with 10 additions and 7 deletions

View file

@ -6,7 +6,10 @@
#define TCP_RTO_MIN 0.2 #define TCP_RTO_MIN 0.2
#define TCP_RTO_MAX 10 #define TCP_RTO_MAX 10
#define TCP_WINDOW_SIZE 8192 #define TCP_WINDOW_SIZE 8192 // Should not be static. For now it's okay
U16 RECEIVE_WINDOW; // gets host window size. It is not static.
U16 SEND_WINDOW; // gets receive window size from host, then adjust accordingly.
#define TCP_MSS 536 // Max Segment Size default #define TCP_MSS 536 // Max Segment Size default
@ -24,7 +27,7 @@
#define TCP_STATE_LAST_ACK 9 #define TCP_STATE_LAST_ACK 9
#define TCP_STATE_TIME_WAIT 10 #define TCP_STATE_TIME_WAIT 10
// TCP header flags. Test with Bt(), e.g. Bt(&flags, TCPf_RST) // TCP header flags. Order of Operation matters. Test with Bt(), e.g. Bt(&flags, TCPf_RST)
#define TCPf_FIN 0 #define TCPf_FIN 0
#define TCPf_SYN 1 #define TCPf_SYN 1
#define TCPf_RST 2 #define TCPf_RST 2

View file

@ -101,7 +101,7 @@ I64 TCPPacketAllocate(U8 **frame_out,
header->ack_num = EndianU32(ack_num); header->ack_num = EndianU32(ack_num);
header->data_offset = (sizeof(CTCPHeader) / 4) << 4; // ??? header->data_offset = (sizeof(CTCPHeader) / 4) << 4; // ???
header->flags = flags; header->flags = flags;
header->window_size = EndianU16(TCP_WINDOW_SIZE / 2);// TODO: What is window size supposed to be ? header->window_size = EndianU16(TCP_WINDOW_SIZE);// Window Size allocation data. Adjusted based on receive window.
header->checksum = 0; header->checksum = 0;
header->urgent_pointer = 0; header->urgent_pointer = 0;
@ -647,8 +647,8 @@ CTCPSocket TCPSocket(U16 domain=AF_UNSPEC)
QueueInit(accept_queue); // init pending connection queue QueueInit(accept_queue); // init pending connection queue
tcp_socket->accept_queue = accept_queue; tcp_socket->accept_queue = accept_queue;
tcp_socket->receive_buffer_size = TCP_WINDOW_SIZE; tcp_socket->receive_buffer_size = RECEIVE_WINDOW;
tcp_socket->receive_buffer = CAlloc(TCP_WINDOW_SIZE); tcp_socket->receive_buffer = CAlloc(RECEIVE_WINDOW);
tcp_socket->max_segment_size = TCP_MSS; tcp_socket->max_segment_size = TCP_MSS;
@ -1057,7 +1057,7 @@ I64 TCPSocketConnect(CTCPSocket *tcp_socket, CSocketAddressStorage *address)
} }
tcp_socket->connection_time = tS; tcp_socket->connection_time = tS;
tcp_socket->receive_window = TCP_WINDOW_SIZE; tcp_socket->receive_window = RECEIVE_WINDOW;
tcp_socket->state = TCP_STATE_SYN_SENT; tcp_socket->state = TCP_STATE_SYN_SENT;
TCPSendFlags(tcp_socket, TCPF_SYN); TCPSendFlags(tcp_socket, TCPF_SYN);
@ -1165,7 +1165,7 @@ CTCPSocket *TCPSocketAccept(CTCPSocket *tcp_socket)
new_socket->next_recv_seq_num = ++pending->segment_seq_num; new_socket->next_recv_seq_num = ++pending->segment_seq_num;
new_socket->connection_time = tS; new_socket->connection_time = tS;
new_socket->receive_window = TCP_WINDOW_SIZE; new_socket->receive_window = RECEIVE_WINDOW;
new_socket->timeout = tcp_socket->timeout; new_socket->timeout = tcp_socket->timeout;
temp_addr = &tcp_socket->source_address; temp_addr = &tcp_socket->source_address;