This project was built to deeply understand how TCP and TLS operate over a routed Layer-3 network.
Instead of using physical hardware, Linux network namespaces were used to simulate:
- Isolated network nodes (client, router, server)
- Two different IP subnets
- IP forwarding across a software router
- Real packet-level protocol behavior
The objective was to analyze:
- TCP 3-way handshake
- TLS 1.2 handshake workflow
- Certificate exchange in plaintext
- Encryption boundary after
ChangeCipherSpec - TTL decrement across a router (Layer-3 proof)
This project was later extended to include Mutual TLS (mTLS) to demonstrate two-way authentication, where both client and server verify each other's identity using certificates.
This project provides a hands-on, packet-level understanding of secure communication mechanisms used in modern distributed systems and zero-trust architectures.
| Namespace | Interface IP | Subnet |
|---|---|---|
| red (Client) | 10.0.1.2 | 10.0.1.0/24 |
| router | 10.0.1.1 / 10.0.2.1 | Two connected subnets |
| blue (Server) | 10.0.2.2 | 10.0.2.0/24 |
- Default gateway (red):
10.0.1.1 - Default gateway (blue):
10.0.2.1 - IP forwarding enabled in router namespace
- Ubuntu 22.04 (or compatible Linux system)
- iproute2
- OpenSSL
- tcpdump
- Wireshark (host machine)
./generate_certs.shsudo ./setup.shsudo ip netns exec red ping 10.0.2.2Expected observation:
- Successful ping replies
- TTL decreases from 64 β 63 (proof of router traversal)
sudo ./cleanup.shThis section demonstrates capturing and analyzing the TLS handshake at packet level in a clean, linear workflow.
sudo ip netns exec router tcpdump -i any -w tls_capture.pcapKeep this running.
(Open a new terminal)
sudo ip netns exec blue openssl s_server \
-accept 4433 \
-cert /certs/server.crt \
-key /certs/server.key \
-tls1_2Expected output:
ACCEPT
(Open another terminal)
sudo ip netns exec red openssl s_client \
-connect 10.0.2.2:4433 \
-tls1_2This initiates the TLS handshake.
Press:
Ctrl + Cin the tcpdump terminal.
Open the generated .pcap file in Wireshark.
tls
tcp.port == 4433
- TCP 3-way handshake occurs before TLS begins
- TLS handshake messages visible:
- ClientHello
- ServerHello
- Certificate
- ServerHelloDone
- ClientKeyExchange
- Encryption starts after
ChangeCipherSpec - Subsequent packets appear as:
TLS Application Data
This section demonstrates mutual authentication where both client and server verify each other using certificates.
sudo ip netns exec router tcpdump -i any -w mtls_capture.pcapKeep this running.
sudo ip netns exec blue openssl s_server \
-accept 4433 \
-cert /certs/server.crt \
-key /certs/server.key \
-CAfile /certs/ca.crt \
-Verify 1sudo ip netns exec red openssl s_client \
-connect 10.0.2.2:4433 \
-cert /certs/client.crt \
-key /certs/client.key \
-CAfile /certs/ca.crtExpected result:
- Handshake succeeds
- Client and server authenticate each other
sudo ip netns exec red openssl s_client \
-connect 10.0.2.2:4433 \
-CAfile /certs/ca.crtExpected result:
- Handshake fails
- Server rejects client
Press:
Ctrl + Cin the tcpdump terminal.
Open the generated .pcap file in Wireshark.
tls
tcp.port == 4433
- Server sends
Certificate Request - Client responds with its
Certificate - Client proves identity using
Certificate Verify - Mutual authentication is established
- Without client certificate β handshake failure
After ChangeCipherSpec, Wireshark shows:
TLS Application Data
This applies to both TLS and mTLS, indicating the transition from asymmetric to symmetric encryption.
Initial TTL: 64
Observed TTL: 63
| Feature | TLS | mTLS |
|---|---|---|
| Server Authentication | β | β |
| Client Authentication | β | β |
| Certificate Exchange | One-way | Two-way |
| Security Level | High | Very High |
| Use Cases | HTTPS | Zero Trust, Microservices |
network_namespaces/
β
βββ blue_namespace/
β βββ server.crt
β βββ server.key
β βββ ca.crt
β
βββ red_namespace/
β βββ client.crt
β βββ client.key
β βββ ca.crt
β
βββ ca/
β βββ ca.crt
β βββ ca.key
β
βββ diagrams/
β βββ topology.png
β
βββ screenshots/
β
βββ report/
β βββ report.pdf
β
βββ setup.sh
βββ cleanup.sh
βββ generate_certs.sh
βββ README.md
βββ tls_capture.pcap
βββ mtls_capture.pcap
Self-signed certificates are used for educational purposes only.
- Layer-3 routing using namespaces
- TCP handshake understanding
- TLS 1.2 internals
- Mutual TLS (mTLS) authentication
- Certificate Authority (CA) concepts
- Packet-level analysis with Wireshark
Samyak Gedam
National Institute of Technology Surathkal, Karnataka
Built as part of first task in mini-project course during my 2nd Semester.
