How to format WHOIS response - bash

I need to implement a "whois" service, that will be listening for whois queries (whois -h ) and will respond with information from phpipam API. I am listening on port 43 with xinetd that starts script.
My problem is that when I send a response from the server, the server after first new line, resets connection. For testing purposes I am simply trying to send two echo lines and result is the same.
Script:
#!/bin/bash
echo "One"
echo "Two"
lsof:
# lsof -i | grep whois
xinetd 17696 root 6u IPv4 91809 0t0 TCP *:whois (LISTEN)
whois query (from client):
# whois -h 192.168.4.129 44.44.44.44
One
fgets: Connection reset by peer
tcpdump:
# tcpdump -n -i any -X port 43
16:34:01.162440 IP 192.168.4.128.49374 > 192.168.4.129.nicname: Flags [S], seq 1949234703, win 29200, options [mss 1460,sackOK,TS val 337480796 ecr 0,nop,wscale 7], length 0
0x0000: 4500 003c 7a53 4000 4006 3617 c0a8 0480 E..<zS#.#.6.....
0x0010: c0a8 0481 c0de 002b 742e f60f 0000 0000 .......+t.......
0x0020: a002 7210 8a80 0000 0204 05b4 0402 080a ..r.............
0x0030: 141d 8c5c 0000 0000 0103 0307 0000 0000 ...\............
0x0040: 0000 0000 0000 0000 0000 0000 ............
16:34:01.162916 IP 192.168.4.129.nicname > 192.168.4.128.49374: Flags [S.], seq 3654394026, ack 1949234704, win 28960, options [mss 1460,sackOK,TS val 25631110 ecr 337480796,nop,wscale 7], length 0
0x0000: 4500 003c 0000 4000 4006 b06a c0a8 0481 E..<..#.#..j....
0x0010: c0a8 0480 002b c0de d9d1 a0aa 742e f610 .....+......t...
0x0020: a012 7120 eb31 0000 0204 05b4 0402 080a ..q..1..........
0x0030: 0187 1986 141d 8c5c 0103 0307 0000 0000 .......\........
0x0040: 0000 0000 0000 0000 0000 0000 ............
16:34:01.162946 IP 192.168.4.128.49374 > 192.168.4.129.nicname: Flags [.], ack 1, win 229, options [nop,nop,TS val 337480797 ecr 25631110], length 0
0x0000: 4500 0034 7a54 4000 4006 361e c0a8 0480 E..4zT#.#.6.....
0x0010: c0a8 0481 c0de 002b 742e f610 d9d1 a0ab .......+t.......
0x0020: 8010 00e5 8a78 0000 0101 080a 141d 8c5d .....x.........]
0x0030: 0187 1986 0000 0000 0000 0000 0000 0000 ................
0x0040: 0000 0000 ....
16:34:01.163348 IP 192.168.4.128.49374 > 192.168.4.129.nicname: Flags [P.], seq 1:14, ack 1, win 229, options [nop,nop,TS val 337480798 ecr 25631110], length 13
0x0000: 4500 0041 7a55 4000 4006 3610 c0a8 0480 E..AzU#.#.6.....
0x0010: c0a8 0481 c0de 002b 742e f610 d9d1 a0ab .......+t.......
0x0020: 8018 00e5 8a85 0000 0101 080a 141d 8c5e ...............^
0x0030: 0187 1986 3434 2e34 342e 3434 2e34 340d ....44.44.44.44.
0x0040: 0a00 0000 0000 0000 0000 0000 0000 0000 ................
0x0050: 00 .
16:34:01.164122 IP 192.168.4.129.nicname > 192.168.4.128.49374: Flags [.], ack 14, win 227, options [nop,nop,TS val 25631110 ecr 337480798], length 0
0x0000: 4500 0034 b92d 4000 4006 f744 c0a8 0481 E..4.-#.#..D....
0x0010: c0a8 0480 002b c0de d9d1 a0ab 742e f61d .....+......t...
0x0020: 8010 00e3 8a2c 0000 0101 080a 0187 1986 .....,..........
0x0030: 141d 8c5e 0000 0000 0000 0000 0000 0000 ...^............
0x0040: 0000 0000 ....
16:34:01.165523 IP 192.168.4.129.nicname > 192.168.4.128.49374: Flags [P.], seq 1:5, ack 14, win 227, options [nop,nop,TS val 25631110 ecr 337480798], length 4
0x0000: 4500 0038 b92e 4000 4006 f73f c0a8 0481 E..8..#.#..?....
0x0010: c0a8 0480 002b c0de d9d1 a0ab 742e f61d .....+......t...
0x0020: 8018 00e3 d5a7 0000 0101 080a 0187 1986 ................
0x0030: 141d 8c5e 4f6e 650a 0000 0000 0000 0000 ...^One.........
0x0040: 0000 0000 0000 0000 ........
16:34:01.165844 IP 192.168.4.128.49374 > 192.168.4.129.nicname: Flags [.], ack 5, win 229, options [nop,nop,TS val 337480800 ecr 25631110], length 0
0x0000: 4500 0034 7a56 4000 4006 361c c0a8 0480 E..4zV#.#.6.....
0x0010: c0a8 0481 c0de 002b 742e f61d d9d1 a0af .......+t.......
0x0020: 8010 00e5 8a78 0000 0101 080a 141d 8c60 .....x.........`
0x0030: 0187 1986 0000 0000 0000 0000 0000 0000 ................
0x0040: 0000 0000 ....
16:34:01.165914 IP 192.168.4.129.nicname > 192.168.4.128.49374: Flags [R.], seq 5, ack 14, win 227, options [nop,nop,TS val 25631111 ecr 337480798], length 0
0x0000: 4500 0034 b92f 4000 4006 f742 c0a8 0481 E..4./#.#..B....
0x0010: c0a8 0480 002b c0de d9d1 a0af 742e f61d .....+......t...
0x0020: 8014 00e3 8a23 0000 0101 080a 0187 1987 .....#..........
0x0030: 141d 8c5e 0000 0000 0000 0000 0000 0000 ...^............
0x0040: 0000 0000 ....
16:34:01.166350 IP 192.168.4.129.nicname > 192.168.4.128.49374: Flags [R], seq 3654394031, win 0, length 0
0x0000: 4500 0028 826a 4000 4006 2e14 c0a8 0481 E..(.j#.#.......
0x0010: c0a8 0480 002b c0de d9d1 a0af 0000 0000 .....+..........
0x0020: 5004 0000 ea03 0000 0000 0000 0000 0000 P...............
0x0030: 0000 0000 0000 0000 0000 0000 0000 ..............
If I try to connect to 43 with telnet, everything work fine:
# telnet 192.168.4.129 43
Trying 192.168.4.129...
Connected to 192.168.4.129.
Escape character is '^]'.
One
Two
Connection closed by foreign host.
UPDATE:
Loop like this works fine
while read line; do
echo "One"
echo "Two"
break
done
But still I can't understand why it is not working by just passing two echo lines, or even if I try to run a while loop with counter:
#!/bin/bash
COUNT=0
while [ $COUNT -lt 5 ]; do
echo The counter is $COUNT
let COUNT=COUNT+1
done
It stops after the first cycle:
# whois -h 192.168.4.129 44.44.44.44
The counter is 0
fgets: Connection reset by peer
Maybe you have any ideas, what is the reason/difference between these two loops?
My /etc/xinetd.d/whoistest:
service whois
{
port = 43
flags = REUSE
socket_type = stream
protocol = tcp
user = root
wait = no
type = UNLISTED
server = /path/to/shell/script
disable = no
log_type = SYSLOG authpriv
log_on_failure += USERID
}
Any support will be appreciated.

You need to make sure your xinetd is configured correctly. Your script also needs to handle input from whois client. This works:
#!/bin/bash
while read line; do
echo $line
echo "foo"
break
done
This reads your line, echoes it back and then something. Feel free to replace echo $line with echo whatever you want.
I had to configure xinetd like this for it to work:
service whois
{
port = 43
flags = REUSE
socket_type = stream
protocol = tcp
user = root
wait = no
type = UNLISTED
server = /tmp/w.sh
disable = no
}
Hope this helps. If your xinetd service is configured wrong, it just seems to drop the connection. If your server doesn't actually listen to input from client, you'll get connection reset by peer errors.
Hannu

Related

Intermittent connection success to Firebird 1.5.4 using RazorSQL 9.3 and included (current) Firebird JDBC driver

I'm connecting to a set of Firebird 1.5.2 servers (2.4.20 Linux kernel - circa 2003. These are a closed, end of life system serving a telephony application (Service Control Point) in an SS7 switching environment. They will not ever be upgraded to current distributions of any components, would a monumental job from rewriting kernel drivers up through two hardware abstraction layers. Just in case you were about to ask. Moreover, they run and run and rarely fail with due to tremendous redundancy in power, drives, processes and connectivity. Designed for Five Nines.
We have a central syncing application that is also running 1.5.2, in-house custom connect C library, connections are fine, reliable, rock solid.
In order to assist in some service migrations (I was the original principal designer of the system 18 years ago), I need to access the databases (as well as other components); Now I had an old VM running FlameRobin, but you know, Intel VM not happy to be on an M1. So I just installed Razor 9.3 on my very new Mac M1.
It does connect to the databases, but it is a hit or miss for success. Sometimes it gets it on the first try, other time 3 or 4 or 5 failures then bang, connect.
I recalled a colleague in our IS group mention that for a Windows Delphi app [unclear how it connects] they had to set the connection attempts into a loop (tries a max of 50 times), because it was likely to fail. So on fail I knew to just try again, being reasonably sure of my settings.
I understand that the current JDBC driver supports Firebird 2+, and that it works on 1.5.4 is a bonus; and humbly I ask a two fold question:
One of curiosity: why is it intermittent - I would expect the same behaviour across attempts?
One of fear: is a subsequent update to the JDBC driver likely to fix the inconsistency and make all attempts fail?
When connection fails, the error received is:
ERROR: An error occurred while trying to make a connection to
the database:
JDBC URL:
jdbc:firebirdsql://10.X.X.X//usr/local/somepath/some.fdb
connection rejected by remote interface [SQLState:08004, ISC
error code:335544421]
On the server the firebird shows
SCP01 Wed Apr 7 11:51:33 2021
SERVER/process_packet: connect reject, server exiting
SCP01 Wed Apr 7 11:51:33 2021
SERVER/process_packet: connect reject, server exiting
tcpdump of successful connection - this trace differs from the failure at the 16 or 17th packet. The 192. is the client, the 10. is the server.
09:19:19.467277 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 64)
192.168.52.114.49170 > 10.4.1.61.3050: Flags [SEW], cksum 0x84b7 (correct), seq 3429195333, win 65535, options [mss 1300,nop,wscale 6,nop,nop,TS val 1496670700 ecr 0,sackOK,eol], length 0
0x0000: 4500 0040 0000 4000 4006 3a5d c0a8 3472 E..#..#.#.:]..4r
0x0010: 0a04 013d c012 0bea cc65 5e45 0000 0000 ...=.....e^E....
0x0020: b0c2 ffff 84b7 0000 0204 0514 0103 0306 ................
0x0030: 0101 080a 5935 61ec 0000 0000 0402 0000 ....Y5a.........
09:19:19.492791 IP (tos 0x0, ttl 57, id 1734, offset 0, flags [DF], proto TCP (6), length 60)
10.4.1.61.3050 > 192.168.52.114.49170: Flags [S.], cksum 0xeb79 (correct), seq 610193967, ack 3429195334, win 5792, options [mss 1460,sackOK,TS val 1450067643 ecr 1496670700,nop,wscale 0], length 0
0x0000: 4500 003c 06c6 4000 3906 3a9b 0a04 013d E..<..#.9.:....=
0x0010: c0a8 3472 0bea c012 245e d22f cc65 5e46 ..4r....$^./.e^F
0x0020: a012 16a0 eb79 0000 0204 05b4 0402 080a .....y..........
0x0030: 566e 46bb 5935 61ec 0103 0300 VnF.Y5a.....
09:19:19.492813 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.49170 > 10.4.1.61.3050: Flags [.], cksum 0x28c2 (correct), seq 3429195334, ack 610193968, win 2052, options [nop,nop,TS val 1496670725 ecr 1450067643], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d c012 0bea cc65 5e46 245e d230 ...=.....e^F$^.0
0x0020: 8010 0804 28c2 0000 0101 080a 5935 6205 ....(.......Y5b.
0x0030: 566e 46bb VnF.
09:19:19.494984 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 528)
192.168.52.114.49170 > 10.4.1.61.3050: Flags [P.], cksum 0x8aa4 (correct), seq 3429195334:3429195810, ack 610193968, win 2052, options [nop,nop,TS val 1496670727 ecr 1450067643], length 476
0x0000: 4500 0210 0000 4000 4006 388d c0a8 3472 E.....#.#.8...4r
0x0010: 0a04 013d c012 0bea cc65 5e46 245e d230 ...=.....e^F$^.0
0x0020: 8018 0804 8aa4 0000 0101 080a 5935 6207 ............Y5b.
0x0030: 566e 46bb 0000 0001 0000 0013 0000 0003 VnF.............
0x0040: 0000 0001 0000 0020 2f75 7372 2f6c 6f63 ......../usr/loc
<snip>
0x01a0: 0419 4461 6e69 656c 732d 4d61 6342 6f6f ..Daniels-MacBoo
0x01b0: 6b2d 4169 722e 6c6f 6361 6c06 0020 2020 k-Air.local.....
0x01c0: 0000 000a 0000 0001 0000 0002 0000 0003 ................
0x01d0: 0000 0001 0000 800b 0000 0001 0000 0005 ................
0x01e0: 0000 0005 0000 0002 0000 800c 0000 0001 ................
0x01f0: 0000 0005 0000 0005 0000 0003 0000 800d ................
0x0200: 0000 0001 0000 0005 0000 0005 0000 0004 ................
09:19:19.520781 IP (tos 0x0, ttl 57, id 1735, offset 0, flags [DF], proto TCP (6), length 52)
10.4.1.61.3050 > 192.168.52.114.49170: Flags [.], cksum 0x15c5 (correct), seq 610193968, ack 3429195810, win 6432, options [nop,nop,TS val 1450067646 ecr 1496670727], length 0
0x0000: 4500 0034 06c7 4000 3906 3aa2 0a04 013d E..4..#.9.:....=
0x0010: c0a8 3472 0bea c012 245e d230 cc65 6022 ..4r....$^.0.e`"
0x0020: 8010 1920 15c5 0000 0101 080a 566e 46be ............VnF.
0x0030: 5935 6207 Y5b.
09:19:19.536740 IP (tos 0x0, ttl 57, id 1753, offset 0, flags [DF], proto TCP (6), length 56)
10.4.1.61.3050 > 192.168.52.114.49170: Flags [P.], cksum 0x15b3 (correct), seq 610193968:610193972, ack 3429195810, win 6432, options [nop,nop,TS val 1450067648 ecr 1496670727], length 4
0x0000: 4500 0038 06d9 4000 3906 3a8c 0a04 013d E..8..#.9.:....=
0x0010: c0a8 3472 0bea c012 245e d230 cc65 6022 ..4r....$^.0.e`"
0x0020: 8018 1920 15b3 0000 0101 080a 566e 46c0 ............VnF.
0x0030: 5935 6207 0000 0004 Y5b.....
09:19:19.536752 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.49170 > 10.4.1.61.3050: Flags [.], cksum 0x26b3 (correct), seq 3429195810, ack 610193972, win 2052, options [nop,nop,TS val 1496670767 ecr 1450067648], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d c012 0bea cc65 6022 245e d234 ...=.....e`"$^.4
0x0020: 8010 0804 26b3 0000 0101 080a 5935 622f ....&.......Y5b/
0x0030: 566e 46c0 VnF.
09:19:19.536762 IP (tos 0x0, ttl 57, id 1754, offset 0, flags [DF], proto TCP (6), length 52)
10.4.1.61.3050 > 192.168.52.114.49170: Flags [F.], cksum 0x15be (correct), seq 610193972, ack 3429195810, win 6432, options [nop,nop,TS val 1450067648 ecr 1496670727], length 0
0x0000: 4500 0034 06da 4000 3906 3a8f 0a04 013d E..4..#.9.:....=
0x0010: c0a8 3472 0bea c012 245e d234 cc65 6022 ..4r....$^.4.e`"
0x0020: 8011 1920 15be 0000 0101 080a 566e 46c0 ............VnF.
0x0030: 5935 6207 Y5b.
09:19:19.536770 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.49170 > 10.4.1.61.3050: Flags [.], cksum 0x26b2 (correct), seq 3429195810, ack 610193973, win 2052, options [nop,nop,TS val 1496670767 ecr 1450067648], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d c012 0bea cc65 6022 245e d235 ...=.....e`"$^.5
0x0020: 8010 0804 26b2 0000 0101 080a 5935 622f ....&.......Y5b/
0x0030: 566e 46c0 VnF.
09:19:19.536816 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.49170 > 10.4.1.61.3050: Flags [F.], cksum 0x26b1 (correct), seq 3429195810, ack 610193973, win 2052, options [nop,nop,TS val 1496670767 ecr 1450067648], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d c012 0bea cc65 6022 245e d235 ...=.....e`"$^.5
0x0020: 8011 0804 26b1 0000 0101 080a 5935 622f ....&.......Y5b/
0x0030: 566e 46c0 VnF.
09:19:19.553654 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 64)
192.168.52.114.49171 > 10.4.1.61.3050: Flags [SEW], cksum 0x7202 (correct), seq 116864533, win 65535, options [mss 1300,nop,wscale 6,nop,nop,TS val 1496670783 ecr 0,sackOK,eol], length 0
0x0000: 4500 0040 0000 4000 4006 3a5d c0a8 3472 E..#..#.#.:]..4r
0x0010: 0a04 013d c013 0bea 06f7 3615 0000 0000 ...=......6.....
0x0020: b0c2 ffff 7202 0000 0204 0514 0103 0306 ....r...........
0x0030: 0101 080a 5935 623f 0000 0000 0402 0000 ....Y5b?........
09:19:19.559660 IP (tos 0x0, ttl 57, id 1755, offset 0, flags [DF], proto TCP (6), length 52)
10.4.1.61.3050 > 192.168.52.114.49170: Flags [.], cksum 0x1593 (correct), seq 610193973, ack 3429195811, win 6432, options [nop,nop,TS val 1450067650 ecr 1496670767], length 0
0x0000: 4500 0034 06db 4000 3906 3a8e 0a04 013d E..4..#.9.:....=
0x0010: c0a8 3472 0bea c012 245e d235 cc65 6023 ..4r....$^.5.e`#
0x0020: 8010 1920 1593 0000 0101 080a 566e 46c2 ............VnF.
0x0030: 5935 622f Y5b/
09:19:19.591334 IP (tos 0x0, ttl 57, id 1756, offset 0, flags [DF], proto TCP (6), length 60)
10.4.1.61.3050 > 192.168.52.114.49171: Flags [S.], cksum 0x7b97 (correct), seq 614280980, ack 116864534, win 5792, options [mss 1460,sackOK,TS val 1450067653 ecr 1496670783,nop,wscale 0], length 0
0x0000: 4500 003c 06dc 4000 3906 3a85 0a04 013d E..<..#.9.:....=
0x0010: c0a8 3472 0bea c013 249d 2f14 06f7 3616 ..4r....$./...6.
0x0020: a012 16a0 7b97 0000 0204 05b4 0402 080a ....{...........
0x0030: 566e 46c5 5935 623f 0103 0300 VnF.Y5b?....
09:19:19.591352 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.49171 > 10.4.1.61.3050: Flags [.], cksum 0xb8d3 (correct), seq 116864534, ack 614280981, win 2052, options [nop,nop,TS val 1496670820 ecr 1450067653], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d c013 0bea 06f7 3616 249d 2f15 ...=......6.$./.
0x0020: 8010 0804 b8d3 0000 0101 080a 5935 6264 ............Y5bd
0x0030: 566e 46c5 VnF.
09:19:19.592148 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 532)
192.168.52.114.49171 > 10.4.1.61.3050: Flags [P.], cksum 0x326f (correct), seq 116864534:116865014, ack 614280981, win 2052, options [nop,nop,TS val 1496670820 ecr 1450067653], length 480
0x0000: 4500 0214 0000 4000 4006 3889 c0a8 3472 E.....#.#.8...4r
0x0010: 0a04 013d c013 0bea 06f7 3616 249d 2f15 ...=......6.$./.
0x0020: 8018 0804 326f 0000 0101 080a 5935 6264 ....2o......Y5bd
0x0030: 566e 46c5 0000 0001 0000 0013 0000 0003 VnF.............
0x0040: 0000 0001 0000 0021 2f75 7372 2f6c 6f63 .......!/usr/loc
<snip>
0x01a0: 6e69 656c 0419 4461 6e69 656c 732d 4d61 niel..Daniels-Ma
0x01b0: 6342 6f6f 6b2d 4169 722e 6c6f 6361 6c06 cBook-Air.local.
0x01c0: 0020 2020 0000 000a 0000 0001 0000 0002 ................
0x01d0: 0000 0003 0000 0001 0000 800b 0000 0001 ................
0x01e0: 0000 0005 0000 0005 0000 0002 0000 800c ................
0x01f0: 0000 0001 0000 0005 0000 0005 0000 0003 ................
0x0200: 0000 800d 0000 0001 0000 0005 0000 0005 ................
0x0210: 0000 0004 ....
09:19:19.625717 IP (tos 0x0, ttl 57, id 1757, offset 0, flags [DF], proto TCP (6), length 52)
10.4.1.61.3050 > 192.168.52.114.49171: Flags [.], cksum 0xa5d3 (correct), seq 614280981, ack 116865014, win 6432, options [nop,nop,TS val 1450067657 ecr 1496670820], length 0
0x0000: 4500 0034 06dd 4000 3906 3a8c 0a04 013d E..4..#.9.:....=
0x0010: c0a8 3472 0bea c013 249d 2f15 06f7 37f6 ..4r....$./...7.
0x0020: 8010 1920 a5d3 0000 0101 080a 566e 46c9 ............VnF.
0x0030: 5935 6264 Y5bd
09:19:19.633936 IP (tos 0x0, ttl 57, id 1746, offset 0, flags [DF], proto TCP (6), length 68)
10.4.1.61.3050 > 192.168.52.114.49171: Flags [P.], cksum 0xa5a9 (correct), seq 614280981:614280997, ack 116865014, win 6432, options [nop,nop,TS val 1450067658 ecr 1496670820], length 16
0x0000: 4500 0044 06d2 4000 3906 3a87 0a04 013d E..D..#.9.:....=
0x0010: c0a8 3472 0bea c013 249d 2f15 06f7 37f6 ..4r....$./...7.
0x0020: 8018 1920 a5a9 0000 0101 080a 566e 46ca ............VnF.
0x0030: 5935 6264 0000 0003 0000 000a 0000 0001 Y5bd............
0x0040: 0000 0003 ....
09:19:19.633943 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.49171 > 10.4.1.61.3050: Flags [.], cksum 0xb6b6 (correct), seq 116865014, ack 614280997, win 2052, options [nop,nop,TS val 1496670860 ecr 1450067658], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d c013 0bea 06f7 37f6 249d 2f25 ...=......7.$./%
0x0020: 8010 0804 b6b6 0000 0101 080a 5935 628c ............Y5b.
0x0030: 566e 46ca VnF.
09:19:19.634826 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 164)
192.168.52.114.49171 > 10.4.1.61.3050: Flags [P.], cksum 0x6de4 (correct), seq 116865014:116865126, ack 614280997, win 2052, options [nop,nop,TS val 1496670860 ecr 1450067658], length 112
0x0000: 4500 00a4 0000 4000 4006 39f9 c0a8 3472 E.....#.#.9...4r
0x0010: 0a04 013d c013 0bea 06f7 37f6 249d 2f25 ...=......7.$./%
0x0020: 8018 0804 6de4 0000 0101 080a 5935 628c ....m.......Y5b.
0x0030: 566e 46ca 0000 0013 0000 0000 0000 0021 VnF............!
0x0040: 2f75 7372 2f6c 6f63 616c 2f63 6d64 4461 /usr/local/cmdDa
<snip>
0x0080: 7351 5932 3f04 0300 0000 3904 2300 0000 sQY2?.....9.#...
0x0090: 5b0f 416d 6572 6963 612f 546f 726f 6e74 [.America/Toront
0x00a0: 6f00 0000 o...
09:19:19.703801 IP (tos 0x0, ttl 57, id 1760, offset 0, flags [DF], proto TCP (6), length 84)
10.4.1.61.3050 > 192.168.52.114.49171: Flags [P.], cksum 0xa4f2 (correct), seq 614280997:614281029, ack 116865126, win 6432, options [nop,nop,TS val 1450067664 ecr 1496670860], length 32
0x0000: 4500 0054 06e0 4000 3906 3a69 0a04 013d E..T..#.9.:i...=
0x0010: c0a8 3472 0bea c013 249d 2f25 06f7 3866 ..4r....$./%..8f
0x0020: 8018 1920 a4f2 0000 0101 080a 566e 46d0 ............VnF.
0x0030: 5935 628c 0000 0009 0000 0000 0000 0000 Y5b.............
0x0040: 0000 0000 0000 0000 0000 0001 0000 0000 ................
0x0050: 0000 0000 ....
09:19:19.703820 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.49171 > 10.4.1.61.3050: Flags [.], cksum 0xb5db (correct), seq 116865126, ack 614281029, win 2052, options [nop,nop,TS val 1496670929 ecr 1450067664], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d c013 0bea 06f7 3866 249d 2f45 ...=......8f$./E
0x0020: 8010 0804 b5db 0000 0101 080a 5935 62d1 ............Y5b.
0x0030: 566e 46d0 VnF.
09:19:19.704234 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 80)
192.168.52.114.49171 > 10.4.1.61.3050: Flags [P.], cksum 0x31c2 (correct), seq 116865126:116865154, ack 614281029, win 2052, options [nop,nop,TS val 1496670929 ecr 1450067664], length 28
0x0000: 4500 0050 0000 4000 4006 3a4d c0a8 3472 E..P..#.#.:M..4r
0x0010: 0a04 013d c013 0bea 06f7 3866 249d 2f45 ...=......8f$./E
0x0020: 8018 0804 31c2 0000 0101 080a 5935 62d1 ....1.......Y5b.
0x0030: 566e 46d0 0000 0028 0000 0000 0000 0000 VnF....(........
0x0040: 0000 0005 3e67 2021 0120 2020 0000 0400 ....>g.!........
09:19:19.740991 IP (tos 0x0, ttl 57, id 1761, offset 0, flags [DF], proto TCP (6), length 1108)
10.4.1.61.3050 > 192.168.52.114.49171: Flags [P.], cksum 0xc58d (correct), seq 614281029:614282085, ack 116865154, win 6432, options [nop,nop,TS val 1450067668 ecr 1496670929], length 1056
0x0000: 4500 0454 06e1 4000 3906 3668 0a04 013d E..T..#.9.6h...=
0x0010: c0a8 3472 0bea c013 249d 2f45 06f7 3882 ..4r....$./E..8.
0x0020: 8018 1920 c58d 0000 0101 080a 566e 46d4 ............VnF.
0x0030: 5935 62d1 0000 0009 0000 0000 0000 0000 Y5b.............
0x0040: 0000 0000 0000 0400 3e01 0001 6749 0002 ........>...gI..
0x0050: 1b4c 492d 5631 2e35 2e32 2e34 3733 3120 .LI-V1.5.2.4731.
0x0060: 4669 7265 6269 7264 2031 2e35 2b4c 492d Firebird.1.5+LI-
0x0070: 5631 2e35 2e32 2e34 3733 3120 4669 7265 V1.5.2.4731.Fire
0x0080: 6269 7264 2031 2e35 2f74 6370 2028 5343 bird.1.5/tcp.(SC
0x0090: 5030 3129 2f50 3130 2004 000a 0000 0021 P01)/P10.......!
0x00a0: 0400 0100 0000 0100 0000 0000 0000 0000 ................
<snip>
0x0440: 0000 0000 0000 0000 0000 0001 0000 0000 ................
0x0450: 0000 0000 ....
09:19:19.741007 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.49171 > 10.4.1.61.3050: Flags [.], cksum 0xb188 (correct), seq 116865154, ack 614282085, win 2035, options [nop,nop,TS val 1496670965 ecr 1450067668], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d c013 0bea 06f7 3882 249d 3365 ...=......8.$.3e
0x0020: 8010 07f3 b188 0000 0101 080a 5935 62f5 ............Y5b.
0x0030: 566e 46d4 VnF.
tcpdump of failed connection
09:18:41.315669 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 64)
192.168.52.114.65500 > 10.4.1.61.3050: Flags [SEW], cksum 0x62cf (correct), seq 1302090607, win 65535, options [mss 1300,nop,wscale 6,nop,nop,TS val 1496632746 ecr 0,sackOK,eol], length 0
0x0000: 4500 0040 0000 4000 4006 3a5d c0a8 3472 E..#..#.#.:]..4r
0x0010: 0a04 013d ffdc 0bea 4d9c 536f 0000 0000 ...=....M.So....
0x0020: b0c2 ffff 62cf 0000 0204 0514 0103 0306 ....b...........
0x0030: 0101 080a 5934 cdaa 0000 0000 0402 0000 ....Y4..........
09:18:41.347668 IP (tos 0x0, ttl 57, id 65389, offset 0, flags [DF], proto TCP (6), length 60)
10.4.1.61.3050 > 192.168.52.114.65500: Flags [S.], cksum 0x0a4c (correct), seq 570729141, ack 1302090608, win 5792, options [mss 1460,sackOK,TS val 1450063829 ecr 1496632746,nop,wscale 0], length 0
0x0000: 4500 003c ff6d 4000 3906 41f3 0a04 013d E..<.m#.9.A....=
0x0010: c0a8 3472 0bea ffdc 2204 a2b5 4d9c 5370 ..4r...."...M.Sp
0x0020: a012 16a0 0a4c 0000 0204 05b4 0402 080a .....L..........
0x0030: 566e 37d5 5934 cdaa 0103 0300 Vn7.Y4......
09:18:41.347687 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.65500 > 10.4.1.61.3050: Flags [.], cksum 0x478d (correct), seq 1302090608, ack 570729142, win 2052, options [nop,nop,TS val 1496632778 ecr 1450063829], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d ffdc 0bea 4d9c 5370 2204 a2b6 ...=....M.Sp"...
0x0020: 8010 0804 478d 0000 0101 080a 5934 cdca ....G.......Y4..
0x0030: 566e 37d5 Vn7.
09:18:41.651317 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 528)
192.168.52.114.65500 > 10.4.1.61.3050: Flags [P.], cksum 0x9017 (correct), seq 1302090608:1302091084, ack 570729142, win 2052, options [nop,nop,TS val 1496633077 ecr 1450063829], length 476
0x0000: 4500 0210 0000 4000 4006 388d c0a8 3472 E.....#.#.8...4r
0x0010: 0a04 013d ffdc 0bea 4d9c 5370 2204 a2b6 ...=....M.Sp"...
0x0020: 8018 0804 9017 0000 0101 080a 5934 cef5 ............Y4..
0x0030: 566e 37d5 0000 0001 0000 0013 0000 0003 Vn7.............
0x0040: 0000 0001 0000 0020 2f75 7372 2f6c 6f63 ......../usr/loc
<snip>
0x01a0: 0419 4461 6e69 656c 732d 4d61 6342 6f6f ..Daniels-MacBoo
0x01b0: 6b2d 4169 722e 6c6f 6361 6c06 0020 2020 k-Air.local.....
0x01c0: 0000 000a 0000 0001 0000 0002 0000 0003 ................
0x01d0: 0000 0001 0000 800b 0000 0001 0000 0005 ................
0x01e0: 0000 0005 0000 0002 0000 800c 0000 0001 ................
0x01f0: 0000 0005 0000 0005 0000 0003 0000 800d ................
0x0200: 0000 0001 0000 0005 0000 0005 0000 0004 ................
09:18:41.691197 IP (tos 0x0, ttl 57, id 65390, offset 0, flags [DF], proto TCP (6), length 52)
10.4.1.61.3050 > 192.168.52.114.65500: Flags [.], cksum 0x3348 (correct), seq 570729142, ack 1302091084, win 6432, options [nop,nop,TS val 1450063863 ecr 1496633077], length 0
0x0000: 4500 0034 ff6e 4000 3906 41fa 0a04 013d E..4.n#.9.A....=
0x0010: c0a8 3472 0bea ffdc 2204 a2b6 4d9c 554c ..4r...."...M.UL
0x0020: 8010 1920 3348 0000 0101 080a 566e 37f7 ....3H......Vn7.
0x0030: 5934 cef5 Y4..
09:18:41.700913 IP (tos 0x0, ttl 57, id 65393, offset 0, flags [DF], proto TCP (6), length 56)
10.4.1.61.3050 > 192.168.52.114.65500: Flags [P.], cksum 0x3337 (correct), seq 570729142:570729146, ack 1302091084, win 6432, options [nop,nop,TS val 1450063864 ecr 1496633077], length 4
0x0000: 4500 0038 ff71 4000 3906 41f3 0a04 013d E..8.q#.9.A....=
0x0010: c0a8 3472 0bea ffdc 2204 a2b6 4d9c 554c ..4r...."...M.UL
0x0020: 8018 1920 3337 0000 0101 080a 566e 37f8 ....37......Vn7.
0x0030: 5934 cef5 0000 0004 Y4......
09:18:41.700921 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.65500 > 10.4.1.61.3050: Flags [.], cksum 0x442f (correct), seq 1302091084, ack 570729146, win 2052, options [nop,nop,TS val 1496633125 ecr 1450063864], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d ffdc 0bea 4d9c 554c 2204 a2ba ...=....M.UL"...
0x0020: 8010 0804 442f 0000 0101 080a 5934 cf25 ....D/......Y4.%
0x0030: 566e 37f8 Vn7.
09:18:41.701042 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.65500 > 10.4.1.61.3050: Flags [F.], cksum 0x442e (correct), seq 1302091084, ack 570729146, win 2052, options [nop,nop,TS val 1496633125 ecr 1450063864], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d ffdc 0bea 4d9c 554c 2204 a2ba ...=....M.UL"...
0x0020: 8011 0804 442e 0000 0101 080a 5934 cf25 ....D.......Y4.%
0x0030: 566e 37f8 Vn7.
09:18:41.701717 IP (tos 0x0, ttl 57, id 65394, offset 0, flags [DF], proto TCP (6), length 52)
10.4.1.61.3050 > 192.168.52.114.65500: Flags [F.], cksum 0x3342 (correct), seq 570729146, ack 1302091084, win 6432, options [nop,nop,TS val 1450063864 ecr 1496633077], length 0
0x0000: 4500 0034 ff72 4000 3906 41f6 0a04 013d E..4.r#.9.A....=
0x0010: c0a8 3472 0bea ffdc 2204 a2ba 4d9c 554c ..4r...."...M.UL
0x0020: 8011 1920 3342 0000 0101 080a 566e 37f8 ....3B......Vn7.
0x0030: 5934 cef5 Y4..
09:18:41.701727 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.65500 > 10.4.1.61.3050: Flags [F.], cksum 0x442d (correct), seq 1302091084, ack 570729147, win 2052, options [nop,nop,TS val 1496633125 ecr 1450063864], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d ffdc 0bea 4d9c 554c 2204 a2bb ...=....M.UL"...
0x0020: 8011 0804 442d 0000 0101 080a 5934 cf25 ....D-......Y4.%
0x0030: 566e 37f8 Vn7.
09:18:41.708391 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 64)
192.168.52.114.65501 > 10.4.1.61.3050: Flags [SEW], cksum 0xff81 (correct), seq 179959836, win 65535, options [mss 1300,nop,wscale 6,nop,nop,TS val 1496633132 ecr 0,sackOK,eol], length 0
0x0000: 4500 0040 0000 4000 4006 3a5d c0a8 3472 E..#..#.#.:]..4r
0x0010: 0a04 013d ffdd 0bea 0ab9 f81c 0000 0000 ...=............
0x0020: b0c2 ffff ff81 0000 0204 0514 0103 0306 ................
0x0030: 0101 080a 5934 cf2c 0000 0000 0402 0000 ....Y4.,........
09:18:41.734738 IP (tos 0x0, ttl 57, id 65391, offset 0, flags [DF], proto TCP (6), length 52)
10.4.1.61.3050 > 192.168.52.114.65500: Flags [.], cksum 0x330d (correct), seq 570729147, ack 1302091085, win 6432, options [nop,nop,TS val 1450063868 ecr 1496633125], length 0
0x0000: 4500 0034 ff6f 4000 3906 41f9 0a04 013d E..4.o#.9.A....=
0x0010: c0a8 3472 0bea ffdc 2204 a2bb 4d9c 554d ..4r...."...M.UM
0x0020: 8010 1920 330d 0000 0101 080a 566e 37fc ....3.......Vn7.
0x0030: 5934 cf25 Y4.%
09:18:41.735602 IP (tos 0x0, ttl 57, id 65396, offset 0, flags [DF], proto TCP (6), length 60)
10.4.1.61.3050 > 192.168.52.114.65501: Flags [S.], cksum 0x6855 (correct), seq 578216133, ack 179959837, win 5792, options [mss 1460,sackOK,TS val 1450063868 ecr 1496633132,nop,wscale 0], length 0
0x0000: 4500 003c ff74 4000 3906 41ec 0a04 013d E..<.t#.9.A....=
0x0010: c0a8 3472 0bea ffdd 2276 e0c5 0ab9 f81d ..4r...."v......
0x0020: a012 16a0 6855 0000 0204 05b4 0402 080a ....hU..........
0x0030: 566e 37fc 5934 cf2c 0103 0300 Vn7.Y4.,....
09:18:41.735620 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.65501 > 10.4.1.61.3050: Flags [.], cksum 0xa59c (correct), seq 179959837, ack 578216134, win 2052, options [nop,nop,TS val 1496633158 ecr 1450063868], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d ffdd 0bea 0ab9 f81d 2276 e0c6 ...=........"v..
0x0020: 8010 0804 a59c 0000 0101 080a 5934 cf46 ............Y4.F
0x0030: 566e 37fc Vn7.
09:18:41.736482 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 532)
192.168.52.114.65501 > 10.4.1.61.3050: Flags [P.], cksum 0xb417 (correct), seq 179959837:179960317, ack 578216134, win 2052, options [nop,nop,TS val 1496633158 ecr 1450063868], length 480
0x0000: 4500 0214 0000 4000 4006 3889 c0a8 3472 E.....#.#.8...4r
0x0010: 0a04 013d ffdd 0bea 0ab9 f81d 2276 e0c6 ...=........"v..
0x0020: 8018 0804 b417 0000 0101 080a 5934 cf46 ............Y4.F
0x0030: 566e 37fc 0000 0001 0000 0013 0000 0003 Vn7.............
0x0040: 0000 0001 0000 0021 2f75 7372 2f6c 6f63 .......!/usr/loc
<snip>
0x01a0: 6e69 656c 0419 4461 6e69 656c 732d 4d61 niel..Daniels-Ma
0x01b0: 6342 6f6f 6b2d 4169 722e 6c6f 6361 6c06 cBook-Air.local.
0x01c0: 0020 2020 0000 000a 0000 0001 0000 0002 ................
0x01d0: 0000 0003 0000 0001 0000 800b 0000 0001 ................
0x01e0: 0000 0005 0000 0005 0000 0002 0000 800c ................
0x01f0: 0000 0001 0000 0005 0000 0005 0000 0003 ................
0x0200: 0000 800d 0000 0001 0000 0005 0000 0005 ................
0x0210: 0000 0004 ....
09:18:41.758811 IP (tos 0x0, ttl 57, id 65397, offset 0, flags [DF], proto TCP (6), length 52)
10.4.1.61.3050 > 192.168.52.114.65501: Flags [.], cksum 0x929e (correct), seq 578216134, ack 179960317, win 6432, options [nop,nop,TS val 1450063870 ecr 1496633158], length 0
0x0000: 4500 0034 ff75 4000 3906 41f3 0a04 013d E..4.u#.9.A....=
0x0010: c0a8 3472 0bea ffdd 2276 e0c6 0ab9 f9fd ..4r...."v......
0x0020: 8010 1920 929e 0000 0101 080a 566e 37fe ............Vn7.
0x0030: 5934 cf46 Y4.F
09:18:41.773914 IP (tos 0x0, ttl 57, id 65399, offset 0, flags [DF], proto TCP (6), length 56)
10.4.1.61.3050 > 192.168.52.114.65501: Flags [P.], cksum 0x928c (correct), seq 578216134:578216138, ack 179960317, win 6432, options [nop,nop,TS val 1450063872 ecr 1496633158], length 4
0x0000: 4500 0038 ff77 4000 3906 41ed 0a04 013d E..8.w#.9.A....=
0x0010: c0a8 3472 0bea ffdd 2276 e0c6 0ab9 f9fd ..4r...."v......
0x0020: 8018 1920 928c 0000 0101 080a 566e 3800 ............Vn8.
0x0030: 5934 cf46 0000 0004 Y4.F....
09:18:41.773923 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.65501 > 10.4.1.61.3050: Flags [.], cksum 0xa38f (correct), seq 179960317, ack 578216138, win 2052, options [nop,nop,TS val 1496633195 ecr 1450063872], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d ffdd 0bea 0ab9 f9fd 2276 e0ca ...=........"v..
0x0020: 8010 0804 a38f 0000 0101 080a 5934 cf6b ............Y4.k
0x0030: 566e 3800 Vn8.
09:18:41.774002 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.52.114.65501 > 10.4.1.61.3050: Flags [F.], cksum 0xa38e (correct), seq 179960317, ack 578216138, win 2052, options [nop,nop,TS val 1496633195 ecr 1450063872], length 0
0x0000: 4500 0034 0000 4000 4006 3a69 c0a8 3472 E..4..#.#.:i..4r
0x0010: 0a04 013d ffdd 0bea 0ab9 f9fd 2276 e0ca ...=........"v..
0x0020: 8011 0804 a38e 0000 0101 080a 5934 cf6b ............Y4.k
0x0030: 566e 3800 Vn8.
<last 3 packets skipped, but out of room here, but they were somewhat repeats of prior>

