diff --git a/README.md b/README.md index 7ff00f2..3f8fc49 100644 --- a/README.md +++ b/README.md @@ -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 ------- diff --git a/examples/client.rs b/examples/client.rs index b478421..0c86536 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -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, hardware_addr, [protocol_addr]);