Masar Labs

PatD - Ping and Traceroute Daemon for IPv4 and IPv6

patd (/patd) is a daemon to ping or traceroute remote hosts.
It is a daemon that runs without root privileges listening on a TCP port for hosts to check.
It receive commands listening on a TCP port and returns the results to the same connection.
patd (/patd) is usefull in situation where you cannot send native ICMP packet, for example from a Java program.

pat (/patd/pat.html) is a client you can use to talk to patd.


  • Does ping and traceroute.
  • Supports both IPv4 and IPv6.
  • Single daemon listening on a TCP local port.
  • Single threaded.
  • Does not run as root but uses capabilities to send ICMP packets.

There is also a client pat (/patd/pat.html) to send commands to patd (/patd).


You can download the sources of patd from here (/download).

There are also binary compiled for Debian Linux ( in our APT Repository (/debian)


Here are two examples of pat/patd.

Ping an host

  1. $> pat
  2. pat6 2606:2800:0220:006D:2626:1447:1097:0AA7
  3. O 2606:2800:0220:006D:26BF:1447:1097:0AA7 seq=1 time=88.374781 ms
  4. pat4
  5. O seq=1 time=129.832764 ms

Tracerout an Host

  1. $> pat -T
  2. pat6 2606:2800:0220:006D:2626:1447:1097:0AA7
  3. t 2001:4B78:0002:0000:0000:0000:0000:0162 seq=1 time=0.579375 ms
  4. t 2001:4B78:0002:000C:0000:0000:0000:0002 seq=2 time=0.577010 ms
  5. t 2001:0450:2002:0043:0000:0000:0000:0001 seq=3 time=0.641369 ms
  6. t 2001:0450:2008:0101:0000:0000:0000:0012 seq=4 time=18.460314 ms
  7. t 2001:2000:3018:0039:0000:0000:0000:0001 seq=5 time=99.657094 ms
  8. t 2001:2000:3080:0608:0000:0000:0000:0002 seq=6 time=91.176435 ms
  9. O 2606:2800:0220:006D:26BF:1447:1097:0AA7 seq=7 time=88.250489 ms
  10. pat4
  11. t seq=1 time=0.320014 ms
  12. t seq=2 time=0.669792 ms
  13. t seq=3 time=135.209402 ms
  14. t seq=4 time=0.569375 ms
  15. t seq=5 time=9.398323 ms
  16. t seq=6 time=9.287580 ms
  17. t seq=7 time=10.076306 ms
  18. t seq=8 time=113.164281 ms
  19. t seq=9 time=141.216692 ms
  20. t seq=10 time=133.022995 ms
  21. O seq=11 time=119.194537 ms


patd [OPTION]...


--address ADDR
set the address to listen to (default: localhost)
--port PORT
set the port to listen to (default: 7865)
-f, --foreground
run in foreground
-p, --pidfile FILE
write a pidfile
-q, --quiet
log less messages to syslog, can be used multiple times
-v, --verbose
log more messages to syslog, can be used multiple times
-h, --help
display an help message and exit
-V, --version
display version information and exit

Protocol Specification

patd accepts commands listening from a TCP connection, You can implement clients talking to patd following this protocol.

Multibyte values are in Network Byte Order, that means BigEndian or Hi bytes first.

Client query message has this format:

COMMAND 1 byte see below
SEND 1 byte min=1 max=63 default=3
RETURN 1 byte min=1 max=63 default=1
START_TTL 1 byte min=0 max=63 default=63
MAX_TTL 1 byte min=1 max=63 default=63
LENGTH 2 bytes min=0 max=32752 (0x7FF0) default=0
FRAGMENT 1 byte min=0 max=1 default=0
TIMEOUT 2 bytes min=1 max=2000 default=1000
ADDR 4,16 bytes IPv4 or IPv6 address

Where COMMAND is:

'4' (0x34) for an IPv4 query, total size of query 14 bytes
'6' (0x36) for an IPv6 query, total size of query 26 bytes

Server response has this format:

RESULT 1 byte see below
SEQ 1 byte
MSEQ 4 bytes
ADDR 4,16 bytes IPv4 or IPv6 address

Where RESULT is:

'o' (0x6F) OK
'O' (0x4F) OK, Last response
'e' (0x65) Error
'E' (0x45) Error, Last response
't' (0x74) Trace
'T' (0x54) Trace, Last response

Total size of response is 10 bytes for an IPv4 query, 22 bytes for an IPv6 query.


patd requires CAP_NET_RAW capability to be executed.


There is NO authentication and authorization so if you expose the TCP connection, you need to implement some firewall rules.

See Also

pat (/patd/pat.html)(8)