Skip to content

muditbhalla/wirecraft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Wirecraft

An evolutionary engineering roadmap of custom application-layer network protocols, low-level socket architecture, and stream framing engines built from scratch in Python.

This repository serves as a progressive laboratory tracking the journey from raw Operating System network primitives up to full-featured custom application protocols.

Stage 1 — The TCP Handshake Boilerplate

Stage 1 establishes the structural virtual "pipe" between two completely isolated processes using the computer's kernel network stack.

Core Networking Primitives Used

  • socket.AF_INET: Instructs the OS to utilize the IPv4 addressing family framework.
  • socket.SOCK_STREAM: Configures the socket connection type to TCP. This guarantees in-order, error-checked delivery of a continuous stream of bytes.
  • Kernel Buffering: Demonstrates the handoff between Python's application memory space and the Operating System's low-level Send/Receive RAM buffers.

Execution and Verification

To verify the local network interface handshake, you must run the processes across two distinct terminal instances.

1. Start the Server Loop

The server binds to the local loopback interface and enters a blocking state, waiting for incoming synchronization flags.

python stage_1_handshake/my_server.py

2. Launch the Client

In a second terminal window, execute the client script to trigger the hardware-level handshake.

python stage_1_handshake/my_client.py

Expected Output Logs

Server Terminal: Will print "Socket successfully bound...", halt at listen(), and unblock, displaying "Handshake accepted" the moment the client runs.

Client Terminal: Will log "Attempting to connect..." followed immediately by a clean termination output confirming "Client successfully connected."


Key Academic Insights Implemented

The TCP Stream Reality: Discovered that TCP does not transfer data in neat, separated "boxes" or individual application messages. It treats data as a continuous, endless stream of bytes.

The Application Layer Mandate: Verified that while the OS kernel guarantees packet delivery and sequence ordering, it has no understanding of payload context. Defining text boundaries (framing) must be handled explicitly by application code in the stages ahead.

About

Building custom network protocols from the wire up. An evolutionary exploration of raw sockets, data framing strategies, and systems programming in Python.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages