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
whitequark
fe80bca19d
Implement TCP keep-alive.
2017-09-16 10:54:59 +00:00
whitequark
be0dcb145c
Fix warnings.
2017-09-15 06:05:41 +00:00
whitequark
e8788be3a0
RingBuffer::{empty,full}→is_{empty,full}.
...
Query methods in Rust conventionally start with the "is" prefix.
2017-09-08 23:23:40 +00:00
whitequark
5ffce2c1a6
Remove Error::Rejected.
...
This wasn't an actual error, just a poorly designed communication
mechanism between sockets and whatever lies on the layer below them.
2017-09-08 00:59:46 +00:00
Egor Karavaev
8404fe908c
Factor out TcpSocket::accepts.
2017-09-08 00:57:42 +00:00
whitequark
9b242c7099
Send a challenge ACK in response to an unacceptable TCP ACK.
2017-09-08 00:11:44 +00:00
whitequark
1102bd94e7
Refactor the "random access" ring buffer interface.
2017-09-07 23:47:42 +00:00
whitequark
5dc0353b2a
Refactor the "continuous" ring buffer interface.
...
This also makes TcpSocket::{send,recv}_slice slightly more efficient
in case when the slice wraps around the corresponding buffer,
halving the necessary amount of calls.
2017-09-07 21:17:31 +00:00
whitequark
a9719f4a13
Merge the TCP ring buffer and generic ring buffer.
...
This adds a few methods to RingBuffer that don't quite fit into
its interface (the slice ones), but we can fix that later.
2017-09-07 00:09:34 +00:00
whitequark
27a23ed3c3
Don't instantly ACK every received TCP segment.
...
This is prohibited by RFC 1122. Instead, aggregate them, and respond
once in the egress function.
However, still instantly send challenge ACKs to trigger fast
retransmit.
2017-09-05 23:23:50 +00:00
whitequark
a71542b2f2
Allow querying the size of the TCP transmit and receive buffers.
...
This may be useful to e.g. ensure the complete transmit buffer
is flushed before proceeding.
2017-08-31 13:22:20 +00:00