Why does this avi file with raw video yield only one frame=

I created an AVI file by rendering the frames using Cairo. The AVI generation code is part of an OCaml library. However, ffmpeg and vlc both yield only the very first frame. If I cut the avi header and use ffplay with the proper codec options, I can view the movie just fine.
What causes ffmpeg to think this file has only one frame?
The header of the file looks like this:
0000000 4952 4646 d0e0 0278 5641 2049 494c 5453
0000010 00c0 0000 6468 6c72 7661 6869 0038 0000
0000020 a2c2 0000 0000 0000 0000 0000 0100 0000
0000030 003c 0000 0000 0000 0001 0000 0000 0000
0000040 01e0 0000 01e0 0000 0000 0000 0000 0000
0000050 0000 0000 0000 0000 494c 5453 0074 0000
0000060 7473 6c72 7473 6872 0038 0000 6976 7364
0000070 4752 2042 0000 0000 0000 0000 0000 0000
0000080 000a 0000 00f0 0000 0000 0000 003c 0000
0000090 2000 00fd 0000 0000 0001 0000 0000 0000
00000a0 01e0 01e0 7473 6672 0028 0000 0028 0000
00000b0 01e0 0000 01e0 0000 0001 0018 0000 0000
00000c0 8c00 000a 0000 0000 0000 0000 0000 0000
00000d0 0000 0000 494c 5453 d00c 0278 6f6d 6976
00000e0 3030 6364 d000 0278 0000 0000 0000 0000
00000f0 0000 0000 0000 0000 0000 0000 0000 0000
I found the answer. Something not mentioned in the docs I read was that the stream itself needs to be encoded as a list of CHUNKS. So every frame shall be one CHUNK. This is, of course, not necessary in principle, but seems to be a very common convention.

