Minimal Python implementations of TCP and TLS echo servers and clients. Designed for networking labs and packet capture analysis in Wireshark to demonstrate plaintext vs encrypted traffic.
Full lab walk-through on Medium.
-
TCP Echo Server → echoes data over plaintext TCP.
-
TCP Echo Client → sends sensitive-looking test data in plaintext.
-
TLS Echo Server → echoes data securely using a self-signed certificate.
-
TLS Echo Client → transmits the same data over TLS with optional key logging for Wireshark.
-
Logging of connection times and packet counts for visibility.
-
Show how plaintext traffic exposes sensitive data (credentials, API keys, etc.).
-
Contrast with TLS-encrypted traffic, where payloads are unreadable in Wireshark.
-
Educational use only — not production-ready.
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/CN=pc1.local"This will create cert.pem and key.pem for the TLS server. These two files must reside in the same folder as the tls_echo_server.py file.
TCP Server
python tcp_echo_server.pyTLS Server
python tls_echo_server.pyTCP (Plaintext) Client
python tcp_echo_client.pyTLS (encrypted) Client
python tls_echo_client.py-
Start a capture on the interface your client/server use.
-
Use filters to isolate traffic:
IP filter:
host 192.168.x.x and host 192.168.x.xTCP Echo Server/Client (port 5000):
tcp.port == 5000TLS Echo Server/Client (port 5443):
tcp.port == 5443- With the TCP client/server, payloads (login, SSN, API keys, etc.) are visible in plaintext.
- With the TLS client/server, payloads appear encrypted and unreadable.
- If you set tls_secrets.log, load it into Wireshark (Preferences → Protocols → TLS → (Pre)-Master-Secret log filename) to decrypt TLS sessions for lab analysis.
- For educational use only — do not use with real sensitive data.
- Blocking, single-threaded design (one client at a time).
- Production-ready systems require concurrency, proper error handling, and verified certificates.
This project is provided under the MIT License.