8000 GitHub - smallnest/pping: Passive ping network monitoring utility (C++)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

smallnest/pping

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pping (pollere passive ping)

pping is a linux/macOS/BSD command line tool to measure network latency via passive monitoring of active connections. Unlike ping, pping doesn't inject traffic to determine RTT (Round-Trip Time) -- it reports the per-packet RTT experienced by normal application traffic. Unlike transport state monitoring tools like ss which can only measure RTT at the sending endpoint, pping can measure RTT at the sender, receiver or anywhere on a connection's path (for example, an OpenWrt home border router could easily monitor the RTT of all traffic to and from the Internet).

For more information on pping, please visit http://pollere.net/pping.html

For on-going work that incorporates the pping approach within an ISP, see: https://github.com/thebracket/cpumap-pping

Compiling

Prerequisites

pping depends on the libtins packet parsing library which should be downloaded and built or installed first.

静态编译libtins:

# (assuming sources are put in ~/src)
cd
7626
 ~/src
git clone https://github.com/mfontanini/libtins.git
cd libtins
mkdir build
cd build
cmake ../ -DLIBTINS_BUILD_SHARED=0 -DLIBTINS_ENABLE_CXX11=1 \
 -DLIBTINS_ENABLE_ACK_TRACKER=0 -DLIBTINS_ENABLE_WPA2=0 \
 -DCMAKE_INSTALL_PREFIX=`dirname $PWD`
make
make install

静态编译 libpcap (静态和动态库都编译):

wget http://www.tcpdump.org/release/libpcap-1.10.0.tar.gz
tar -zxvf libpcap-1.10.0.tar.gz
cd libpcap-1.10.0

./configure

sudo make install

安装glibclibstdc++的静态库:

yum install glibc-static libstdc++-static

Building

在上一个步骤,libtins被默认安装到了/usr/local, 所以Makefile中LIBTINS变量应该确保设置为/usr/local:

LIBTINS = /usr/local

确保静态编译:

#LIBTINS = $(HOME)/src/libtins
LIBTINS = /usr/local
CPPFLAGS += -I$(LIBTINS)/include
LDFLAGS += -L$(LIBTINS)/lib $(LIBTINS)/lib/libtins.a -static -ltins -lpcap
CXXFLAGS += -std=c++14 -g -O3 -Wall

pping:  pping.cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o pping pping.cpp $(LDFLAGS)

clean:
	rm pping

然后make就可以静态编译pping了。

检查编译好的pping有没有依赖动态库:

[root@vps3 pping]# readelf -d pping

There is no dynamic section in this file.

Examples

pping -i interface monitors tcp traffic on interface and reports each packet's RTT to stdout. For example pping -i en0 (Mac OS) pping -i wlp2s0 (Ubuntu 17.04)

pping -r pcapfile prints the RTT of tcp packets captured with tcpdump or wireshark to pcapfile.

There are a few flags that control how long pping will capture and/or how many packets it will capture, the output format, and a bpf filter for what packets to capture. For example, to see the RTT of next 100 tcp packets from netflix or youtube:

   pping -i en0 -c 100 -f 'net 45.57 or 74.125'

pping -h, pping --help, or just pping describes the flags.

Since pping outputs one line per packet, if it's being run on a busy interface its output should be redirected to a file or piped to a summarization or plotting utility. In the latter case, the -m (machine-friendly output format) might be useful.

Output to Mongo database

pping can be set up to output to a Mongo database. The compile flag USE_DB must be set and the mongo c++ library installed (https://mongodb.github.io/mongo-cxx-driver/). Once a mongo database instance is running, pping is invoked with the -d flag and given the uri. If this is not of interest, don't compile with the USE_DB flag.

About

Passive ping network monitoring utility (C++)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 97.9%
  • Makefile 2.1%
0