17 Commits

Author SHA1 Message Date
whitequark
b1680368fe Rework the pretty printer to avoid superfluous trailing newlines. 2017-12-16 21:42:19 +00:00
Philipp Oppermann
198fe239f1 Redesign the phy::Device trait to avoid Drop impls. 2017-11-03 23:15:07 +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
2773fa72ec utils::Dispose → io::Sink. 2017-08-21 07:28:32 +00:00
whitequark
d73c2bdb81 Update fault injector so that rate limiting works without std. 2017-07-23 15:10:57 +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
37ba81f807 Fix an off-by-three-orders-of-magnitude error. 2017-07-23 12:03:56 +00:00
whitequark
8c339d8b7a Fix argument order in Tracer::new callbacks. 2017-07-23 12:01:53 +00:00
whitequark
3a656c1529 Inject the current timestamp into Device::{transmit,receive}.
Various parts of smoltcp require an arrow of time; a monotonically
increasing timestamp. Most obviously this is TCP sockets, but
the tracer and the pcap writer devices also benefit from having
timestamps. There are a few ways this could be implemented:
  1. using a static Cell, global for the entire smoltcp crate;
  2. using a static method on Device;
  3. using an instance method on Device;
  4. passing the current timestamp into *Interface::poll.

The first two options are undesirable because they create a notion
of global clock, and interfere e.g. with mocking.
The third option is undesirable because not all devices are
inherently tied to a particular clock, e.g. a loopback device isn't.

Therefore, the timestamp is injected into both sockets and devices
through the *Interface::poll method.
2017-07-23 09:48:14 +00:00
whitequark
7d54157e77 Add EthernetTracer, a specialization of Tracer for EthernetFrame.
This makes the loopback example much nicer, #[cfg]-wise.
2017-07-23 06:28:00 +00:00
whitequark
12f92be419 Use proper clock mocking in the loopback example. 2017-07-23 06:08:13 +00:00
whitequark
15ce667743 Add a bare-metal usage example. 2017-07-14 03:18:11 +00:00
whitequark
103fca2387 In examples, trace the packets being dropped by the fault injector. 2017-06-26 08:44:07 +00:00
whitequark
86c1cbad9b In examples, print packet dumps with timestamps, too.
This helps debugging retransmit issues.
2017-06-26 08:01:00 +00:00
whitequark
21900288cc Add packet shaping to the fault injector. 2017-05-29 10:53:30 +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