Skip to content
This repository was archived by the owner on Apr 21, 2023. It is now read-only.

Repository files navigation

ProtocolStack

CIcodecovGo Report CardGitHub release (latest SemVer)License: MIT
This repository is for learning network programming in Go and mainly aims to implement TCP/IP stack.

Overview

Supported Protocols

  • Ethernet
  • ARP
    • Request
    • Reply
  • IP
    • v4
    • v6
  • ICMP
    • Echo Request
    • Echo Reply
  • TCP
    • Receiving data less than MTU
    • Receiving data which exceeds MTU
    • Sending data
    • Flow Control
    • Retransmission
  • UDP

Requirements

  • OS: Linux
  • Go: 1.14.x or higher

Directory Structure

ProtocolStack/
├── .github
│ └── workflows .. Configurations for GitHub Actions
├── src
│ ├── binary ..... provides utilities for binary operation
│ ├── cli ........ cli command difinitions
│ ├── error ...... error definitions
│ ├── log ........ provides utilities for logging
│ ├── monitor .... provides monitoring features to watch services
│ ├── mw ......... provides a layer to connect network layer with ethernet layer
│ ├── net ........ protocol implementations
│ │ ├── arp .... arp
│ │ ├── eth .... ethernet protocol
│ │ ├── icmp ... icmp
│ │ ├── ip ..... ip
│ │ └── tcp .... tcp
│ ├── repo ....... provides repositories of various entities
│ ├── syscall .... provides system call wrappers
│ ├── test ....... test cases
│ ├── time ....... provides utilities for time operation
│ └── worker ..... provides various types used by worker
└── vagrant
└── provisioners provides provisioning scripts

Instructions

ProtocolStack needs a TAP device for its capability. For the reason, this project uses a virtual machine (Linux) to run the application.

1. Preparing for using the virtual machine

Software required is as follows:

Note: Mutagen synchronizes files between local system and virtual machine.

2. Controlling the virtual machine

vm.sh controls the virtual machine. The available commands are as follows:

  • start
  • stop
  • restart

You can perform the commands below:

> ./vm.sh start # Start the VM and create a Mutagen session.> ./vm.sh stop # Stop the VM and terminate the Mutagen session.> ./vm.sh restart # Restart the VM and recreate the Mutagen session.

Note: Remote debugging with GoLand

3. Compile

It is able to compile the application with make:

> make compile

4. Running application

Start as echo server

./bin/pstack server

Start as client

Send ICMP request:
./bin/pstack ping -c 192.0.2.1

Note: make supports the commands below:

  • build build project
  • clean clean up caches
  • compile resolve dependencies, and build the program
  • fmt run formatter
  • gen generate source code
  • lint run linters (golangci-lint)
  • resolve resolve dependencies
  • test run all tests

Examples

References

Notes

Memos

About

A simple implementation of the protocol stack.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages