All Projects → tevino → Tcp Shaker

tevino / Tcp Shaker

Licence: mit
💓 Performing TCP handshake without ACK in Go, useful for health checking, that is SYN, SYN-ACK, RST.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Tcp Shaker

Pypacker
📦 The fastest and simplest packet manipulation lib for Python
Stars: ✭ 216 (-25.26%)
Mutual labels:  network, tcp, packets
Simplenet
An easy-to-use, event-driven, asynchronous network application framework compiled with Java 11.
Stars: ✭ 164 (-43.25%)
Mutual labels:  network, tcp, packets
Rshijack
tcp connection hijacker, rust rewrite of shijack
Stars: ✭ 288 (-0.35%)
Mutual labels:  network, tcp
Netscanner
netscanner - TCP/UDP scanner to find open or closed ports
Stars: ✭ 191 (-33.91%)
Mutual labels:  network, tcp
Skillbox Chat
Skillbox demo application for the Python course
Stars: ✭ 86 (-70.24%)
Mutual labels:  network, tcp
Kalm.js
The socket manager
Stars: ✭ 155 (-46.37%)
Mutual labels:  network, tcp
Ofxgpio
Library C++ for raspberrypi and orangepi, GPIO interfaces compatible with openframeworks.
Stars: ✭ 155 (-46.37%)
Mutual labels:  network, tcp
Trackerjacker
Like nmap for mapping wifi networks you're not connected to, plus device tracking
Stars: ✭ 2,307 (+698.27%)
Mutual labels:  network, packets
React Native Tcp Socket
React Native TCP socket API for Android, iOS & macOS with client SSL/TLS support
Stars: ✭ 112 (-61.25%)
Mutual labels:  network, tcp
Network
C# Network Library
Stars: ✭ 237 (-17.99%)
Mutual labels:  network, tcp
Pjon
PJON (Padded Jittering Operative Network) is an experimental, arduino-compatible, multi-master, multi-media network protocol.
Stars: ✭ 2,615 (+804.84%)
Mutual labels:  network, tcp
dpdk
A comprehensive rust binding for DPDK allowing high speed userspace networking across 256 cores and 32 NICs
Stars: ✭ 30 (-89.62%)
Mutual labels:  tcp, packets
Qtnetworkng
QtNetwork Next Generation. A coroutine based network framework for Qt/C++, with more simpler API than boost::asio.
Stars: ✭ 125 (-56.75%)
Mutual labels:  network, tcp
Libtins
High-level, multiplatform C++ network packet sniffing and crafting library.
Stars: ✭ 1,609 (+456.75%)
Mutual labels:  network, packets
Fi6s
IPv6 network scanner designed to be fast
Stars: ✭ 116 (-59.86%)
Mutual labels:  network, tcp
Zserver4d
ZServer4D 是一套从商业项目剥离而出的云服务器中间件,可以承载百万级的分布式负载服务,并且支持IoT及内网穿透
Stars: ✭ 199 (-31.14%)
Mutual labels:  network, tcp
Smart Buffer
smart-buffer is a Buffer wrapper that adds automatic read & write offset tracking, string operations, data insertions, and more.
Stars: ✭ 73 (-74.74%)
Mutual labels:  network, packets
Deta cache
缓存cache服务器
Stars: ✭ 106 (-63.32%)
Mutual labels:  network, tcp
Hisocket
It is a lightweight client socket solution, you can used it in C# project or Unity3d
Stars: ✭ 275 (-4.84%)
Mutual labels:  network, tcp
L2-Emulator
Implementing a Layer-2 Emulator in C using Graphs and LinkedList
Stars: ✭ 17 (-94.12%)
Mutual labels:  tcp, packets

TCP Checker 💓

Go Report Card GoDoc Build Status

This package is used to perform TCP handshake without ACK, which useful for TCP health checking.

HAProxy does this exactly the same, which is:

  1. SYN
  2. SYN-ACK
  3. RST

This implementation has been running on tens of thousands of production servers for years.

Why do I have to do this

In most cases when you establish a TCP connection(e.g. via net.Dial), these are the first three packets between the client and server(TCP three-way handshake):

  1. Client -> Server: SYN
  2. Server -> Client: SYN-ACK
  3. Client -> Server: ACK

This package tries to avoid the last ACK when doing handshakes.

By sending the last ACK, the connection is considered established.

However, as for TCP health checking the server could be considered alive right after it sends back SYN-ACK,

that renders the last ACK unnecessary or even harmful in some cases.

Benefits

By avoiding the last ACK

  1. Less packets better efficiency
  2. The health checking is less obvious

The second one is essential because it bothers the server less.

This means the application level server will not notice the health checking traffic at all, thus the act of health checking will not be considered as some misbehavior of client.

Requirements

  • Linux 2.4 or newer

There is a fake implementation for non-Linux platform which is equivalent to:

conn, err := net.DialTimeout("tcp", addr, timeout)
conn.Close()

Usage

import "github.com/tevino/tcp-shaker"

c := NewChecker()

ctx, stopChecker := context.WithCancel(context.Background())
defer stopChecker()
go func() {
	if err := c.CheckingLoop(ctx); err != nil {
		fmt.Println("checking loop stopped due to fatal error: ", err)
	}
}()

<-c.WaitReady()

timeout := time.Second * 1
err := c.CheckAddr("google.com:80", timeout)
switch err {
case ErrTimeout:
	fmt.Println("Connect to Google timed out")
case nil:
	fmt.Println("Connect to Google succeeded")
default:
	fmt.Println("Error occurred while connecting: ", err)
}

TODO

  • [ ] IPv6 support (Test environment needed, PRs are welcome)

Special thanks to contributors

  • @lujjjh Added zero linger support for non-Linux platform
  • @jakubgs Fixed compatibility on Android
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].