Git Product home page Git Product logo

tcp-info's Introduction

tcp-info

GoDoc Build Status Go Report Card Coverage Status

The tcp-info tool executes a polling loop that tracks the measurement statistics of every open TCP socket on a system. Data is written, in JSONL format (refered to internally as ArchivedRecord), to files compressed using zstd. This tool forms the basis of a lot of measurements on the Kubernetes-based Measurement Lab platform.

We expect most people will run this tool using a docker container. To invoke, with data written to ~/data, and prometheus metrics published on port 7070:

docker run --network=host -v ~/data:/home/ -it measurementlab/tcp-info -prom=7070

Fast tcp-info collector in Go

This repository uses the netlink API to collect inet_diag messages, partially parses them, and caches the intermediate representation. It then detects differences from one scan to the next, and queues connections that have changed for logging. It logs the intermediate representation through external zstd processes to one file per connection.

The previous version uses protobufs, but we have discontinued that largely because of the increased maintenance overhead, and risk of losing unparsed data. Instead, we are now using ArchivedRecord which is partially parsed netlink messages, mostly in base64 encoded blobs, marshaled to JSONL format, with one JSON object per line.

To run the tests or the collection tool, you will also require zstd, which can be installed with:

bash <(curl -fsSL https://raw.githubusercontent.com/horta/zstd.install/master/install)

OR

sudo apt-get update && sudo apt-get install -y zstd

Parse library and command line tools

CSV tool

The cmd/csvtool directory contains a tool for parsing ArchivedRecord and producing CSV files. Currently reads netlink-jSONL from stdin and writes CSV to stdout.

Code Layout

  • inetdiag - code related to include/uapi/linux/inet_diag.h. All structs will be in structs.go
  • tcp - Should include ONLY the code related to include/uapi/linux/tcp.h
  • parse - code related to parsing the messages in inetdiag and tcp.
  • zstd - zstd reader and writer.
  • saver - code related to writing ParsedMessages to files.
  • cache - code to cache netlink messages and detect changes.
  • collector - code related to collecting netlink messages from the kernel.

Dependencies (as of March 2019)

  • saver: inetdiag, cache, parse, tcp, zstd
  • collector: parse, saver, inetdiag, tcp
  • main.go: collector, saver, parse (just for sanity check)
  • cache: parse
  • parse: inetdiag

And (almost) all package use metrics.

Layers for main.go (each layer depends only on items to right, or lower layers)

  1. main.go
  2. collector > saver > cache
  3. netlink > inetdiag
  4. tcp, zstd, metrics

Layers for parse package:

  1. parse (used by command line tools, etl)
  2. netlink > inetdiag
  3. tcp, zstd, metrics

tcp-info's People

Contributors

bassosimone avatar gfr10598 avatar nkinkade avatar pboothe avatar stephen-soltesz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.