All Projects → brewlin → net-protocol

brewlin / net-protocol

Licence: Apache-2.0 license
golang模拟内核协议栈 实现链路层、网络层、传输层、应用层 用户态协议栈 ,基于虚拟网卡TUN/TAP

Programming Languages

go
31211 projects - #10 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to net-protocol

Mirage Tcpip
TCP/IP networking stack in pure OCaml, using the Mirage platform libraries. Includes IPv4/6, ICMP, and UDP/TCP support.
Stars: ✭ 277 (+114.73%)
Mutual labels:  tcp, udp, icmp, ipv4, arp
Packetsender
Network utility for sending / receiving TCP, UDP, SSL
Stars: ✭ 1,349 (+945.74%)
Mutual labels:  tcp, ipv6, udp, ipv4
Pytcp
PyTCP is an attempt to create fully functional TCP/IP stack in Python. It supports TCP stream based transport with reliable packet delivery based on sliding window mechanism and basic congestion control. It also supports IPv6/ICMPv6 protocols with SLAAC address configuration. It operates as user space program attached to Linux TAP interface. As of today stack is able to send and receive traffic over Internet using IPv4 and IPv6 default gateways for routing. Since goal of this project is purely educational (at least at this point) the clarity of code is preferred over its efficiency. For the same reason security features are not being implemented just yet unless they are integral part of TCP/IP suite protocols specification.
Stars: ✭ 65 (-49.61%)
Mutual labels:  tcp, udp, icmp, arp
Netlink
Socket and Networking Library using msgpack.org[C++11]
Stars: ✭ 197 (+52.71%)
Mutual labels:  tcp, ipv6, udp, ipv4
masscanned
Let's be scanned. A low-interaction honeypot focused on network scanners and bots. It integrates very well with IVRE to build a self-hosted alternative to GreyNoise.
Stars: ✭ 50 (-61.24%)
Mutual labels:  tcp, ipv6, udp, ipv4
sx
🖖 Fast, modern, easy-to-use network scanner
Stars: ✭ 1,267 (+882.17%)
Mutual labels:  udp, icmp, ipv4, arp
captcp
A open source program for TCP analysis of PCAP files
Stars: ✭ 110 (-14.73%)
Mutual labels:  tcp, ipv6, udp, ipv4
Enet Csharp
Reliable UDP networking library
Stars: ✭ 464 (+259.69%)
Mutual labels:  ipv6, udp, protocol, ipv4
Pypacker
📦 The fastest and simplest packet manipulation lib for Python
Stars: ✭ 216 (+67.44%)
Mutual labels:  tcp, udp, protocol, arp
Pingtunnel
ping tunnel is a tool that advertises tcp/udp/socks5 traffic as icmp traffic for forwarding.
Stars: ✭ 1,904 (+1375.97%)
Mutual labels:  tcp, udp, icmp
Hazel Networking
Hazel Networking is a low level networking library for C# providing connection orientated, message based communication via TCP, UDP and RUDP.
Stars: ✭ 194 (+50.39%)
Mutual labels:  tcp, udp, protocol
Computer Networking
Free resources for a self-taught education in Computer Networking
Stars: ✭ 201 (+55.81%)
Mutual labels:  tcp, udp, arp
Asio2
Header only c++ network library, based on asio,support tcp,udp,http,websocket,rpc,ssl,icmp,serial_port.
Stars: ✭ 202 (+56.59%)
Mutual labels:  tcp, udp, icmp
node-drivers
Industrial protocol drivers in node.js
Stars: ✭ 20 (-84.5%)
Mutual labels:  tcp, udp, protocol
Fi6s
IPv6 network scanner designed to be fast
Stars: ✭ 116 (-10.08%)
Mutual labels:  tcp, ipv6, udp
Mts
Project of Multi-protocol Test Tool opensourced by Ericsson
Stars: ✭ 34 (-73.64%)
Mutual labels:  tcp, udp, protocol
Hev Socks5 Server
A simple, lightweight socks5 server for Unix (Linux/BSD/macOS)
Stars: ✭ 33 (-74.42%)
Mutual labels:  tcp, ipv6, ipv4
Pjon
PJON (Padded Jittering Operative Network) is an experimental, arduino-compatible, multi-master, multi-media network protocol.
Stars: ✭ 2,615 (+1927.13%)
Mutual labels:  tcp, udp, protocol
Blinksocks
A framework for building composable proxy protocol stack.
Stars: ✭ 587 (+355.04%)
Mutual labels:  tcp, udp, protocol
Libnet
A portable framework for low-level network packet construction
Stars: ✭ 640 (+396.12%)
Mutual labels:  tcp, udp, arp

net-protocol

GitHub last commit GitHub GitHub code size in bytes GitHub release (latest by date)

基于go 实现链路层、网络层、传输层、应用层 网络协议栈 ,使用虚拟网卡实现 docs:http://wiki.brewlin.com/wiki/net-protocol/index/

@demo && test

相关demo以及协议测试在cmd目录下,cd ./cmd*

docker

> docker run -d --device /dev/net/tun:/dev/net/tun --privileged brewlin/net-protocol
> docker exec -it containerid /bin/bash
> go run cmd/transport/udp/server/main.go
> go run cmd/transport/udp/net_client.go

@application 应用层

@transport 传输层

@network 网络层

@link 链路层

@物理层

  • tun tap 虚拟网卡的实现

@客户端

发起客户端请求

协议相关构体

具体细节文档:http://wiki.brewlin.com/wiki/net-protocol/index/

1.应用层相关协议

应用层暂时只实现了httpwebsocketdns协议。都基于tcp、udp等进行二次封装

http protocol:

http 协议报文
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Origin: http://example.com
Sec-WebSocket-Protcol: chat, superchat
Sec-WebSocket-Version: 13

websocket protocol:

  websocket 数据帧报文

0               1               2               3               4
0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
+-+-+-+-+-------+-+-------------+-------------------------------+
|F|R|R|R| opcode|M| Payload len |    Extended payload length    |
|I|S|S|S|  (4)  |A|     (7)     |             (16/64)           |
|N|V|V|V|       |S|             |   (if payload len==126/127)   |
| |1|2|3|       |K|             |                               |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
|     Extended payload length continued, if payload len == 127  |
+ - - - - - - - - - - - - - - - +-------------------------------+
|                               |Masking-key, if MASK set to 1  |
+-------------------------------+-------------------------------+
| Masking-key (continued)       |          Payload Data         |
+-------------------------------- - - - - - - - - - - - - - - - +
:                     Payload Data continued ...                :
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
|                     Payload Data continued ...                |
+---------------------------------------------------------------+

2.传输层相关协议

传输层实现了updtcp、等协议,实现了主要接口

tcp protocol:

		     tcp 首部协议报文
0               1               2               3               4
0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Acknowledgment Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data |           |U|A|P|R|S|F|                               |
| Offset| Reserved  |R|C|S|S|Y|I|            Window             |
|       |           |G|K|H|T|N|N|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |         Urgent Pointer        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             data                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

udp-protocol:

udp 协议报文

端口机制

3.网络层相关协议

ip protocol:

              ip头部协议报文
0               1               2               3               4
0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  LHL  | Type of Service |        Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Identification(fragment Id)    |Flags|  Fragment Offset      |
|           16 bits               |R|D|M|       13 bits         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time-To-Live  |   Protocol      |      Header Checksum        |
| ttl(8 bits)   |    8 bits       |          16 bits            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               Source IP Address (32 bits)                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              Destination Ip Address (32 bits)                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options (*** bits)          |  Padding     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].