connqc

package module
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 14 Imported by: 0

README

Connection Quality Checker

connqc is a tool to assess the reliability of the network transport between networked hosts. Known connection issues that connqc has been designed to detect include:

  • Unstable connection between hosts
  • Firewall dropping packets intermittently
  • Ports or port combinations are blocked or become blocked
  • Routes flip flop causing spontaneous connection issues

While other tools exist that are similar to connqc, such as ping, netcat and iperf, they do not establish a connection that is maintained without user interaction while also reporting the connection quality.

connqc consists of a server that listens for TCP or UDP probing messages, and a client that sends said messages. The client logs the probing duration and warns if some messages get lost.

Usage

Server

Start the server. The default address is :8123:

$ connqc server 

or specify a port:

$ connqc server --addr=":1234"
More Options

The server command supports the following additional arguments.

OPTIONS:
   --addr value                         The address to listen on for probe messages (default: ":8123") [$ADDR]
   --buffer-size value                  The size of the read buffer used by the server (default: 512) [$BUFFER_SIZE]
   --read-timeout value                 The duration after which the server should timeout when reading from a connection (default: 2s) [$READ_TIMEOUT]
   --write-timeout value                The duration after which the server should timeout when writing to a connection (default: 5s) [$WRITE_TIMEOUT]
   --log.format value                   Specify the format of logs. Supported formats: 'logfmt', 'json', 'console' [$LOG_FORMAT]
   --log.level value                    Specify the log level. e.g. 'debug', 'info', 'error'. (default: "info") [$LOG_LEVEL]
   --log.ctx value [ --log.ctx value ]  A list of context field appended to every log. Format: key=value. [$LOG_CTX]
   --help, -h                           show help
Firewall

For use on firewalls managed with firewall-cmd:

$ firewall-cmd --add-port=8123/tcp
# and later after the test is done
$ firewall-cmd --remove-port=8123/tcp
Client

Start the client with the connqc server's address:

$ connqc client --addr="127.0.0.1:8123"

To enable more human-readable logs, set the log format:

$ connqc client --addr="127.0.0.1:8123" --log.format="console"

To increase the amount of sent requests, reduce the interval:

$ connqc client --addr="127.0.0.1:8123" --interval="200ms"
More Options

The client command supports the following additional arguments.

OPTIONS:
   --protocol value                     Use protocol for the connection (available: tcp, udp) (default: "tcp") [$PROTOCOL]
   --addr value                         The address of the connqc server [$ADDR]
   --backoff value                      The duration to wait for before retrying to connect to the server (default: 1s) [$BACKOFF]
   --interval value                     The interval at which to send probe messages to the server (default: 1s) [$INTERVAL]
   --read-timeout value                 The duration after which the client should timeout when reading from a connection (default: 2s) [$READ_TIMEOUT]
   --write-timeout value                The duration after which the client should timeout when writing to a connection (default: 5s) [$WRITE_TIMEOUT]
   --log.format value                   Specify the format of logs. Supported formats: 'logfmt', 'json', 'console' [$LOG_FORMAT]
   --log.level value                    Specify the log level. e.g. 'debug', 'info', 'error'. (default: "info") [$LOG_LEVEL]
   --log.ctx value [ --log.ctx value ]  A list of context field appended to every log. Format: key=value. [$LOG_CTX]
   --help, -h                           show help

License

Copyright 2023 marbis GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package connqc contains the connqc server and client implementations, as well as the probe message encoder and decoder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client attempts to hold a connection with a server, sending probe messages at a configured interval.

func NewClient

func NewClient(backoff, sendInterval, readTimeout, writeTimeout time.Duration, log *logger.Logger) *Client

NewClient returns a client.

func (*Client) Run

func (c *Client) Run(ctx context.Context, protocol, addr string)

Run sends probe messages to the server continuously. If the connection fails, it retries at the configured backoff interval.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes messages from a reader.

func NewDecoder

func NewDecoder(r io.Reader) Decoder

NewDecoder returns a decoder for the given reader.

func (Decoder) Decode

func (d Decoder) Decode() (Message, error)

Decode decodes a message off the stream.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder encodes messages onto a stream.

func NewEncoder

func NewEncoder(w io.Writer) Encoder

NewEncoder returns an encoder with the given writer.

func (Encoder) Encode

func (e Encoder) Encode(msg Message) error

Encode encodes a message onto the steam.

type Message

type Message interface {
	// contains filtered or unexported methods
}

Message represents a connqc message.

type Probe

type Probe struct {
	ID   uint64
	Data string
}

Probe is a probe message.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server handles connections from clients.

func NewServer

func NewServer(bufSize int, readTimeout, writeTimeout time.Duration, log *logger.Logger) *Server

NewServer returns a server.

func (*Server) Serve added in v1.2.0

func (s *Server) Serve(conn net.PacketConn)

Serve handles a connection from a client.

The handler provides an identical response to every message it receives. The caller who initiated the connection is responsible for ensuring its closure.

Directories

Path Synopsis
cmd
connqc command
Package main is the entry point of the application.
Package main is the entry point of the application.
internal
buffr
Package buffr provides a buffered reader.
Package buffr provides a buffered reader.
Package tcp provides a TCP server implementation.
Package tcp provides a TCP server implementation.
Package udp provides a UDP server implementation.
Package udp provides a UDP server implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL