Commit Graph

194 Commits

Author SHA1 Message Date
jhwgh1968 e867832214 Minimal Implementation of TCP Selective Acknowledgement
Closes: #266
Approved by: whitequark
2019-01-01 13:51:02 +08:00
jhwgh1968 88016e675f Fully implement TCP Window Scaling
Closes: #253
Approved by: whitequark
2018-08-20 06:57:44 +08:00
jhwgh1968 1745df2110 Implement TCP Window Scaling, Phase 1 (Issue #106)
Closes: #232
Approved by: whitequark
2018-06-25 03:08:44 +08:00
Kai Lüke b23df24a2a Only trigger fast retransmit for data to send
This fixes entering a loop when both endpoints
are stuck in retransmission.

https://github.com/m-labs/smoltcp/issues/224

Closes: #233
Approved by: whitequark
2018-06-18 22:19:42 +08:00
Kai Lüke 272baab3ef Reset retrasmission delay after fast retrasmit
Closes: #233
Approved by: whitequark
2018-06-18 22:19:42 +08:00
Ole Martin Ruud 022cad8b11 Fix implementation of fast retransmit (TcpSocket)
Improve detection of duplicate ACKs by checking that the segment does
not contain data.

Move implementation from the 'reject unacceptable acknowledgements'
to later in the process function, because a duplicate ACK is not an
'unacceptable' acknowledgement but rather a condition to update state.

Implement more tests to verify the operation of the fast retransmit
implementation.

Related issue: #224

Closes: #225
Approved by: whitequark
2018-06-10 02:53:35 +08:00
Astro e5a3de210c Optimize RingBuffer::enqueue_many_with to an empty buffer.
This optimization makes sure that enqueueing to an empty ring buffer
would never wrap around, in turn ensuring that enqueueing to an empty
packet buffer would never use more than one metadata entry.
Right now, pushing buffer-sized packets into a packet buffer requires
at least two metadata entries, which is surprising and wasteful.
2018-05-24 22:00:00 +00:00
Ole Martin Ruud f501198a68 Implement fast retransmit for TcpSocket
Implement a simple way to discover and respond to three duplicate ACKs
from the reciver of the data. This leads to a fast retransmit of the
last unacknowledged seqment. This is feature is described in [RFC 5681].

Closes: #104

Closes: #214
Approved by: whitequark
2018-05-18 00:40:47 +08:00
Ole Martin Ruud 0c59e3f5f9 Implement new type for `poll_at`
Change return-type for `poll_at` for sockets to be a `PollAt` instead of
the former `Option<Instant>`.

Closes: #216
Approved by: whitequark
2018-05-17 06:17:47 +08:00
whitequark ca743cba24 Fix format strings using time to not include extraneous ms suffix. 2018-05-15 14:49:53 +00:00
Kai Lüke fada9d4e27 Update remote_last_win for all ACKs
Only ACKs generated by `dispatch` were updating
`remote_last_win` but not the ACKs generated by
`process`, failing to keep track of the last
announced receive window. This left
`window_to_update` to return false in `dispatch`
after the RX buffer was emptied, thus not announcing
that the receive window is not zero anymore.

The change updates `remote_last_win` for immediate
ACKs generated by `process`.

Closes: #200
Approved by: whitequark
2018-05-08 01:27:28 +08:00
Dan Robertson 9747733dd7 Use time types in socket
Use the time types (Instant and Duration) in the socket modules instead
of a simple u64.

Closes: #141
Approved by: whitequark
2018-02-16 10:44:03 +08:00
Philipp Oppermann 6b3f103c05 Return specific sockets from `new` functions instead of `Socket`.
* Add Into<Socket> implementations for sockets
* Make SocketSet::add generic over Into<Socket>
2018-01-28 14:36:23 +00:00
whitequark f494200c8c Disregard TCP FIN flag if it arrives in a segment not at window start.
Fixes #111.
2018-01-05 21:06:20 +00:00
Dan Robertson b653a6e421 Fix documentation warnings.
- There are several warnings that are thrown when running `cargo doc`. Fix
  these warnings.
- Convert all module documentation to use /*! for consistency.
2018-01-05 19:38:23 +00:00
Dan Robertson 439e0a2cc1 Add the proto-ipv4 feature. 2017-12-24 13:28:59 +00:00
whitequark 436f4ef624 Correctly handle retransmission of lost-received-lost TCP segments.
Thanks @pothos for initial analysis of the issue.
2017-12-22 19:31:04 +00:00
whitequark ae17151f2a Fix a few documentation issues. NFC. 2017-12-22 13:13:43 +00:00
whitequark a45b3d9eab TcpSocket::recv_impl should have never been public, oops. 2017-12-22 13:11:11 +00:00
whitequark fec3bb32eb Make the log crate properly optional. 2017-12-22 09:57:38 +00:00
whitequark bd40265d3a Use a more specific log message for keep-alive or probe TCP packets. 2017-12-21 10:39:54 +00:00
Dan Robertson c5c2264cdc Use hop limit instead of ttl
Use hop limit instead of ttl for method and member names.
2017-12-18 13:47:34 +00:00
whitequark 278bb4b2c9 Trace the TCP socket acknowledging incoming segment. 2017-12-18 12:47:42 +00:00
whitequark c19bd1da7c Make elaborated reasons for sending a TCP packet more precise. 2017-12-15 06:31:50 +00:00
whitequark 1c7ce85004 Log an elaborated reason for sending a TCP packet.
Otherwise, it is hard to debug e.g. ACK loops.
2017-12-15 05:24:17 +00:00
whitequark 6c83936872 Extract socket handle into a new SocketMeta structure.
This paves way for adding more metadata apart from handles,
such as caches and so on.

This commit also removes SocketHandle::EMPTY in favor of
SocketHandle::default() since they are functionally identical.
2017-11-22 03:50:09 +00:00
Kai Lüke 2a52234d53 Don't panic on TCP sequence number wrapping in debug mode. 2017-11-13 18:03:36 +00:00
Kai Lüke 3db035bbac Preserve retransmission timer for Dup-ACKs
Duplicate ACKs should not replace the retransmission timer,
but if not in retransmission, still set the keep-alive timer
as normal ACKs do.
2017-11-13 06:26:26 +00:00
Dan Robertson adb5014780 Add ICMP sockets
- Add support for ICMP sockets
 - Add tests for ICMP sockets
 - Rename proto-<type> features to socket-<type>
 - Update documentation
2017-11-09 00:08:24 +00:00
whitequark fe6b04a29a Rework TcpSocket::{send,recv} to remove need for precomputing size.
Now, these functions give you the largest contiguous slice they can
grab, and you return however much you took from it.
2017-10-31 19:24:54 +00:00
whitequark 1cd3625bf4 Small adjustments to TTL code; style, docs, and tests. NFCI. 2017-10-24 23:12:55 +00:00
Dan Robertson eef65d2676 Implement set_ttl for Tcp and Udp sockets
- Add the ttl member to the IpRepr
 - Add the ttl member along with setters and getters to the tcp and udp
   socket types
 - Add unit tests for the new set_ttl parameter
 - Update usage of IpRepr to include the ttl value
2017-10-24 23:02:18 +00:00
whitequark 52600cd521 Replace "socket debug identifiers" with just socket handles.
This is basically a rename that now calls an apple an apple,
except user code can no longer change it. It's not obvious if
user code getting the socket handle from the socket is very useful,
but it's not harmful either, so why not.
2017-10-05 03:02:41 +00:00
Egor Karavaev 5be76b8dc1 Add support for IPv4 default gateway. 2017-10-03 15:17:29 +00:00
Steffen Butzer f9093d15aa phy: introduce hardware based checksum settings, rename DeviceLimits
this contains a rename of occurrences of
DeviceLimits -> DeviceCapabilities.
2017-10-02 21:40:08 +00:00
whitequark 9c3534e452 A few cosmetic changes to TCP socket trace messages.
No functional change.
2017-09-24 13:39:23 +00:00
whitequark 32d720831a Completely redo the logic of TCP socket polling.
The previous implementation made no sense. It is obvious that
poll_at() should use the same mechanisms to decide whether dispatch()
should be called as dispatch() itself uses to decide whether to send
anything.

This fixes numerous busy looping issues that arise if the return
value of poll() is used for waiting.
2017-09-24 13:20:56 +00:00
whitequark 96b284a30f Fix two issues that may cause TCP sockets to be polled too late.
1. Apart from non-empty transmit buffer, a state which transmits
   a FIN flag should also be considerd. Otherwise, closing a socket
   with an empty transmit buffer may retransmit the FIN flag forever.
2. Timeout poll requests should only be overridden by timer poll
   requests when the latter is earlier.
2017-09-24 11:04:55 +00:00
whitequark 8db752eb7a Fix a typo in documentation. 2017-09-24 08:23:46 +00:00
whitequark 711c05f7b1 Make TCP more RFC 5681 compliant wrt immediate ACKs. 2017-09-22 18:57:47 +00:00
whitequark a5a9bb44c9 Clarify inline TCP documentation. 2017-09-22 18:40:23 +00:00
whitequark b90cee43bb Fix a warning. 2017-09-22 17:38:58 +00:00
whitequark 8166037a91 Handle buffer wraparound in TCP reassembly code. 2017-09-22 17:10:51 +00:00
whitequark 5aae15aaba Fix an issue where TCP packets would have zero IP payload length. 2017-09-22 10:14:26 +00:00
whitequark a9d6a9b7b8 Fix a few warnings. 2017-09-22 10:06:40 +00:00
whitequark 7a2cd7842d Implement reassembly of out-of-order TCP segments. 2017-09-22 10:06:40 +00:00
whitequark b6e4e23868 Clean up PSH flag handling. 2017-09-22 08:15:29 +00:00
whitequark d7da46fd3b Do not clear remote_last_ts in TcpSocket::set_timeout().
After this change, if an 1s timeout is set on a socket that received
no packet for 2s, it will be instantly aborted, which seems
more reasonable. Also, this makes the `self.remote_last_ts.is_none()`
branch in TcpSocket::dispatch() actually behave as described.
2017-09-22 06:16:58 +00:00
whitequark f23bfe2014 Clean up and document TCP MSS calculations. 2017-09-22 06:02:03 +00:00
whitequark 9281733209 Implement TCP timeouts. 2017-09-18 11:05:40 +00:00