Asterisk 11.3: reading SIP-I over TCP

I was successful in setting up Asterisk 11.3 & SIP-I (over UDP)

now I am trying to do the same BUT over TCP.

my asterisk-i box is unable to read complete INVITE packet over TCP, though the pcap file shows the complete packet.

I added verbose [ast_verb] to chan_sip and attached are the logs + pcap
the log file also contains the relevant modified chan_sip functions (check_message_integrity, sip_tcp_read) with verbose.

https://github.com/alticelabs/asterisk-i/files/636169/issue_sip_over_tcp.txt
https://github.com/alticelabs/asterisk-i/files/636193/20161207115920_sip.zip

any clue on how to fix this will be highly appreciated.

following lines from the log file are of interest

   >  :::: sip_tcp_read while MESSAGE_FRAGMENT read data size is 1789

then the entire INVITE (read from socket is printed)
and then this read buffer is appended to &req->data
now the size is reduced :frowning:
> :::: sip_tcp_read > 1719

where does the 70 odd bytes go !!!