George Barnett 7dc32169b2 Raise minimum Swift version to 5.2 (#1106) 4 年之前
..
Sources cf9649a4b4 Add .swiftformat and apply a lint check in CI (#929) 5 年之前
.gitignore 5397772adf Add a client debugging initializer and PCAP debugging example (#908) 5 年之前
Package.swift 7dc32169b2 Raise minimum Swift version to 5.2 (#1106) 4 年之前
README.md 5397772adf Add a client debugging initializer and PCAP debugging example (#908) 5 年之前

README.md

PCAP Debugging Example

This example demonstrates how to use the NIOWritePCAPHandler from NIOExtras with gRPC Swift.

The example configures a client to use the NIOWritePCAPHandler with a file sink so that all network traffic captured by the handler is written to a .pcap file. The client makes a single bidirectional streaming RPC to an Echo server provided by gRPC Swift.

The captured network traffic can be inspected by opening the .pcap with tools like Wireshark or tcpdump.

Running the Example

The example relies on the Echo server from the gRPC Swift repository. To start the server, from the root of the gRPC repository run:

$ swift run Echo server 0

Note the port printed by the server. In a separate shell, in this directory run:

$ swift run PCAPExample localhost <SERVER_PORT>

Some logs should be emitted similar to below, including the path of the .pcap file:

2020-07-24T10:48:50+0100 info gRPC PCAP Demo : Creating fileSink for path './channel-ObjectIdentifier(0x00007f8a25604c40).pcap'
2020-07-24T10:48:50+0100 info gRPC PCAP Demo : ✅ Successfully created fileSink for path './channel-ObjectIdentifier(0x00007f8a25604c40).pcap'
...
2020-07-24T10:48:50+0100 info gRPC PCAP Demo : ✅ RPC completed successfully
...
2020-07-24T10:48:50+0100 info gRPC PCAP Demo : Done!

The .pcap file can be opened with either: Wireshark or tcpdump -r <PCAP_FILE>.