From 8982293017b132c73aff734fa8baa7afd261e125 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 2 Aug 2015 21:18:02 +0200 Subject: [PATCH] tcp: Whitespace cleanup, move a define to header and fix a typo. --- .../network/protocols/tcp/TCPEndpoint.cpp | 11 ++---- .../network/protocols/tcp/TCPEndpoint.h | 2 +- .../kernel/network/protocols/tcp/tcp.h | 38 ++++++++++--------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp index b4f52dd686..d941d6e973 100644 --- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp @@ -37,8 +37,8 @@ // References: -// - RFC 793 - Transmission Control Protocol -// - RFC 813 - Window and Acknowledgement Strategy in TCP +// - RFC 793 - Transmission Control Protocol +// - RFC 813 - Window and Acknowledgement Strategy in TCP // - RFC 1337 - TIME_WAIT Assassination Hazards in TCP // // Things this implementation currently doesn't implement: @@ -304,8 +304,6 @@ protected: # define T(x) #endif // TCP_TRACING -// Initial estimate for packet round trip time (RTT) -#define TCP_INITIAL_RTT 2000000 // constants for the fFlags field enum { @@ -1280,8 +1278,7 @@ TCPEndpoint::_DuplicateAcknowledge(tcp_segment_header &segment) if (fDuplicateAcknowledgeCount == 3) { _ResetSlowStart(); - fCongestionWindow = fSlowStartThreshold + 3 - * fSendMaxSegmentSize; + fCongestionWindow = fSlowStartThreshold + 3 * fSendMaxSegmentSize; fSendNext = segment.acknowledge; } else if (fDuplicateAcknowledgeCount > 3) fCongestionWindow += fSendMaxSegmentSize; @@ -2253,7 +2250,7 @@ TCPEndpoint::_Acknowledged(tcp_segment_header& segment) fCongestionWindow += increment; } - // if there is data left to be send, send it now + // if there is data left to be sent, send it now if (fSendQueue.Used() > 0) _SendQueued(); } diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h index c49bf47533..1ff167b5bb 100644 --- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h +++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h @@ -150,7 +150,7 @@ private: tcp_sequence fInitialSendSequence; uint32 fDuplicateAcknowledgeCount; - net_route *fRoute; + net_route *fRoute; // TODO: don't use a net_route, but a net_route_info!!! // (the latter will automatically adapt to routing changes) diff --git a/src/add-ons/kernel/network/protocols/tcp/tcp.h b/src/add-ons/kernel/network/protocols/tcp/tcp.h index 47fe3f0560..6f30ec2943 100644 --- a/src/add-ons/kernel/network/protocols/tcp/tcp.h +++ b/src/add-ons/kernel/network/protocols/tcp/tcp.h @@ -43,30 +43,30 @@ enum tcp_state { }; struct tcp_header { - uint16 source_port; - uint16 destination_port; - uint32 sequence; - uint32 acknowledge; + uint16 source_port; + uint16 destination_port; + uint32 sequence; + uint32 acknowledge; struct { #if B_HOST_IS_LENDIAN == 1 - uint8 reserved : 4; - uint8 header_length : 4; + uint8 reserved : 4; + uint8 header_length : 4; #else - uint8 header_length : 4; - uint8 reserved : 4; + uint8 header_length : 4; + uint8 reserved : 4; #endif }; - uint8 flags; - uint16 advertised_window; - uint16 checksum; - uint16 urgent_offset; + uint8 flags; + uint16 advertised_window; + uint16 checksum; + uint16 urgent_offset; - uint32 HeaderLength() const { return (uint32)header_length << 2; } - uint32 Sequence() const { return ntohl(sequence); } - uint32 Acknowledge() const { return ntohl(acknowledge); } - uint16 AdvertisedWindow() const { return ntohs(advertised_window); } - uint16 Checksum() const { return ntohs(checksum); } - uint16 UrgentOffset() const { return ntohs(urgent_offset); } + uint32 HeaderLength() const { return (uint32)header_length << 2; } + uint32 Sequence() const { return ntohl(sequence); } + uint32 Acknowledge() const { return ntohl(acknowledge); } + uint16 AdvertisedWindow() const { return ntohs(advertised_window); } + uint16 Checksum() const { return ntohs(checksum); } + uint16 UrgentOffset() const { return ntohs(urgent_offset); } } _PACKED; class tcp_sequence { @@ -187,6 +187,8 @@ operator==(tcp_sequence a, tcp_sequence b) #define TCP_MAX_SEGMENT_LIFETIME 60000000 // 60 secs #define TCP_PERSIST_TIMEOUT 1000000 // 1 sec +// Initial estimate for packet round trip time (RTT) +#define TCP_INITIAL_RTT 2000000 // 2 secs // Minimum retransmit timeout (consider delayed ack) #define TCP_MIN_RETRANSMIT_TIMEOUT 200000 // 200 msecs // Maximum retransmit timeout (per RFC6298)