Browse Source

Update README to explain how the client example works.

whitequark 8 years ago
parent
commit
ddba30e9cf
2 changed files with 20 additions and 3 deletions
  1. 18 1
      README.md
  2. 2 2
      examples/client.rs

+ 18 - 1
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
 -------
 

+ 2 - 2
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<ArpCache>,
         hardware_addr, [protocol_addr]);