The oncrpc-ping is a utility designed to measure actual ONC RPC(Sun RPC) service latency over both TCP and UDP transport protocols. By bypassing the RPC Bind service, the utility avoids unnecessary service inquiries, ensuring accurate, end-to-end latency measurements.
| Library | Purpose |
|---|---|
| libtirpc | ONC RPC client API |
ONC RPC specifications define a standardized 'NULL' procedure (procedure number 0). This 'do-nothing' operation is supported by all ONC RPC servers and is ideal for service latency measurement.
To capture pure client-server RPC latency, the program utilizes low-level ONC RPC interfaces to control client behavior. The measurement lifecycle is as follows:
- Create a network socket configured for the specified transport (TCP/UDP).
- Initialize an ONC RPC client.
- Execute a
connect()call. - Issue an ONC RPC NULL request to the remote server and record the latency.
- Terminate the ONC RPC client connection.
The following simplified data flow graph shows where the program measures the latency (the box section):
Client Server
| |
| ------- Connect Request / Handshake ----> |
| <--------- Handshake Response ------------ |
| |
---------------------------------------------------
| | | |
| | --- ONC RPC NULL PROC (Ping Request) ----> | |
| | <--------- ONC RPC NULL PROC Reply ------- | |
| | | |
---------------------------------------------------
| |
| --------- Destroy ONC RPC Client --------> |
| <--------- Close Connection -------------- |
| |
$ make
gcc -g -Wall -Wextra -Wpedantic -Wconversion -Wdouble-promotion -Wunused -Wshadow -Wsign-conversion -fsanitize=undefined -I/usr/include/tirpc -c oncrpc-ping.c -o oncrpc-ping.o
gcc -g -Wall -Wextra -Wpedantic -Wconversion -Wdouble-promotion -Wunused -Wshadow -Wsign-conversion -fsanitize=undefined oncrpc-ping.o -o oncrpc-ping -lm -ltirpc
$ ./oncrpc-ping -h
ONC RPC Ping - Version 1.0.0
usage: oncrpc-ping -n|--hostname <target hostname / IP>
-P|--port <port number>
-p|--program-number <RPC program number>
-v|--program-version <RPC program version>
-T|--transport tcp|udp
[-i|--interval <second(s)>] default: 1 second
[-t|--rpc-timeout <second(s)>] default: 10 seconds
[-c|--connect-timeout <second(s)>] default: 5 seconds
[-C|--count <count number>]
[-h|--help]
-
-nor--hostname <hostname / IP>: target hostname or IP address of the RPC server -
-Por--port <port>: port number the RPC server is listening on -
-por--program-number <number>: ONC RPC program number registered by the target service -
-vor--program-version <version>: ONC RPC program version number of the target service -
-Tor--transport <tcp|udp>: transport protocol -
-ior--interval <seconds>: interval in whole seconds between successive RPC NULL calls -
-tor--rpc-timeout <seconds>: timeout in whole seconds for each individual RPC NULL call -
-cor--connect-timeout <seconds>: timeout in whole seconds for the initialconnect()call -
-Cor--count <number>: number of RPC NULL calls to send before printing statistics and exiting. if omitted, the program runs indefinitely until interrupted withCtrl+C(SIGINT), at which point it prints final statistics and exits cleanly -
-hor--help: print usage information and exit
[07/24/2026] 1.0.0 - initial commit
$ ./oncrpc-ping -n 10.x.x.x -P 2049 -p 100003 -v 3 -T tcp -C 5
INFO: socket file descriptor number: 3
index 1 from 10.x.x.x: RPC program=100003 version=3 time=0.084 ms | XID=0x948041C3
index 2 from 10.x.x.x: RPC program=100003 version=3 time=0.093 ms | XID=0x938041C3
index 3 from 10.x.x.x: RPC program=100003 version=3 time=0.070 ms | XID=0x928041C3
index 4 from 10.x.x.x: RPC program=100003 version=3 time=0.104 ms | XID=0x918041C3
index 5 from 10.x.x.x: RPC program=100003 version=3 time=0.149 ms | XID=0x908041C3
--- 10.x.x.x ONC RPC ping statistics ---
rtt min/avg/max/stddev = 0.070/0.100/0.149/0.027 ms