mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-30 00:41:17 +01:00
[sys net destiny]
- fixed a bug where a retransmit of a payload tcp_hc packet did not have the payload added because total_sent_bytes wasnt reset to 0 after last transmit
This commit is contained in:
parent
af34855d46
commit
fef556dd66
@ -228,6 +228,7 @@ void send_tcp_thread (void)
|
||||
{
|
||||
printf("Could not send %s!\n", current_message.tcp_string_msg);
|
||||
}
|
||||
printf("Finished sending!\n");
|
||||
msg_reply(&recv_msg, &send_msg);
|
||||
}
|
||||
}
|
||||
@ -540,7 +541,7 @@ void boot_client(char *str)
|
||||
|
||||
void show_nbr_cache(char *str)
|
||||
{
|
||||
print_nbr_cache();
|
||||
// print_nbr_cache();
|
||||
}
|
||||
|
||||
#ifdef DBG_IGNORE
|
||||
|
||||
@ -594,6 +594,9 @@ int32_t send(int s, void *msg, uint64_t len, int flags)
|
||||
|
||||
// Add thread PID
|
||||
current_int_tcp_socket->send_pid = thread_getpid();
|
||||
|
||||
recv_msg.type = UNDEFINED;
|
||||
|
||||
while (1)
|
||||
{
|
||||
current_tcp_socket->tcp_control.no_of_retry = 0;
|
||||
@ -605,9 +608,10 @@ int32_t send(int s, void *msg, uint64_t len, int flags)
|
||||
memcpy(&saved_tcp_context, ¤t_tcp_socket->tcp_control.tcp_context, sizeof(tcp_hc_context_t)-1);
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
while (recv_msg.type != TCP_ACK)
|
||||
{
|
||||
// Add packet data
|
||||
printf("Send Window: %u, MSS: %u\n", current_tcp_socket->tcp_control.send_wnd, current_tcp_socket->tcp_control.mss);
|
||||
if (current_tcp_socket->tcp_control.send_wnd > current_tcp_socket->tcp_control.mss)
|
||||
{
|
||||
// Window size > Maximum Segment Size
|
||||
@ -644,6 +648,7 @@ int32_t send(int s, void *msg, uint64_t len, int flags)
|
||||
current_tcp_socket->tcp_control.send_nxt += sent_bytes;
|
||||
current_tcp_socket->tcp_control.send_wnd -= sent_bytes;
|
||||
|
||||
printf("Sent bytes: %li\n", sent_bytes);
|
||||
if (send_tcp(current_int_tcp_socket, current_tcp_packet, temp_ipv6_header, 0, sent_bytes) != 1)
|
||||
{
|
||||
// Error while sending tcp data
|
||||
@ -653,17 +658,20 @@ int32_t send(int s, void *msg, uint64_t len, int flags)
|
||||
memcpy(¤t_tcp_socket->tcp_control.tcp_context, &saved_tcp_context, sizeof(tcp_hc_context_t));
|
||||
current_tcp_socket->tcp_control.tcp_context.hc_type = COMPRESSED_HEADER;
|
||||
#endif
|
||||
printf("Error while sending, returning to application thread!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Remember current time
|
||||
current_tcp_socket->tcp_control.last_packet_time = vtimer_now();
|
||||
|
||||
printf("Waiting for Message in send()!\n");
|
||||
net_msg_receive(&recv_msg);
|
||||
switch (recv_msg.type)
|
||||
{
|
||||
case TCP_ACK:
|
||||
{
|
||||
printf("Got ACK in send()!\n");
|
||||
tcp_hdr_t *tcp_header = ((tcp_hdr_t*)(recv_msg.content.ptr));
|
||||
if ((current_tcp_socket->tcp_control.send_nxt == tcp_header->ack_nr) && (total_sent_bytes == len))
|
||||
{
|
||||
@ -671,6 +679,7 @@ int32_t send(int s, void *msg, uint64_t len, int flags)
|
||||
current_tcp_socket->tcp_control.send_nxt = tcp_header->ack_nr;
|
||||
current_tcp_socket->tcp_control.send_wnd = tcp_header->window;
|
||||
// Got ACK for every sent byte
|
||||
printf("Everything sent, returning!\n");
|
||||
#ifdef TCP_HC
|
||||
current_tcp_socket->tcp_control.tcp_context.hc_type = COMPRESSED_HEADER;
|
||||
#endif
|
||||
@ -687,16 +696,18 @@ int32_t send(int s, void *msg, uint64_t len, int flags)
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: If window size > MSS, ACK was valid only for a few segments, handle retransmit of missing segments
|
||||
break;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// // TODO: If window size > MSS, ACK was valid only for a few segments, handle retransmit of missing segments
|
||||
// break;
|
||||
// }
|
||||
break;
|
||||
}
|
||||
case TCP_RETRY:
|
||||
{
|
||||
current_tcp_socket->tcp_control.send_nxt -= sent_bytes;
|
||||
current_tcp_socket->tcp_control.send_wnd += sent_bytes;
|
||||
total_sent_bytes -= sent_bytes;
|
||||
#ifdef TCP_HC
|
||||
memcpy(¤t_tcp_socket->tcp_control.tcp_context, &saved_tcp_context, sizeof(tcp_hc_context_t));
|
||||
current_tcp_socket->tcp_control.tcp_context.hc_type = MOSTLY_COMPRESSED_HEADER;
|
||||
|
||||
@ -123,10 +123,11 @@ void handle_tcp_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socke
|
||||
{
|
||||
if (check_tcp_consistency(&tcp_socket->socket_values, tcp_header) == PACKET_OK)
|
||||
{
|
||||
printf("Packet consistency OK!\n");
|
||||
m_send_tcp.content.ptr = (char*)tcp_header;
|
||||
net_msg_send(&m_send_tcp, tcp_socket->send_pid, 0, TCP_ACK);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
printf("NO WAY OF HANDLING THIS ACK!\n");
|
||||
}
|
||||
@ -275,6 +276,7 @@ void tcp_packet_handler (void)
|
||||
|
||||
ipv6_header = ((ipv6_hdr_t*)m_recv_ip.content.ptr);
|
||||
tcp_header = ((tcp_hdr_t*)(m_recv_ip.content.ptr + IPV6_HDR_LEN));
|
||||
printArrayRange(((uint8_t *)ipv6_header), IPV6_HDR_LEN+ipv6_header->length, "Incoming");
|
||||
#ifdef TCP_HC
|
||||
tcp_socket = decompress_tcp_packet(ipv6_header);
|
||||
#else
|
||||
@ -285,12 +287,14 @@ void tcp_packet_handler (void)
|
||||
|
||||
payload = (uint8_t*)(m_recv_ip.content.ptr + IPV6_HDR_LEN + tcp_header->dataOffset_reserved*4);
|
||||
|
||||
|
||||
print_tcp_status(INC_PACKET, ipv6_header, tcp_header, &tcp_socket->socket_values);
|
||||
|
||||
if ((chksum == 0xffff) && (tcp_socket != NULL))
|
||||
{
|
||||
#ifdef TCP_HC
|
||||
update_tcp_hc_context(true, tcp_socket, tcp_header);
|
||||
#endif
|
||||
// print_tcp_status(INC_PACKET, ipv6_header, tcp_header, &tcp_socket->socket_values);
|
||||
// Remove reserved bits from tcp flags field
|
||||
uint8_t tcp_flags = tcp_header->reserved_flags & REMOVE_RESERVED;
|
||||
|
||||
@ -346,8 +350,8 @@ void tcp_packet_handler (void)
|
||||
else
|
||||
{
|
||||
printf("Wrong checksum (%x) or no corresponding socket found!\n", chksum);
|
||||
printArrayRange(((uint8_t *)ipv6_header), IPV6_HDR_LEN+ipv6_header->length, "Incoming");
|
||||
print_tcp_status(INC_PACKET, ipv6_header, tcp_header, &tcp_socket->socket_values);
|
||||
// printArrayRange(((uint8_t *)ipv6_header), IPV6_HDR_LEN+ipv6_header->length, "Incoming");
|
||||
// print_tcp_status(INC_PACKET, ipv6_header, tcp_header, &tcp_socket->socket_values);
|
||||
}
|
||||
|
||||
msg_reply(&m_recv_ip, &m_send_ip);
|
||||
|
||||
@ -80,7 +80,7 @@ uint16_t compress_tcp_packet(socket_internal_t *current_socket, uint8_t *current
|
||||
// Update the tcp context fields
|
||||
update_tcp_hc_context(false, current_socket, (tcp_hdr_t *)(current_tcp_packet+3));
|
||||
|
||||
// print_tcp_status(OUT_PACKET, temp_ipv6_header, (tcp_hdr_t *)(current_tcp_packet+3), current_tcp_socket);
|
||||
print_tcp_status(OUT_PACKET, temp_ipv6_header, (tcp_hdr_t *)(current_tcp_packet+3), current_tcp_socket);
|
||||
|
||||
// Convert TCP packet to network byte order
|
||||
switch_tcp_packet_byte_order((tcp_hdr_t *)(current_tcp_packet+3));
|
||||
@ -275,7 +275,7 @@ uint16_t compress_tcp_packet(socket_internal_t *current_socket, uint8_t *current
|
||||
packet_size += payload_length;
|
||||
|
||||
update_tcp_hc_context(false, current_socket, &full_tcp_header);
|
||||
// print_tcp_status(OUT_PACKET, temp_ipv6_header, &full_tcp_header, current_tcp_socket);
|
||||
print_tcp_status(OUT_PACKET, temp_ipv6_header, &full_tcp_header, current_tcp_socket);
|
||||
return packet_size;
|
||||
}
|
||||
// Check for header compression type: MOSTLY_COMPRESSED_HEADER
|
||||
@ -369,8 +369,10 @@ uint16_t compress_tcp_packet(socket_internal_t *current_socket, uint8_t *current
|
||||
// Adding TCP payload length to TCP_HC header length
|
||||
packet_size += payload_length;
|
||||
|
||||
printf("TCP Payload length: %u\n", payload_length);
|
||||
|
||||
update_tcp_hc_context(false, current_socket, &full_tcp_header);
|
||||
// print_tcp_status(OUT_PACKET, temp_ipv6_header, &full_tcp_header, current_tcp_socket);
|
||||
print_tcp_status(OUT_PACKET, temp_ipv6_header, &full_tcp_header, current_tcp_socket);
|
||||
return packet_size;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#define TCP_SYN_INITIAL_TIMEOUT 6*SECONDS
|
||||
#define TCP_SYN_TIMEOUT 24*SECONDS
|
||||
#define TCP_MAX_SYN_RETRIES 3
|
||||
#define TCP_ACK_TIMEOUT 2*SECONDS // still static, should be calculated via RTT
|
||||
#define TCP_ACK_TIMEOUT 3*SECONDS // still static, should be calculated via RTT
|
||||
#define TCP_ACK_MAX_TIMEOUT 90*SECONDS
|
||||
|
||||
#define TCP_NOT_DEFINED 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user