Code Monkey home page Code Monkey logo

go-metro's Introduction

go-metro

Requirements

This go package requires the great gopacket - it provides awesome packet decoding and pcap integration in Go. Unfortunately gopacket imposes a restriction on the go version due to some language features such as three-index slices - you will need go >=1.2. You will also need the PCAP library in your system - should be easy to find in any *NIX-style system in your package manager (apt-get, yum, ports, homebrew, etc). Also available in windows here - untested though!:

Description

This tool aims to passively calculate TCP RTTs between hosts communicating with us. What we do is fairly straightforward, we follow TCP streams active within a certain period of time and estimate the RTT between any outgoing packet with data, and its corresponding TCP acknowledgement. Because the PCAP library provides timestamping we are able to compute with a realtive high degree of precision the difference in time between these two events. To protect ourselves from duplicates and breaks in communication we use the TS and TSecr values in the TCP Options, if available, to differentiate between duplicates. For the time being we have chosen to ignore streams in which our host in not actively participating (ie. just ACKing incoming data) because in that scenario we do not know when the next incoming packet may come - it may not be imminent, there may be breaks in communication - and that would cause reporting inflated RTT values.

Usage

  • Make sure you have cloned gopacket into your $GOPATH/src, and have PCAP lib in your system.
  • Clone this repo into your $GOPATH/src
cd $GOPATH
go get -a -v github.com/DataDog/go-metro
go install github.com/DataDog/go-metro
  • You should now have the executable in $GOPATH/bin.
  • Have fun!

Linux tip

You don't need to run this as root, you can set CAP_NET_RAW capabilities on the executable - you will need sudo rights to do that though.

sudo setcap cap_net_raw+ep $GOPATH/bin/go-metro

And you're good to go, no need to be super anymore!

Note: Please note that you will need your filesystem to have extended security attributes enabled to allow setting capabilities on files. This will normally involve having your kernel built with a configuration enabling CONFIG_EXT3_FS_SECURITY, CONFIG_EXT4_FS_SECURITY, CONFIG_REISERFS_FS_SECUIRTY, etc and CONFIG_EXT3_FS_XATTR, CONFIG_EXT4_FS_XATTR, CONFIG_REISERFS_FS_XATTR, etc - depending on your filesystem. The good news is that Ubuntu/Fedora/Mint kernels are typically built with these features enabled straight out of the box. Also, you might have to ensure the partition is mounted to enable support xattr.

Agent 5.x >= 5.27.0

Plase note that if you are running the bundled go-metro with datadog agent 5.x w/ version >= 5.27.0, the file provided in /opt/datadog-agent/bin/go-metro is actually a wrapper script. The binary is actually found in /opt/datadog-agent/bin/go-metro.bin and so you should make sure you run the setcap commands provided above on that binary and not the wrapper script.

go-metro's People

Contributors

fanny-jiang avatar ganeshkumarsv avatar olivielpeau avatar remh avatar sgnn7 avatar truthbk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-metro's Issues

Slight typo and one missing -devel

At https://github.com/DataDog/go-metro#usage the instructions miss the capitalization of Data"D"og.

It says:

go install github.com/Datadog/go-metro

When it should say:

go install github.com/DataDog/go-metro

Finally, I also had to install "libpcap-devel" on a CentOS7 system in addition to the other packages. The error, for posterity was as follows:

$ go install github.com/DataDog/go-metro                                                   
# github.com/google/gopacket/pcap
src/github.com/google/gopacket/pcap/pcap_unix.go:34:18: fatal error: pcap.h: No such file or directory
 #include <pcap.h>
                  ^
compilation terminated.

go get failing.

go version

go version go1.3.3 linux/amd64

This command cd $GOPATH
go get -a -v github.com/DataDog/go-metro

Throws this error

runtime
errors
sync/atomic
unicode
unicode/utf8
math
sync
sort
io
syscall
container/list
hash
crypto/subtle
crypto/cipher
bytes
strings
bufio
crypto/hmac
time
encoding
path
hash/crc32
strconv
math/rand
os
reflect
crypto
crypto/aes
crypto/md5
crypto/rc4
crypto/sha1
crypto/sha256
crypto/sha512
encoding/base64
regexp/syntax
encoding/pem
net
path/filepath
io/ioutil
os/signal
encoding/binary
fmt
regexp
crypto/des
flag
math/big
encoding/hex
encoding/xml
archive/tar
compress/flate
crypto/elliptic
github.com/DataDog/datadog-go/statsd
crypto/rand
crypto/ecdsa
crypto/dsa
crypto/rsa
encoding/asn1
archive/zip
compress/gzip
github.com/cihub/seelog/archive/gzip
github.com/cihub/seelog/archive/tar
net/textproto
runtime/debug
github.com/cihub/seelog/archive
github.com/cihub/seelog/archive/zip
crypto/x509/pkix
github.com/google/gopacket
golang.org/x/net/context
gopkg.in/yaml.v2
crypto/x509
gopkg.in/tomb.v2
github.com/google/gopacket/layers
crypto/tls
net/smtp
github.com/cihub/seelog
github.com/google/gopacket/pcap
# github.com/google/gopacket/pcap
src/github.com/google/gopacket/pcap/pcap.go:30: undefined: pcapErrorNotActivated
src/github.com/google/gopacket/pcap/pcap.go:52: undefined: pcapTPtr
src/github.com/google/gopacket/pcap/pcap.go:64: undefined: pcapPkthdr

#cat /etc/os-release
NAME="SLES"
VERSION="12-SP4"
VERSION_ID="12.4"
PRETTY_NAME="SUSE Linux Enterprise Server 12 SP4"
ID="sles"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:12:sp4"

Please let me know if you need more info.
What am I doing wrong?

Improve example docs

In particular, better document how the 2 whitelists work, and that they're optional.

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.