All Projects → veithen → Knetstat

veithen / Knetstat

Licence: gpl-2.0
Simple kernel module to inspect socket options

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Knetstat

Reactor Netty
TCP/HTTP/UDP/QUIC client/server with Reactor over Netty
Stars: ✭ 1,743 (+1200.75%)
Mutual labels:  tcp, udp
Stream
NodeJS Modbus Stream
Stars: ✭ 114 (-14.93%)
Mutual labels:  tcp, udp
Esp8266 Wifi Uart Bridge
Transparent WiFi (TCP, UDP) to UART Bridge, in AP or STATION mode
Stars: ✭ 107 (-20.15%)
Mutual labels:  tcp, udp
T Io
解决其它网络框架没有解决的用户痛点,让天下没有难开发的网络程序
Stars: ✭ 1,331 (+893.28%)
Mutual labels:  tcp, udp
Async Sockets Cpp
Simple thread-based asynchronous TCP & UDP Socket classes in C++.
Stars: ✭ 127 (-5.22%)
Mutual labels:  tcp, udp
Packetsender
Network utility for sending / receiving TCP, UDP, SSL
Stars: ✭ 1,349 (+906.72%)
Mutual labels:  tcp, udp
Pingtunnel
ping tunnel is a tool that advertises tcp/udp/socks5 traffic as icmp traffic for forwarding.
Stars: ✭ 1,904 (+1320.9%)
Mutual labels:  tcp, udp
Netassistant
A UDP/TCP Assistant. 网络调试助手
Stars: ✭ 66 (-50.75%)
Mutual labels:  tcp, udp
Gobetween
☁️ Modern & minimalistic load balancer for the Сloud era
Stars: ✭ 1,631 (+1117.16%)
Mutual labels:  tcp, udp
Goproxy
🔥 Proxy is a high performance HTTP(S) proxies, SOCKS5 proxies,WEBSOCKET, TCP, UDP proxy server implemented by golang. Now, it supports chain-style proxies,nat forwarding in different lan,TCP/UDP port forwarding, SSH forwarding.Proxy是golang实现的高性能http,https,websocket,tcp,socks5代理服务器,支持内网穿透,链式代理,通讯加密,智能HTTP,SOCKS5代理,黑白名单,限速,限流量,限连接数,跨平台,KCP支持,认证API。
Stars: ✭ 11,334 (+8358.21%)
Mutual labels:  tcp, udp
N2o
⭕ N2O: Distributed Application Server
Stars: ✭ 1,262 (+841.79%)
Mutual labels:  tcp, udp
Pbscan
Faster and more efficient stateless SYN scanner and banner grabber due to userland TCP/IP stack usage.
Stars: ✭ 122 (-8.96%)
Mutual labels:  tcp, udp
Objectdeliverer
ObjectDeliverer is a data transmission / reception library for Unreal Engine (C ++, Blueprint).
Stars: ✭ 78 (-41.79%)
Mutual labels:  tcp, udp
Oscp5
An Open Sound Control (OSC) implementation for Java and Processing
Stars: ✭ 103 (-23.13%)
Mutual labels:  tcp, udp
Logbert
Logbert is an advanced log message viewer for log4net, log4j and others.
Stars: ✭ 70 (-47.76%)
Mutual labels:  tcp, udp
Ddos Rootsec
DDOS Archive by RootSec (Scanners, BotNets (Mirai and QBot Premium & Normal and more), Exploits, Methods, Sniffers)
Stars: ✭ 108 (-19.4%)
Mutual labels:  tcp, udp
Mr2
Mr.2 can help you expose local server to external network. Support both TCP/UDP, of course support HTTP. Zero-Configuration.
Stars: ✭ 1,102 (+722.39%)
Mutual labels:  tcp, udp
Pytcp
PyTCP is an attempt to create fully functional TCP/IP stack in Python. It supports TCP stream based transport with reliable packet delivery based on sliding window mechanism and basic congestion control. It also supports IPv6/ICMPv6 protocols with SLAAC address configuration. It operates as user space program attached to Linux TAP interface. As of today stack is able to send and receive traffic over Internet using IPv4 and IPv6 default gateways for routing. Since goal of this project is purely educational (at least at this point) the clarity of code is preferred over its efficiency. For the same reason security features are not being implemented just yet unless they are integral part of TCP/IP suite protocols specification.
Stars: ✭ 65 (-51.49%)
Mutual labels:  tcp, udp
Fi6s
IPv6 network scanner designed to be fast
Stars: ✭ 116 (-13.43%)
Mutual labels:  tcp, udp
Go Netstat
A netstat implementation written in Go
Stars: ✭ 121 (-9.7%)
Mutual labels:  tcp, udp

knetstat

Introduction

knetstat is a simple Linux kernel module that adds four new files to /proc/net: tcpstat, tcp6stat, udpstat and udp6stat. The content of these files is roughly equivalent to the output of netstat with options -t4an, -t6an, -u4an and -u6an respectively, i.e. they provide information about TCP and UDP sockets in human readable form. The difference with the corresponding netstat output is that they have an additional column that displays (a subset of) the socket options. This was the primary motivation for writing the knetstat kernel module: currently, on Linux there is no way for an administrator to inspect the options set on a socket created by some process (other than using strace or an equivalent tool on that process at socket creation/configuration time), because this information is not exposed through the /proc file system.

knetstat internally reuses the infrastructure that is used by the kernel to generate the content of the /proc/net/tcp, /proc/net/tcp6, /proc/net/udp and /proc/net/udp6 files. This means that there is a one-to-one correspondence between the entries in these files and the entries in the files generated by knetstat. Only the formatting and information content is different between the two.

Here is some sample output:

$ cat /proc/net/tcpstat 
Recv-Q Send-Q Local Address           Foreign Address         Stat Diag Options
     0      0 127.0.0.1:6010          0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_KEEPALIVE=0,TCP_NODELAY=0
     0      0 0.0.0.0:22              0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_KEEPALIVE=0,TCP_NODELAY=0
     0      0 192.168.1.18:22         192.168.1.6:49537       ESTB      SO_REUSEADDR=1,SO_KEEPALIVE=1,TCP_NODELAY=1
     0      0 127.0.0.1:6010          127.0.0.1:45462         ESTB      SO_REUSEADDR=1,SO_KEEPALIVE=0,TCP_NODELAY=1
     0      0 127.0.0.1:45462         127.0.0.1:6010          ESTB      SO_REUSEADDR=0,SO_KEEPALIVE=1,TCP_NODELAY=1

The "Diag" column can display the following diagnostic indicators:

Indicator Meaning
>| The sender window (i.e. the window advertised by the remote endpoint) is 0. No data can be sent to the peer.
|< The receiver window (i.e. the window advertised by the local endpoint) is 0. No data can be received from the peer.
># There are unacknowledged packets and the last ACK was received more than one second ago. This may be an indication that there are network problems or that the peer crashed.

Currently supported features

  • Protocols: TCP and UDP (IPv4 and IPv6)
  • Socket options: SO_REUSEADDR, SO_REUSEPORT, SO_KEEPALIVE (TCP), TCP_KEEPIDLE (TCP), TCP_KEEPCNT (TCP), TCP_KEEPINTVL (TCP), SO_RCVBUF, SO_SNDBUF, SO_RCVTIMEO, SO_SNDTIMEO, SO_LINGER (TCP), TCP_NODELAY, TCP_FASTOPEN, TCP_DEFER_ACCEPT, SO_BROADCAST (UDP)

TCP Keepalive Parameter Handling

TCP_KEEPIDLE, TCP_KEEPCNT and TCP_KEEPINTVL correspond to tcp_keepalive_time, tcp_keepalive_probes and tcp_keepalive_intvl values described in tcp(7) and the respective sysctls. If those values are overridden at the socket level (by setting them to something other than zero), they will be printed by knetstat, otherwise, the kernel will use sysctls and the module will ignore them while printing the output.

Compatibility

The current knetstat code has been successfully tested with kernel versions 3.13, 3.18, 4.4, 4.8, 4.9 and 4.15. It may work with other versions as well.

Build

To build the module, ensure that you have the headers for the currently running kernel as well as the basic build tools such as make and GCC. E.g. on Ubuntu:

# apt-get install linux-headers-$(uname -r) make gcc

Then check out the knetstat source code and execute make. This should create knetstat.ko which can be loaded using insmod.

Notes for Java developers

The following table shows the correspondence between socket options reported by knetstat and setter methods defined by the java.net.Socket class. This information can be used to infer the configuration that a Java process applied to a java.net.Socket instance based on the output of knetstat. The mapping is straightforward, except for setSoTimeout.

Java method Socket option reported by knetstat
setKeepAlive SO_KEEPALIVE
setReceiveBufferSize SO_RCVBUF
setReuseAddress SO_REUSEADDR
setSendBufferSize SO_SNDBUF
setSoLinger SO_LINGER
setSoTimeout none [*]
setTcpNoDelay TCP_NODELAY

[*] In contrast to what the Javadoc suggests, the setSoTimeout method doesn't actually set any socket option on Linux. By default, java.net.Socket instances are backed by java.net.SocksSocketImpl (even if no SOCKS proxy is configured). This class extends java.net.AbstractPlainSocketImpl which stores the timeout internally for later use by the read methods in java.net.SocketInputStream. They in turn pass the timeout to an invocation of the poll system call that waits until data is available for reading (or an error occurs).

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].