Skip to content

Commit

Permalink
Update README to explain how the client example works.
Browse files Browse the repository at this point in the history
whitequark committed Mar 5, 2017

Verified

This commit was signed with the committer’s verified signature.
makenowjust Hiroya Fujinami
1 parent d866cc7 commit ddba30e
Showing 2 changed files with 20 additions and 3 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -151,7 +151,7 @@ sudo ./target/debug/tcpdump eth0

### examples/server.rs

_examples/server.rs_ emulates a network host that can serve requests.
_examples/server.rs_ emulates a network host that can respond to requests.

The host is assigned the hardware address `02-00-00-00-00-01` and IPv4 address `192.168.69.1`.

@@ -176,6 +176,23 @@ The buffers are only 64 bytes long, for convenience of testing resource exhausti
Fault injection is available through the `--drop-chance` and `--corrupt-chance` options,
with values in percents. A good starting value is 15%.

### examples/client.rs

_examples/client.rs_ emulates a network host that can initiate requests.

The host is assigned the hardware address `02-00-00-00-00-02` and IPv4 address `192.168.69.2`.

Read its [source code](/examples/client.rs), then run it as:

```sh
cargo run --example client -- tap0 ADDRESS PORT
```

It connects to the given address (not a hostname) and port (e.g. `socat stdio tcp4-listen 1234`),
and will respond with reversed chunks of the input indefinitely.

Fault injection is available, as described above.

License
-------

4 changes: 2 additions & 2 deletions examples/client.rs
Original file line number Diff line number Diff line change
@@ -28,8 +28,8 @@ fn main() {
let tcp_tx_buffer = TcpSocketBuffer::new(vec![0; 128]);
let tcp_socket = TcpSocket::new(tcp_rx_buffer, tcp_tx_buffer);

let hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x01]);
let protocol_addr = IpAddress::v4(192, 168, 69, 1);
let hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x02]);
let protocol_addr = IpAddress::v4(192, 168, 69, 2);
let mut iface = EthernetInterface::new(
Box::new(device), Box::new(arp_cache) as Box<ArpCache>,
hardware_addr, [protocol_addr]);

0 comments on commit ddba30e

Please sign in to comment.