HTTP

httping

2020年06月28日

Overview

http Protocol 通信を試験できる httping を試してみる。

Environment

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="21.04 (Hirsute Hippo)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 21.04"
VERSION_ID="21.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=hirsute
UBUNTU_CODENAME=hirsute
$ 

Install

sudo apt-get install httping

Use

Help

$ httping --help
HTTPing v2.5, (C) 2003-2016 folkert@vanheusden.com
 * SSL support included (-l)
 * ncurses interface with FFT included (-K)
 * TFO (TCP fast open) support included (-F)

 *** where to connect to ***
-g x / --url             URL to ping (e.g. -g http://localhost/)
-h x / --hostname        hostname to ping (e.g. localhost) - use either -g or -h
-p x / --port            portnumber (e.g. 80) - use with -h
-6   / --ipv6            use IPv6 when resolving/connecting
-l   / --use-ssl         connect using SSL. pinging an https URL automatically enables this setting

 *** proxy settings ***
-x x / --proxy           x should be "host:port" which are the network settings of the http/https
                         proxy server. ipv6 ip-address should be "[ip:address]:port"
-E                       fetch proxy settings from environment variables
--proxy-user x           username for authentication against proxy
--proxy-password x       password for authentication against proxy
--proxy-password-file x  read password for proxy authentication from file x
-5                       proxy is a socks5 server
--proxy-buster x         adds "&x=[random value]" to the request URL

 *** timing settings ***
-c x / --count           how many times to ping
-i x / --interval        delay between each ping
-t x / --timeout         timeout (default: 30s)
--ai / --adaptive-interval execute pings at multiples of interval relative to start, automatically
                         enabled in ncurses output mode
-f   / --flood           flood connect (no delays)

 *** HTTP settings ***
-Z   / --no-cache        ask any proxies on the way not to cache the requests
--divert-connect         connect to a different host than in the URL given
--keep-cookies           return the cookies given by the HTTP server in the following request(s)
--no-host-header         do not add "Host:"-line to the request headers
-Q   / --persistent-connections use a persistent connection, i.e. reuse the same TCP connection for
                         multiple HTTP requests. usually possible when 'Connection: Keep-Alive' is
                         sent by server. adds a 'C' to the output if httping had to reconnect
-I x / --user-agent      use 'x' for the UserAgent header
-R x / --referer         use 'x' for the Referer header
--header                 adds an extra request-header

 *** networking settings ***
--max-mtu                limit the MTU size
--no-tcp-nodelay         do not disable Naggle
--recv-buffer            receive buffer size
--tx-buffer              transmit buffer size
-r   / --resolve-once    resolve hostname only once (useful when pinging roundrobin DNS: also takes
                         the first DNS lookup out of the loop so that the first measurement is also
                         correct)
-W                       do not abort the program if resolving failed: keep retrying
-y x / --bind-to         bind to an ip-address (and thus interface) with an optional port
-F   / --tcp-fast-open   "TCP fast open" (TFO), reduces the latency of TCP connects
--priority               set priority of packets
--tos                    set TOS (type of service)

 *** HTTP authentication ***
-A   / --basic-auth      activate ("basic") authentication
-U x / --username        username for authentication
-P x / --password        password for authentication
-T x                     read the password fom the file 'x' (replacement for -P)

 *** output settings ***
-s   / --show-statuscodes show statuscodes
-S   / --split-time      split measured time in its individual components (resolve, connect, send,
                         etc.
--threshold-red          from what ping value to show the value in red (must be bigger than yellow),
                         only in color mode (-Y)
--threshold-yellow       from what ping value to show the value in yellow
--threshold-show         from what ping value to show the results
--timestamp / --ts       put a timestamp before the measured values, use -v to include the date and
                         -vv to show in microseconds
--aggregate x[,y[,z]]    show an aggregate each x[/y[/z[/etc]]] seconds
-z   / --show-fingerprint show fingerprint (SSL)
-v                       verbose mode

 *** "GET" (instead of HTTP "HEAD") settings ***
-G   / --get-request     do a GET request instead of HEAD (read the contents of the page as well)
-b   / --show-transfer-speed show transfer speed in KB/s (use with -G)
-B   / --show-xfer-speed-compressed like -b but use compression if available
-L x / --data-limit      limit the amount of data transferred (for -b) to 'x' (in bytes)
-X   / --show-kb         show the number of KB transferred (for -b)

 *** output mode settings ***
-q   / --quiet           quiet, only returncode
-m   / --parseable-output give machine parseable output (see also -o and -e)
-M                       json output, cannot be combined with -m
-o rc,rc,... / --ok-result-codes what http results codes indicate 'ok' comma separated WITHOUT
                         spaces inbetween default is 200, use with -e
-e x / --result-string   string to display when http result code doesn't match
-n warn,crit / --nagios-mode-1 / --nagios-mode-2 Nagios-mode: return 1 when avg. response time >=
                         warn, 2 if >= crit, otherwhise return 0
-N x                     Nagios mode 2: return 0 when all fine, 'x' when anything failes
-C cookie=value / --cookie add a cookie to the request
-Y   / --colors          add colors
-a   / --audible-ping    audible ping

 *** GUI/ncurses mode settings ***
-K   / --ncurses / --gui ncurses/GUI mode
--draw-phase             draw phase (fourier transform) in gui
--slow-log               when the duration is x or more, show ping line in the slow log window (the
                         middle window)
--graph-limit x          do not scale to values above x
-D   / --no-graph        do not show graphs (in ncurses/GUI mode)

-V   / --version         show the version

Example:
	httping x201 -Y -s -Z

$  

Verify

$ httping -c 5 -l rlab.travelersmedia.jp
PING rlab.travelersmedia.jp:443 (/):
connected to 192.168.10.1:443 (240 bytes), seq=0 time= 37.16 ms 
connected to 192.168.10.1:443 (240 bytes), seq=1 time=125.12 ms 
connected to 192.168.10.1:443 (240 bytes), seq=2 time=133.86 ms 
connected to 192.168.10.1:443 (240 bytes), seq=3 time= 38.02 ms 
connected to 192.168.10.1:443 (240 bytes), seq=4 time= 33.85 ms 
--- https://rlab.cavtime.net/ ping statistics ---
5 connects, 5 ok, 0.00% failed, time 5370ms
round-trip min/avg/max = 33.9/73.6/133.9 ms
$ 

Packet

$ httping -c 1 -l rlab.travelersmedia.jp
PING rlab.travelersmedia.jp:443 (/):
connected to 192.168.10.1:443 (240 bytes), seq=0 time= 51.66 ms 
--- https://rlab.cavtime.net/ ping statistics ---
1 connects, 1 ok, 0.00% failed, time 1052ms
round-trip min/avg/max = 51.7/51.7/51.7 ms
$ 
No.     Time           Source                Destination           Protocol Length Info
     34 2.357892997    192.168.1.59          192.168.10.1          TCP      74     53188 → 443 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 SACK_PERM=1 TSval=4055077589 TSecr=0 WS=128
     35 2.368063931    192.168.10.1          192.168.1.59          TCP      74     443 → 53188 [SYN, ACK] Seq=0 Ack=1 Win=65160 Len=0 MSS=1414 SACK_PERM=1 TSval=13198109 TSecr=4055077589 WS=128
     36 2.368129613    192.168.1.59          192.168.10.1          TCP      66     53188 → 443 [ACK] Seq=1 Ack=1 Win=64256 Len=0 TSval=4055077600 TSecr=13198109
     37 2.368668850    192.168.1.59          192.168.10.1          TLSv1.3  349    Client Hello
     38 2.371176703    192.168.10.1          192.168.1.59          TCP      66     443 → 53188 [ACK] Seq=1 Ack=284 Win=64896 Len=0 TSval=13198117 TSecr=4055077600
     39 2.374088730    192.168.10.1          192.168.1.59          TLSv1.3  1514   Server Hello, Change Cipher Spec, Application Data
     40 2.374125319    192.168.1.59          192.168.10.1          TCP      66     53188 → 443 [ACK] Seq=284 Ack=1449 Win=63104 Len=0 TSval=4055077605 TSecr=13198118
     41 2.374156254    192.168.10.1          192.168.1.59          TCP      1514   443 → 53188 [PSH, ACK] Seq=1449 Ack=284 Win=64896 Len=1448 TSval=13198118 TSecr=4055077600 [TCP segment of a reassembled PDU]
     42 2.374179669    192.168.1.59          192.168.10.1          TCP      66     53188 → 443 [ACK] Seq=284 Ack=2897 Win=61696 Len=0 TSval=4055077606 TSecr=13198118
     43 2.374203890    192.168.10.1          192.168.1.59          TCP      1266   443 → 53188 [PSH, ACK] Seq=2897 Ack=284 Win=64896 Len=1200 TSval=13198118 TSecr=4055077600 [TCP segment of a reassembled PDU]
     44 2.374225645    192.168.1.59          192.168.10.1          TCP      66     53188 → 443 [ACK] Seq=284 Ack=4097 Win=60544 Len=0 TSval=4055077606 TSecr=13198118
     45 2.374245383    192.168.10.1          192.168.1.59          TLSv1.3  555    Application Data, Application Data, Application Data
     46 2.374252501    192.168.1.59          192.168.10.1          TCP      66     53188 → 443 [ACK] Seq=284 Ack=4586 Win=60160 Len=0 TSval=4055077606 TSecr=13198119
     47 2.375442449    192.168.1.59          192.168.10.1          TLSv1.3  146    Change Cipher Spec, Application Data
     48 2.375525044    192.168.1.59          192.168.10.1          TLSv1.3  163    Application Data
     49 2.379064668    192.168.10.1          192.168.1.59          TCP      66     443 → 53188 [ACK] Seq=4586 Ack=364 Win=64896 Len=0 TSval=13198123 TSecr=4055077607
     50 2.379097016    192.168.10.1          192.168.1.59          TCP      66     443 → 53188 [ACK] Seq=4586 Ack=461 Win=64896 Len=0 TSval=13198124 TSecr=4055077607
     51 2.379117310    192.168.10.1          192.168.1.59          TLSv1.3  337    Application Data
     52 2.379134701    192.168.1.59          192.168.10.1          TCP      66     53188 → 443 [ACK] Seq=461 Ack=4857 Win=63872 Len=0 TSval=4055077611 TSecr=13198124
     53 2.379156546    192.168.10.1          192.168.1.59          TLSv1.3  337    Application Data
     54 2.379172289    192.168.1.59          192.168.10.1          TCP      66     53188 → 443 [ACK] Seq=461 Ack=5128 Win=63616 Len=0 TSval=4055077611 TSecr=13198124
     55 2.394568518    192.168.10.1          192.168.1.59          TLSv1.3  324    Application Data
     56 2.394595859    192.168.1.59          192.168.10.1          TCP      66     53188 → 443 [ACK] Seq=461 Ack=5386 Win=63360 Len=0 TSval=4055077626 TSecr=13198139
     57 2.394630957    192.168.10.1          192.168.1.59          TLSv1.3  90     Application Data
     58 2.394645559    192.168.1.59          192.168.10.1          TCP      66     53188 → 443 [ACK] Seq=461 Ack=5410 Win=63360 Len=0 TSval=4055077626 TSecr=13198139
     59 2.394663660    192.168.10.1          192.168.1.59          TCP      66     443 → 53188 [FIN, ACK] Seq=5410 Ack=461 Win=64896 Len=0 TSval=13198139 TSecr=4055077611
     60 2.394772554    192.168.1.59          192.168.10.1          TLSv1.3  90     Application Data
     61 2.394875874    192.168.1.59          192.168.10.1          TCP      66     53188 → 443 [FIN, ACK] Seq=485 Ack=5411 Win=64128 Len=0 TSval=4055077626 TSecr=13198139
     62 2.399888911    192.168.10.1          192.168.1.59          TCP      66     443 → 53188 [ACK] Seq=5411 Ack=485 Win=64896 Len=0 TSval=13198143 TSecr=4055077626
     63 2.399913833    192.168.10.1          192.168.1.59          TCP      66     443 → 53188 [ACK] Seq=5411 Ack=486 Win=64896 Len=0 TSval=13198143 TSecr=4055077626