tcp: Whitespace cleanup, move a define to header and fix a typo.

This commit is contained in:
Michael Lotz 2015-08-02 21:18:02 +02:00
parent bed94ebc49
commit 8982293017
3 changed files with 25 additions and 26 deletions

View File

@ -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();
}

View File

@ -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)

View File

@ -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)