27 Commits

Author SHA1 Message Date
whitequark
49ed4ae5f3 Add a TCP data source endpoint to the server example. 2017-08-31 09:09:16 +00:00
whitequark
39464a53fc Compute soft deadline in poll() and use nonblocking sockets.
Before this commit, anything that touched RawSocket or TapInterface
worked partly by accident and partly because of a horrible crutch
that resulted in massive latencies as well as inevitable packet loss
every time an ARP request had to be issued. Also, there was no way
to use poll() other than by continuously calling it in a busy loop.

After this commit, poll() indicates when the earliest timer expires,
and so the caller can sleep until that moment (or until packets
arrive).

Note that there is a subtle problem remaining: every time poll()
is called, every socket with a pending outbound packet whose
IP address doesn't correspond to a MAC address will send a new
ARP request, resulting in potentially a whole lot of such requests.
ARP rate limiting is a separate topic though.
2017-08-29 19:47:11 +00:00
whitequark
7533542ba8 Fix warnings. 2017-07-31 07:59:01 +00:00
whitequark
6bc6cc7af7 Implement fmt::Write for TcpSocket. 2017-07-30 06:59:01 +00:00
whitequark
265e6f6cb7 Add UdpSocket::is_open, similar to TcpSocket::is_open in function.
Fixes #31.
2017-07-30 01:17:58 +00:00
whitequark
492fe3e4b1 Rework and test UDP sockets.
Before, errors such as packets not fitting into a buffer would have
resulted in panics, and errors such as unbound sockets were
simply ignored.
2017-07-27 22:30:01 +00:00
whitequark
53a3875452 Rework error handling in TcpSocket::connect. 2017-07-27 12:27:33 +00:00
whitequark
c799bfc398 Add --pcap option to all our examples.
Also, generally reorganize and clean up option handling.
2017-07-23 14:57:04 +00:00
whitequark
961b12ce93 Add a sinkhole to the server example. 2017-05-29 16:54:51 +00:00
whitequark
be9d0a202d Don't block forever in TapInterface.
Ideally Devices should be non-blocking, but that would be really
annoying to implement, so for now, to get the examples working,
I'm using this hack.
2017-03-05 05:30:03 +00:00
whitequark
a0f2c62ac9 Add a TCP client example. 2017-03-05 04:47:45 +00:00
whitequark
b88204c607 Factor out common code from examples. 2017-03-05 04:19:19 +00:00
TÖRÖK Attila
e436356ae7 examples/server: fix outdated/misleading variable name. 2017-01-26 16:59:12 +00:00
whitequark
b860505775 Try to get TCP state query methods into a saner state. 2017-01-14 09:13:25 +00:00
whitequark
830f9d9ad5 Update TcpSocket::{can,may}_{send,recv} APIs. 2017-01-14 06:59:58 +00:00
whitequark
8bff18cfdd Rework the user-facing error handling in UDP sockets. 2017-01-12 04:18:18 +00:00
whitequark
d5638f469f Return the amount of bytes sent from UdpSocket::send_slice. 2017-01-11 06:39:27 +00:00
whitequark
0ccd6205f7 Swap the data and endpoint in UdpSocket methods.
This is to match libstd.
2017-01-11 06:23:17 +00:00
whitequark
8f28e99a0c Make interfaces not own the sockets. 2017-01-11 05:25:54 +00:00
whitequark
70a09735c9 Make binding the UDP socket an explicit operation. 2017-01-11 04:44:42 +00:00
whitequark
019d03d758 Implement socket sets. 2017-01-11 04:05:41 +00:00
whitequark
839eae82a3 Use Managed/ManagedSlice for EthernetInterface. 2017-01-10 11:37:12 +00:00
whitequark
657658de87 Reorder type parameters of Interface. 2017-01-01 08:18:25 +00:00
whitequark
286c130dc5 Implement TCP retransmission. 2016-12-31 08:35:46 +00:00
whitequark
5860c365f5 Impement fault injection. 2016-12-31 01:05:29 +00:00
whitequark
553d640057 Implement the TCP TIME-WAIT state. 2016-12-28 05:33:12 +00:00
whitequark
05cadcf0e4 More sensible naming for examples. 2016-12-28 00:18:10 +00:00