Update README to explain how the client example works.
This commit is contained in:
parent
9ce66375c4
commit
ae89abe0a4
19
README.md
19
README.md
|
@ -151,7 +151,7 @@ sudo ./target/debug/tcpdump eth0
|
||||||
|
|
||||||
### examples/server.rs
|
### 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`.
|
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,
|
Fault injection is available through the `--drop-chance` and `--corrupt-chance` options,
|
||||||
with values in percents. A good starting value is 15%.
|
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
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ fn main() {
|
||||||
let tcp_tx_buffer = TcpSocketBuffer::new(vec![0; 128]);
|
let tcp_tx_buffer = TcpSocketBuffer::new(vec![0; 128]);
|
||||||
let tcp_socket = TcpSocket::new(tcp_rx_buffer, tcp_tx_buffer);
|
let tcp_socket = TcpSocket::new(tcp_rx_buffer, tcp_tx_buffer);
|
||||||
|
|
||||||
let hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x01]);
|
let hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x02]);
|
||||||
let protocol_addr = IpAddress::v4(192, 168, 69, 1);
|
let protocol_addr = IpAddress::v4(192, 168, 69, 2);
|
||||||
let mut iface = EthernetInterface::new(
|
let mut iface = EthernetInterface::new(
|
||||||
Box::new(device), Box::new(arp_cache) as Box<ArpCache>,
|
Box::new(device), Box::new(arp_cache) as Box<ArpCache>,
|
||||||
hardware_addr, [protocol_addr]);
|
hardware_addr, [protocol_addr]);
|
||||||
|
|
Loading…
Reference in New Issue