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)
| 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)
Create namespaces and routing:
sudo ./setup.shVerify connectivity:
sudo ip netns exec red ping 10.0.2.2Expected observation:
- Successful ping replies
- TTL decreases from 64 β 63 (proof of router traversal)
Cleanup environment:
sudo ./cleanup.shTLS 1.2 was explicitly enforced to observe the full handshake including ClientKeyExchange and ChangeCipherSpec.
sudo ip netns exec blue openssl s_server \
-key blue_namespace/key.pem \
-cert blue_namespace/cert.pem \
-accept 4433 \
-tls1_2sudo ip netns exec red openssl s_client \
-connect 10.0.2.2:4433 \
-tls1_2Capture traffic from router interface veth-r1:
Use tcpdump and open pcap in Wireshark.
sudo ip netns exec router tcpdump -i veth-r1 -w tls_capture.pcapLeave it running.
In new terminal:
sudo ip netns exec blue openssl s_server \
-key blue_namespace/key.pem \
-cert blue_namespace/cert.pem \
-accept 4433It should say:
ACCEPT
In another terminal:
sudo ip netns exec red openssl s_client -connect 10.0.2.2:4433Handshake will run.
Press:
Ctrl + Cin the tcpdump terminal
Open the .pcap file in Wireshark.
tcp.port == 4433
tls
ssl
- SYN
- SYN-ACK
- ACK
Connection successfully established before TLS begins.
- ClientHello
- ServerHello
- Certificate (plaintext transmission)
- ServerHelloDone
- ClientKeyExchange
- ChangeCipherSpec
- Finished
After ChangeCipherSpec, Wireshark displays:
TLS Application Data
This confirms symmetric session key activation and encrypted communication.
Initial TTL observed from sender: 64
TTL at receiver: 63
The decrement confirms:
- Packet passed through one router
- True Layer-3 forwarding occurred
- No direct Layer-2 bridging between namespaces
The following were validated in Wireshark:
- TCP sequence number progression
- TLS record encapsulation inside TCP segments
- Proper segmentation and acknowledgements
- No broadcast leakage between subnets
- Clear transition from asymmetric to symmetric encryption
- ClientHello β proposes cipher suites
- ServerHello β selects cipher suite
- Certificate β server proves identity
- ClientKeyExchange β pre-master secret encrypted using RSA
- Both sides derive symmetric session keys
- ChangeCipherSpec
- Finished
After this point, encrypted application data begins
TLS-Handshake-Linux-Namespaces/
β
βββ blue_namespace/
β βββ cert.pem
β βββ key.pem (ignored via .gitignore)
β
βββ diagrams/
β βββ topology.png
β
βββ screenshots/
β βββ 01_wireshark_pcap_opening.png
β βββ 02_initial_syn.png
β βββ 03_syn_ack.png
β βββ 04_final_ack.png
β βββ 05_client_hello.png
β βββ 06_server_hello.png
β βββ 07_sending_encrypted_data.png
β βββ 08_connection_termination.png
β
βββ report/
β βββ report.pdf
β
βββ setup.sh
βββ cleanup.sh
βββ README.md
βββ .gitignore
βββ tls_capture.pcap
Self-signed certificates were used strictly for academic experimentation.
In production environments:
- Certificates must be issued by trusted Certificate Authorities (CA)
- TLS 1.3 is strongly recommended
- Private keys must never be committed to version control
- Clear distinction between Layer-2 and Layer-3 communication
- TCP connection lifecycle understanding
- TLS 1.2 handshake internals
- Asymmetric β symmetric cryptographic transition
- Practical Wireshark packet inspection
- Realistic network simulation using Linux namespaces
Samyak Gedam
National Institute of Technology Surathkal, Karnataka.
Built as part of first task in mini-project course during my 2nd Semester.