Converting RGB values in [0,1] range to high dynamic range (EXR format)

I just need some clarification on how to properly convert rgb pixel values in the range [0,1] to be in the right range for a HDR format like openEXR.
So I know for instance that when working with low dynamic range formats like PNG or JPG that only have 8 bits per channel, you simply have to multiply each rgb value by 2^8-1 = 255 and clamp so that all your values are in the range [0, 255].
OpenEXR and other HDR formats use a half precision format with 16 bits per channel. So do I just do the same thing as before and multiply each channel by 2^16-1 = 65535 so that my new range becomes [0, 65535]?
EDIT
So I tried doing what I wrote above but when I try to display the openEXR file in photoshop it is completely white. It seems like any value greater than around 10 or so is too bright for photoshop to display properly which I find very odd. So this doesn't seem like the correct way to do it unless there is something wrong with photoshops display.
We are dealing with three related but different issues at the same time.
The first issue is that of range: are channels stored as values in the range [0, 1] or [0, 255] or [0, 65535]. Scaling (multiplying and possibly clamping) is what you do to convert from one range to another.
The second issue is that of raw sample size: how many bits do you use to store the value. This doesn't necessarily have to be the binary logarithm of the size of the range. For example, if your range is [0, 255], you could store the values in 8 bits where the least significant bits represents increments of 1, or in 6 bits where the least significant bit represents increments of 4, or in 10 bits where the least significant bit represents increments of 0.25. In fact, as we will see in the next issue, the increments do not have to be fixed.
The third and final issue is that of encoding: fixed point or floating point. When we say that we store values of [0, 255] in 8 bits or values of [0, 65535] in 16 bits, we usually mean integer encoding (a special case of fixed point where the least significant bit represents fixed increments of 1). When values are stored in the range [0, 1] however, regardless of the raw sample size, usually this implies floating point storage (where most bits are used to store the significand, while a few bits are reserved to store the size of the increment associated with the least significant bit). When we speak of "half precision", "single precision", "double precision", "extended precision" and so forth we also invariably mean floating point encoding.
So here is the catch: OpenEXR uses floating point encoding, in a format that is not built in to most programming languages. Most modern languages only have 64-bit floats, and if they offer anything else it's usually 32-bit floats (respectively double and float in the C family), but 16-bit floats are almost never available out of the box.
Half precision can represent values in the range [-65505, 65504], with 11 bits (slightly better than 3 decimal digits) of precision, while also being able to represent values as small as 2^-14. However, given that OpenEXR is a HDR format, you are probably not really expected to use the entire range because the number encoding is chosen to accomodate for (extreme) over- or underexposure. That is, unless your camera actually produces such an enormous dynamic range of values.
So you might not actually need to scale your channel values. However, given that you already start with values in [0, 1], you probably have floating point numbers stored in single or double precision and you'll have to transcode them to half precision. Depending on the programming language, the libraries and even the hardware platform that you use, there might be an off-the-shelf solution or you might need to do some bit-fiddling of your own. As a starting point I can only offer you this DuckDuckGo search.
I'm too tired to think straight, but this may help you work it all out. I used ImageMagick to create three OpenEXR images, one white, one black and one red, all 1 pixel x 1 pixel.
convert -size 1x1! xc:white white.exr
convert -size 1x1! xc:black black.exr
convert -size 1x1! xc:red red.exr
Then I hexdumped them all:
xxd white.exr > white.txt
xxd black.exr > black.txt
xxd red.exr > red.txt
Here are the files:
White.txt
0000000: 762f 3101 0200 0000 6368 616e 6e65 6c73 v/1.....channels
0000010: 0063 686c 6973 7400 4900 0000 4100 0100 .chlist.I...A...
0000020: 0000 0000 0000 0100 0000 0100 0000 4200 ..............B.
0000030: 0100 0000 0000 0000 0100 0000 0100 0000 ................
0000040: 4700 0100 0000 0000 0000 0100 0000 0100 G...............
0000050: 0000 5200 0100 0000 0000 0000 0100 0000 ..R.............
0000060: 0100 0000 0063 6f6d 7072 6573 7369 6f6e .....compression
0000070: 0063 6f6d 7072 6573 7369 6f6e 0001 0000 .compression....
0000080: 0000 6461 7461 5769 6e64 6f77 0062 6f78 ..dataWindow.box
0000090: 3269 0010 0000 0000 0000 0000 0000 0000 2i..............
00000a0: 0000 0000 0000 0064 6973 706c 6179 5769 .......displayWi
00000b0: 6e64 6f77 0062 6f78 3269 0010 0000 0000 ndow.box2i......
00000c0: 0000 0000 0000 0000 0000 0000 0000 006c ...............l
00000d0: 696e 654f 7264 6572 006c 696e 654f 7264 ineOrder.lineOrd
00000e0: 6572 0001 0000 0000 7069 7865 6c41 7370 er......pixelAsp
00000f0: 6563 7452 6174 696f 0066 6c6f 6174 0004 ectRatio.float..
0000100: 0000 0000 0080 3f73 6372 6565 6e57 696e ......?screenWin
0000110: 646f 7743 656e 7465 7200 7632 6600 0800 dowCenter.v2f...
0000120: 0000 0000 0000 0000 0000 7363 7265 656e ..........screen
0000130: 5769 6e64 6f77 5769 6474 6800 666c 6f61 WindowWidth.floa
0000140: 7400 0400 0000 0000 803f 0053 0100 0000 t........?.S....
0000150: 0000 0000 0000 0008 0000 0000 3c00 3c00 ............<.<.
0000160: 3c00 3c <.<
Black.txt
0000000: 762f 3101 0200 0000 6368 616e 6e65 6c73 v/1.....channels
0000010: 0063 686c 6973 7400 4900 0000 4100 0100 .chlist.I...A...
0000020: 0000 0000 0000 0100 0000 0100 0000 4200 ..............B.
0000030: 0100 0000 0000 0000 0100 0000 0100 0000 ................
0000040: 4700 0100 0000 0000 0000 0100 0000 0100 G...............
0000050: 0000 5200 0100 0000 0000 0000 0100 0000 ..R.............
0000060: 0100 0000 0063 6f6d 7072 6573 7369 6f6e .....compression
0000070: 0063 6f6d 7072 6573 7369 6f6e 0001 0000 .compression....
0000080: 0000 6461 7461 5769 6e64 6f77 0062 6f78 ..dataWindow.box
0000090: 3269 0010 0000 0000 0000 0000 0000 0000 2i..............
00000a0: 0000 0000 0000 0064 6973 706c 6179 5769 .......displayWi
00000b0: 6e64 6f77 0062 6f78 3269 0010 0000 0000 ndow.box2i......
00000c0: 0000 0000 0000 0000 0000 0000 0000 006c ...............l
00000d0: 696e 654f 7264 6572 006c 696e 654f 7264 ineOrder.lineOrd
00000e0: 6572 0001 0000 0000 7069 7865 6c41 7370 er......pixelAsp
00000f0: 6563 7452 6174 696f 0066 6c6f 6174 0004 ectRatio.float..
0000100: 0000 0000 0080 3f73 6372 6565 6e57 696e ......?screenWin
0000110: 646f 7743 656e 7465 7200 7632 6600 0800 dowCenter.v2f...
0000120: 0000 0000 0000 0000 0000 7363 7265 656e ..........screen
0000130: 5769 6e64 6f77 5769 6474 6800 666c 6f61 WindowWidth.floa
0000140: 7400 0400 0000 0000 803f 0053 0100 0000 t........?.S....
0000150: 0000 0000 0000 0008 0000 0000 3c00 0000 ............<...
0000160: 0000 00 ...
Red.txt
0000000: 762f 3101 0200 0000 6368 616e 6e65 6c73 v/1.....channels
0000010: 0063 686c 6973 7400 4900 0000 4100 0100 .chlist.I...A...
0000020: 0000 0000 0000 0100 0000 0100 0000 4200 ..............B.
0000030: 0100 0000 0000 0000 0100 0000 0100 0000 ................
0000040: 4700 0100 0000 0000 0000 0100 0000 0100 G...............
0000050: 0000 5200 0100 0000 0000 0000 0100 0000 ..R.............
0000060: 0100 0000 0063 6f6d 7072 6573 7369 6f6e .....compression
0000070: 0063 6f6d 7072 6573 7369 6f6e 0001 0000 .compression....
0000080: 0000 6461 7461 5769 6e64 6f77 0062 6f78 ..dataWindow.box
0000090: 3269 0010 0000 0000 0000 0000 0000 0000 2i..............
00000a0: 0000 0000 0000 0064 6973 706c 6179 5769 .......displayWi
00000b0: 6e64 6f77 0062 6f78 3269 0010 0000 0000 ndow.box2i......
00000c0: 0000 0000 0000 0000 0000 0000 0000 006c ...............l
00000d0: 696e 654f 7264 6572 006c 696e 654f 7264 ineOrder.lineOrd
00000e0: 6572 0001 0000 0000 7069 7865 6c41 7370 er......pixelAsp
00000f0: 6563 7452 6174 696f 0066 6c6f 6174 0004 ectRatio.float..
0000100: 0000 0000 0080 3f73 6372 6565 6e57 696e ......?screenWin
0000110: 646f 7743 656e 7465 7200 7632 6600 0800 dowCenter.v2f...
0000120: 0000 0000 0000 0000 0000 7363 7265 656e ..........screen
0000130: 5769 6e64 6f77 5769 6474 6800 666c 6f61 WindowWidth.floa
0000140: 7400 0400 0000 0000 803f 0053 0100 0000 t........?.S....
0000150: 0000 0000 0000 0008 0000 0000 3c00 0000 ............<...
0000160: 0000 3c ..<
diff white.txt black.txt
22,23c22,23
< 0000150: 0000 0000 0000 0008 0000 0000 3c00 3c00 ............<.<.
< 0000160: 3c00 3c <.<
---
> 0000150: 0000 0000 0000 0008 0000 0000 3c00 0000 ............<...
> 0000160: 0000 00
The short answer is that this will probably not give you a useful result.
The moderately-long answer is that this approach makes a number of assumptions that are not at all "safe" with regard to image processing.
The primary assumption is that a Low Dynamic Range value of 255 represents an HDR value of 65535. The primary problem that HDR intends to solve is that real-world signals have to be compressed to a limited scope. Imagine taking a digital photograph of the sun directly: the input value for that light intensity is much greater than any imaging software supports, so it has to be compressed somehow. With LDR, the center of the sun's disk and much of the bloom around it will all be clamped to 255. With HDR, you're still clamping, but only to 65535. If you have a real-world signal which is giving values like 200, 255, 300 and 100,000, and then that gets clamped to 255, it should make sense that you cannot simply scale 255 to 65535 and get a reasonable result. That 255 might have been clamped from 256, or from 300, or from 100000; there's no way to know. (This is a radical oversimplification of imaging, but it should be sufficient for understanding this limitation in particular).
A secondary assumption is that what you see on your monitor has anything to do with the values in your image. The 0 - 65535 range of values in the image must be represented on your display, which is almost certainly limited to the sRGB spectrum (255). Mostly likely, if you've simply scaled 0-255 to 0-65535, then 99% of your range is above 255. So regardless of how much information is in your image, it's easy for it all to get clipped to "white."
Furthermore, depending on how Photoshop (or the GPU driver or the OS or the display panel) is translating your HDR 65535 into sRGB, it's just as likely that it's AGAIN being clamped to 255, or perhaps scaled "dumbly," or perhaps scaled "smartly," or any combination thereof. If Photoshop shows your image as solid white, you'll have to confirm a number of steps in the process to determine "who" in particular is transforming your color values, and how. Photoshop might be clamping before it sends to the OS. The OS might be clamping before it sends to the GPU. The GPU might be clamping when it sends to the display. The display might be clamping when it turns on the pixel. ...or any combination of clamping, scaling, and transforming at any of those steps (I know, not all of those combinations are actually possible, but the point is that there is a lot going on between the file and your eyeball).
Transforming LDR values to an HDR color space (and vice versa) is a non-trivial pursuit that represents a discipline unto itself. Depending on your application, you may need to do a great deal more research before you come to a good solution.

how to convert a binary file to human read able

I have a binary file of a Fortran program. For this binary file want to know the source coding of the Fortran program. By using hexdum -c I have converted the binary file to ascii file. Still it is not understandable. How to convert a binary file or ascii file to human readable format.
Below I have past the some portion of ascii file after doing hexdum -c
0003D80 0000 0000 0100 1300 8901 0000 D8B4 0408
0003D90 0000 0000 0100 1000 9701 0000 CCB5 0408
0003DA0 0000 0000 0100 1400 A301 0000 B09D 0408
0003DB0 0000 0000 0200 0C00 B901 0000 0000 0000
0003DC0 0000 0000 0400 F1FF BE00 0000 0000 0000
0003DD0 0000 0000 0400 F1FF EE00 0000 0000 0000
0003DE0 0000 0000 0400 F1FF B901 0000 0000 0000
0003DF0 0000 0000 0400 F1FF 0100 0000 0000 0000
0003E00 0000 0000 0400 F1FF 1000 0000 0000 0000
0003E10 0000 0000 0400 F1FF 0100 0000 0000 0000
0003E20 0000 0000 0400 F1FF 3E00 0000 0000 0000
0003E30 0000 0000 0400 F1FF B901 0000 0000 0000
0003E40 0000 0000 0400 F1FF E901 0000 0000 0000
0003E50 0000 0000 0400 F1FF F201 0000 00B1 0408
0003E60 1400 0000 0100 0F00 0302 0000 14B1 0408
0003EE0 1400 0000 0100 0F00 8B02 0000 B4B1 0408
0003EF0 1400 0000 0100 0F00 9C02 0000 C8B1 0408
0003F00 1400 0000 0100 0F00 AF02 0000 DCB1 0408
0003F10 1400 0000 0100 0F00 C202 0000 F0B1 0408
0003F20 1400 0000 0100 0F00 D502 0000 04B2 0408
0003F30 1400 0000 0100 0F00 E802 0000 18B2 0408
0003F40 1400 0000 0100 0F00 FB02 0000 2CB2 0408
There are decompilers which will attempt to generate source code from the binary, but it would not be the original source code. Meaning it would not have comments or local variable names. In order to get a decompiler for your binary though, you have to find out which compiler was used to generate it, then which architecture it was compiled for. The next step would be to search for a decompiler for that compiler, or a decompiler for that architecture which is similar enough to the compilation techniques used on the original compiler to generate reasonable source code.
The binary file you gave (since it's a compiled program) isn't just a binary representation of ASCII or any other text code. The reason is that It's machine code, meaning that it doesn't translate into anything human readable.
Some other people have mentioned, there are some decompilers which attempt to reverse the compile process (but those wouldn't give variable names and comments).
If it's an open source program you're trying to find the source code for, you should be able to find it somewhere online (like on sourceforge.net)

Understanding Camtasia Studio Hexadecimal Data

Camtasia Studio is a software package for recording screen captures. One thing it does, it records the mouse movement coordinates separately from the video of your screen. It does this so you can modify the appearance of the cursor after you are done recording.
Once you have recorded your screen, it has an option for exporting the raw components of your capture. One of the files contains the cursor coordinates which look like this...
4556 5453 0300 0000 0c00 0000 0c00 0000
ca00 0000 0c00 0000 0100 0000 0000 0000
8002 0000 e001 0000 1900 0000 cb00 0000
1900 0000 0100 0000 0000 0000 000c 0259
0000 0059 0014 0000 00e0 e8ab 096a 032d
08b8 0100 00c8 0000 0008 0000 0037 0000
00b0 feff ffef 0328 02d2 0100 00f0 0328
02d2 0100 00f1 0329 02e0 0100 00f2 032a
02e0 0100 00f5 032b 02ed 0100 00f8 032d
02ed 0100 00fb 032f 02fa 0100 0001 0432
02fa 0100 0007 0435 0208 0200 000e 043a
0208 0200 0018 043f 0215 0200 0023 0445
0215 0200 002e 044a 0215 0200 0039 0450
0215 0200 0046 0455 0215 0200 004f 0458
0215 0200 0056 045a 022c 0200 005d 045e
022c 0200 0063 0462 0242 0200 0068 0465
0242 0200 006f 046b 0258 0200 0072 046f
0258 0200 0079 0476 0280 0200 0082 047d
0280 0200 0089 0484 028c 0200 0091 048a
028c 0200 0098 0494 029a 0200 009e 049c
029a 0200 00a3 04a0 029a 0200 00a7 04a3
029a 0200 00aa 04a6 02aa 0200 00af 04ab
02bc 0200 00b2 04ae 02bc 0200 00b4 04b3
02bc 0200 00b8 04b7 02cc 0200 00be 04bd
02cc 0200 00c1 04bf 02dd 0200 00c3 04c1
02dd 0200 00c6 04c4 02f8 0200 00c9 04c6
02f8 0200 00cb 04c8 0205 0300 00cc 04c9
0213 0300 00cd 04c9 0213 0300 00cd 04ca
0220 0300 00ce 04cb 0221 0300 00ce 04cc
0221 0300 00ce 04cd 0236 0300 00ce 04ce
0236 0300 00cd 04cf 024d 0300 00cc 04d0
024d 0300 00cc 04d1 0262 0300 00cb 04d2
0262 0300 00cb 04d3 0279 0300 00ca 04d3
02a5 0300 00c9 04d3 0218 0000 0002 0000
000c 0000 0002 0000 0000 0000 0081 0404
0487 06a5 04a5 0300 00f8 0304 0487 06ba
040a 0000 0003 0000 000a 0000 0001 0000
0000 0000 0000 0008 0009 000c 0000 0001
0000 000c 0000 0001 0000 0000 0000 00ff
033b 027f 061b 040c 0000 0005 0000 000c
0000 0001 0000 0000 0000 0000 0000 00ff
ffff ff0c 0000 0004 0000 000c 0000 0001
0000 0000 0000 0001 0000 0000 0000 001c
0000 002d 0100 001c 0000 0001 0000 0090
0300 0000 0100 0079 0000 0044 0000 0000
0000 0000 0000 0000 0000 00
This is from a 1 second recording. The screen capture size was 640x480. I was moving the mouse from the top left corner to the bottom right corner.
So here is my question. Is there a way to translate this information to time and X, Y coordinates of the video? I guess I just don't understand the notation but I want to use this information for my own project. Can anyone make sense of this data?

Resources