MSPFrom Scratch: The Story and Structure of MSP, My Custom Python ProtocolMSP

table of contents

MSP: Building a Custom Communication Protocol with Python

Have you ever felt that existing communication tools, while powerful, can feel like a black box?
That very frustration led me to create my own protocol—something transparent, educational, and entirely mine.

This article introduces MSP (Minokamo Secure Protocol):
Why I built it, how it works, and how you can try it yourself.

MSP Protocol Educational Value Who Benefits and Why – Learning Through Custom Protocol Development 🔧 Communication Protocol Learners Why it helps: • Learn how to build custom structures on top of TCP • Understand packet design, headers, and data flow • See real implementation of sync bytes, CRC, and framing 🧠 Retro PC / Virtual OS Experimenters Why it helps: • Perfect for COM port and serial communication experiments • Educational material for understanding serial protocols • Bridge modern Python with classic serial interfaces 📚 Students & Educational Settings Why it helps: • Experience the joy of creating “your own protocol” • Hands-on learning with immediate visual results • Builds confidence in network programming concepts 🧪 Security Beginners Why it helps: • Step-by-step evolution: No encryption → AES encryption • Learn security concepts progressively and practically • See immediate impact of adding encryption layers 📦 Scientific Equipment Developers Why it helps: • Design simple communication without TCP/IP stack dependency • Perfect for embedded systems and experimental setups • Minimal overhead, maximum control over data flow The Learning Journey with MSP Step 1 Basic MSP Understand packet structure & flow Step 2 Add COM Extend to serial communication Step 3 GUI Tool Build user-friendly interface Step 4 Encryption Add AES security layer Step 5 File Transfer Implement advanced features 🎯 Master Goal Complete understanding of custom protocol development from basic to advanced security 💡 Key Benefit: Learn by Building, Not Just Reading – Hands-on Protocol Development Experience

Why Create a Custom Protocol?

While tools like HTTP and WebSocket are fantastic, they’re also too complete.
There’s little room left to explore or customize their internals.

I wanted to go back to basics.
To build something minimal, transparent, and capable of expressing ideas that traditional protocols didn’t quite support.

MSP is built on TCP and intentionally keeps its packet structure simple—making it ideal for learning and experimentation.

MSP Packet Structure

Here’s how a typical MSP packet is organized:

  • SYNC (2 bytes): Start indicator (0xAA55)
  • LENGTH (2 bytes): Total length of the packet (header + payload)
  • VERSION (1 byte): Protocol version
  • TYPE (1 byte): Message type (e.g., data or acknowledgment)
  • PAYLOAD (variable): UTF-8 encoded message body
  • CRC (1 byte): A simple checksum (sum of payload bytes % 256)

This layout offers two advantages:

  • If transmission is disrupted, SYNC helps realign the stream.
  • CRC provides basic corruption detection.
MSP Packet Structure SYNC (2B) Length (2B) VER (1B) Type (1B) Payload (Variable) CRC (1B) • SYNC: Fixed value 0xAA55 • Length: Total packet length (payload length + 7) • VER: Protocol version (currently 1) • Type: 0x10 (DATA) or 0x11 (ACK) • CRC: Simple checksum of payload (sum mod 256) MSP Communication Flow Client Server Data Packet (TYPE_DATA) Acknowledgment (TYPE_ACK) Key Components of msp.py MSP Protocol Implementation MSPClient MSPServer

Client-Server Communication Flow

Communication in MSP is straightforward:

  • The client sends a message
  • The server replies with an ACK (acknowledgment packet)

Under the hood, this is handled via Python sockets and binary data.
Two core functions take care of the packet workflow:

  • build_packet() – constructs a packet on the sender side
  • parse_packet() – interprets received packets on the receiver side
MSP Protocol Detailed Flow Client Processing Initialize Connect to Server Create Data Packet build_packet(TYPE_DATA, message) Send Packet Receive & Parse Response parse_packet(response) Terminate Server Processing Initialize Bind Socket & Listen Wait for Connection Accept Client Connection Receive & Parse Packet parse_packet(data) Create & Send ACK Packet build_packet(TYPE_ACK, ‘OK’) Send Data ACK Response Protocol Constants: • SYNC: 0xAA55 • VERSION: 1 • TYPE_DATA: 0x10 • TYPE_ACK: 0x11 • Default Port: 9009

Getting Started with MSP

MSP is lightweight and dependency-free.
All functionality is contained in a single file: msp.py.

To start the server:

python msp.py --mode server --host 127.0.0.1 --port 9009

To send a message from the client:

python msp.py --mode client --host 127.0.0.1 --port 9009 --message "Hello MSP"

If everything works, you’ll receive an ACK response—confirming successful transmission.

Testing Across Machines (Linux to Windows)

I also tested MSP between different OS environments.

On a Linux client:

python3 msp.py --mode client --host 192.168.0.15 --port 9009 --message "Hello MSP"

(Replace 192.168.0.15 with the actual IP of your Windows server)

On the Windows server:

python msp.py --mode server --host 0.0.0.0 --port 9009

Note: Don’t forget to configure the Windows Firewall to allow incoming TCP traffic on port 9009.
Add a rule for TCP, local port 9009, and allow connection under “Private” or “Domain” profiles.

A typical rule configuration would be:

  • Protocol type: TCP
  • Local port: 9009
  • Action: Allow the connection
  • Profile: Private or Domain (adjust based on your network)

What’s Next? Future Ideas for MSP

Since MSP is custom-built, the possibilities are wide open.
Here’s what I plan for upcoming versions:

  • Add AES encryption for secure communication (planned for v0.2)
  • Build a Tkinter GUI to make testing more visual
  • Support COM ports for retro computing and FreeDOS compatibility
  • Extend into file transfer and remote control capabilities

See the Code and Demo

You can find the full source code and a demonstration video here:

  • GitHub Repository:

Final Thoughts

MSP wasn’t built for enterprise.
It was built for understanding, for learning, and for the pure joy of creating something from scratch.

Designing your own protocol gives shape to the invisible.
And that, I believe, is the essence of programming.

I hope MSP inspires someone else to explore, learn, or create.

If you like this article, please
Follow !

Please share if you like it!
table of contents