Smack 4.4.8: Request of Bob data from sender has a long wait to receive the replied Bob data

aTalk release 4.1.0 implements XEP-0264: Jingle Content Thumbnails support for File Transfer protocol in both:
a. XEP-0234: Jingle File Transfer
b. XEP-0096: SI File Transfer

Upon received of a File Transfer Request with thumbnail element, a Bob data request is sent. However it is found that the requester needs to wait ~16s before the bob data is received, if the thumbnail size is set to 128 x 96. This long wait is not practical, as the recipient will likely to click the Accept button before even the thumbnail is received and displayed.

Following are the logcats captured while carried out test with swan sending a file transfer request to swordfish.

// ========= File transfer requester swan ==========
07:58:37.582  D  Thumbnail byteData: 17910
07:58:37.622  D  SENT (0): 
                 <iq to='swordfish@atalk.sytes.net/atalk-1tsh01p' id='E33RP-32' type='set'>
                   <si xmlns='http://jabber.org/protocol/si' id='jsi_1400349419' mime-type='image/jpeg' profile='http://jabber.org/protocol/si/profile/file-transfer'>
                     <file xmlns='http://jabber.org/protocol/si/profile/file-transfer' name='1000001003.jpg' size='75036'>
                       <desc>
                         Sending file with thumbnail
                       </desc>
                       <thumbnail xmlns='urn:xmpp:thumbs:1' uri='cid:sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org' media-type='image/jpeg' width='128' height='96'/>
                     </file>
                     <feature xmlns="http://jabber.org/protocol/feature-neg">
                       <x xmlns='jabber:x:data' type='form'>
                         <field var='stream-method' type='list-single'>
                           <option>
                             <value>
                               http://jabber.org/protocol/bytestreams
                             </value>
                           </option>
                           <option>
                             <value>
                               http://jabber.org/protocol/ibb
                             </value>
                           </option>
                         </field>
                       </x>
                     </feature>
                   </si>
                 </iq>

07:58:37.751  D  RECV (0): 
                 <iq xml:lang='en' to='swan@atalk.sytes.net/atalk-1jgccqn' from='swordfish@atalk.sytes.net/atalk-1tsh01p' type='get' id='6YRF5-37'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org'/>
                 </iq>

07:58:37.849  D  SENT (0): 
                 <iq to='swordfish@atalk.sytes.net/atalk-1tsh01p' id='6YRF5-37' type='result'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org' max_age='86400' type='image/jpeg'>
07:58:37.849  D      /9j/4AAQSkZJRgABAQAAAQABAAD/kiqrWo5VZ27uuWdCy3jTJg+2n93tN0XuZjtnOT4/DVGBoRuFu2tHCowEGaVHh365w+HNl5T6vOja8rJ6McikR1aq/XWdtoL5/G2sxYFCDVELTqkLsFqKGcaNt2ZSFqu+1WqrYlltxsGzRfFW05qlypI37tqxqevF7N0QvWudUqf0YKCErsaTqkazEpmhyrHtg9qnqv6RyfXar5Z2/P6bkiYk8+a+kH6PNM1dO3GUxlhZYC705Y5bMIcJjMNZ/aLUcLf0qdrkKgx73H1ejXq0r2kbatbXFO7tqFRKyhCraLROutQ0c5a42+u7nM0M5eYrEVFy9/kro2SV8vYGrcWim8VFrvQSpaVFrpWo1Le4rI9JiRCyeSZM7y/yt3J59F1gfbnziJ8VVkd2tFjc3HI+pK5z4qxOtNC6T6UiMbYYxjZmo1G229DvkP+dtwLpYbxsucxsdVzmgzG80kxcjNzwDfslnnue7fFES81bP7/ABpyhuaUZ8K8KbFarNW8+T0G1N0fqfc0oY6evKbPD9P07b1poYrcFl4FXxuT5fU9ZsI+ORi/s+N7G/zYrFbI1yfJjmORPwgZLEF+eHKmkFxKRHD53zKyf6kbI4n/ACrr
                   </data>
// ========= File transfer recipient swordfish ==========
07:58:39.699  D  RECV (0): 
                 <iq xml:lang='en-US' to='swordfish@atalk.sytes.net/atalk-1tsh01p' from='swan@atalk.sytes.net/atalk-1jgccqn' type='set' id='E33RP-32'>
                   <si xmlns='http://jabber.org/protocol/si' id='jsi_1400349419' mime-type='image/jpeg' profile='http://jabber.org/protocol/si/profile/file-transfer'>
                     <file xmlns='http://jabber.org/protocol/si/profile/file-transfer' name='1000001003.jpg' size='75036'>
                       <desc>
                         Sending file with thumbnail
                       </desc>
                       <thumbnail xmlns='urn:xmpp:thumbs:1' uri='cid:sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org' media-type='image/jpeg' width='128' height='96'/>
                     </file>
                     <feature xmlns='http://jabber.org/protocol/feature-neg'>
                       <x xmlns='jabber:x:data' type='form'>
                         <field var='stream-method' type='list-single'>
                           <option>
                             <value>
                               http://jabber.org/protocol/bytestreams
                             </value>
                           </option>
                           <option>
                             <value>
                               http://jabber.org/protocol/ibb
                             </value>
                           </option>
                         </field>
                       </x>
                     </feature>
                   </si>
                 </iq>
                 
07:58:39.787  D  SENT (0): 
                 <iq to='swan@atalk.sytes.net/atalk-1jgccqn' id='6YRF5-37' type='get'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org'/>
                 </iq> 

07:58:55.231  D  RECV (0): 
                 <iq xml:lang='en-US' to='swordfish@atalk.sytes.net/atalk-1tsh01p' from='swan@atalk.sytes.net/atalk-1jgccqn' type='result' id='6YRF5-37'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org' max_age='86400' type='image/jpeg'>
07:58:55.231  D      /9j/4AAQSkZJRgABAQAAAQABAAD
/h6eCcvv8xywLvHdexktB2vmvPatPLZvLTqA571U+QqEDzagnLaExejxWdF0bpTb0oJc7bpRxztDjqNhssG88lv8ADN+MXAH+PpGl2XyXnA7LtHNOdbQlpx+DGUs3ntrIZu254y0WKiFiiT/sx1GqSLS3aowkZpxyhC07ZKURk85Mt+cAezvide6JtfEA9Dt+2YLP6jDiz+XzIuteiPRhsY3R38noRNjcAk/TISRSnzG1RmDnKyhHDLZl8H1hz+aJ0X80nxn5HgPKbt3bfEzoNbkvXcntedZLNcrLA9cOubAFohTIjKrm1yWrDkaw6y7QUtBpNatw0HqW47d6NX2SWat89qU+lTXI2y1bvJJStqSXeJmnb+rZoLR6ZqszVa71ytu3q1WqrUFSpWpAptKqULViSUdilE+o224Id1VgHDbAAtL0zvJVIC7VDkMQunY/yJfF7L4rmta15Z6gfotx1sbx4FequxB2ofvFL2izlUdVzdeiFIR6choRIob9CocPAw9fU5ppAy0wYlCD
07:58:55.269  D    </data></iq>

From above it is found that the requester swan sends the bob data immediately after received the bob data request from swordfish. However swordfish receives the requested bob data only after a wait
of ~16s. On further checking with ejabberd log data, it indicates that swan actually segmented the bob data in sending. This is the cause of the delay, even though ejabberd relays the bob data in a single stanza sending.

Please advice if there is a way to get bob data sending without data segmentation to avoid the long delay wait.

2024-05-13 07:58:38.270456+08:00 [notice] <0.4433.2> (tls|<0.4433.2>) Received XML on stream = <<"<iq to='swan@atalk.sytes.net/atalk-1jgccqn' id='6YRF5-37' type='get'><data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org'/></iq>">>

2024-05-13 07:58:38.281664+08:00 [notice] <0.4438.2> (tls|<0.4438.2>) Send XML on stream = <<"<iq xml:lang='en' to='swan@atalk.sytes.net/atalk-1jgccqn' from='swordfish@atalk.sytes.net/atalk-1tsh01p' type='get' id='6YRF5-37'><data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org'/></iq>">>

2024-05-13 07:58:38.306607+08:00 [notice] <0.4438.2> (tls|<0.4438.2>) Received XML on stream = <<"<iq to='swordfish@atalk.sytes.net/atalk-1tsh01p' id='6YRF5-37' type='result'><data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org' max_age='86400' type='image/jpeg'>/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3Nw

2024-05-13 07:58:45.351467+08:00 [notice] <0.4438.2> (tls|<0.4438.2>) Received XML on stream = <<"GPvj0lsMsSfxr8nfGZvCuq57CT2QhMHmOvcsN7HVc0rVNl2KlsHgCmIFIPo6EvFln3o8roKkRmqR1DcEKKx0SyTWjdG1McPGMhyjnnP69/qxbk0cW855mxM2eh2OHNWTgSbp5yDR1N4Fq7ppvF6qTmR0k2kQQDXKuHvH0muEl4ist8xba3IDKpIIEe5uw/I+Ij+R1Q2aye73XCll3R+wt+C8b2BFIHcxklpmSYInpWi

2024-05-13 07:58:53.544397+08:00 [notice] <0.4438.2> (tls|<0.4438.2>) Received XML on stream =
L2krFf8Au16NX0mhOodP0jtxWuNL4yzksbSndYasnrVKj1K9UMb5DurPULtIPuJIksehV03qZua+ldRV6hgeo2JyO4KoVVUA2pJCgAAlgADAHAl4uv8A5S4Ll3jH1ryUi8xfHnWN5iZoCKPLcuVsGNjsYyhUAOSzUl+9hjF3R6GJnFBctS6lG0Nv0UvzzsesaH+GUL2eTfMGRyr9GIwQb8FX5NcjsyaX+Pv369K5fkvpF9qn4y3+GPkHDLCrMHSWN0ci/JN7zn4qqfFGr6drkVfS+/f+ntU/f36/HQlx7C8PteJ/LoNJzrHePx7xiFS6+0dtGAu2KdJ6HoMwMz+/sMMgpyBKih+5ZZoI1K6OrXEWAlQOOCXsjQnWDJay1vbWOBucda5Cy1fWz1HJ4qpUxWS09bHDUquEvjSuri0bKC9yBuL6nRs6Nrjbe6u3rXaRRRKZZtdo3RmSr520yF9Z32nqOGvMXkkXJYjMBcg1LLWIq2tK5SwNra+hbNWu61zf1ra3Sjbud7MYH//Z</data></iq>

2024-05-13 07:58:53.572463+08:00 [notice] <0.4433.2> (tls|<0.4433.2>) Send XML on stream = <<"<iq xml:lang='en-US' to='swordfish@atalk.sytes.net/atalk-1tsh01p' from='swan@atalk.sytes.net/atalk-1jgccqn' type='result' id='6YRF5-37'><data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org' max_age='86400' type='image/jpeg'>/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAACRyWFlaAAABFAAAABRnWFlaAAABKAAAABRiWFlaAAABPAAAABR3dHB0AAABUAAAABRyVFJDAAABZAAAAChnVFJDAAABZAAAAChiVFJDAAABZAAAAChjcHJ0AAABjAAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEJYWVogAAAAAAAAb6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9YWVogAAAAAAAA9tYAAQAAAADTLXBhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABtbHVjAAAAAAAAAAEAAAAMZW5VUwAAACAAAAAcAEcAbwBvAGcAbABlACAASQBuAGMALgAgADIAMAAxADb/2w
sMMgpyBKih+5ZZoI1K6OrXEWAlQOOCXsjQnWDJay1vbWOBucda5Cy1fWz1HJ4qpUxWS09bHDUquEvjSuri0bKC9yBuL6nRs6Nrjbe6u3rXaRRRKZZtdo3RmSr520yF9Z32nqOGvMXkkXJYjMBcg1LLWIq2tK5SwNra+hbNWu61zf1ra3Sjbud7MYH//Z</data></iq>">>
1 Like

Could you show the ejabberd log line(s) that indicate that the data was segmented (I assume you are referring segmentation on the IP layer?).

Actually I have already included ejabberd log in my first comment. From the aTalk logcat, I can only see the initial Bob data sent by swan. To understand which is causing the delay, I proceeded to check the ejabberd log. Found that ejabberd was receiving the the Bob data sent from swan in 3 segments at ~7s interval. I have clean up, reformat with comment and attached the ejabberd log below.
I am not sure if there is an underlying handshakes between smack and ejabberd to segment the Bob data transfer; as I did not see ejabberd log on this process.

To confirm the observation, I change the thumbnail to png format, the bob size increases to >50K, and found it was again segmented into 7 instances, leading to ~48s delay in Bob data transfer.

// ======= ejabberd log with comments ========
// ==== ejabberd receives the stanza from swordfish for Bob request
2024-05-13 07:58:38.270456+08:00 [notice] <0.4433.2> (tls|<0.4433.2>)
Received XML on stream = 
<iq to='swan@atalk.sytes.net/atalk-1jgccqn' id='6YRF5-37' type='get'>
  <data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org'/>
</iq>

// === ejabbred relays the Bob request to swan ====. 
2024-05-13 07:58:38.281664+08:00 [notice] <0.4438.2> (tls|<0.4438.2>)
Send XML on stream = <iq xml:lang='en' to='swan@atalk.sytes.net/atalk-1jgccqn' from='swordfish@atalk.sytes.net/atalk-1tsh01p' type='get' id='6YRF5-37'>
  <data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org'/>
</iq>

// ==== Found smack segemented and sent the bob data to ejabberd on 3 instances, at ~7 seconds interval ====. 
2024-05-13 07:58:38.306607+08:00 [notice] <0.4438.2> (tls|<0.4438.2>) Received XML on stream =
<iq to='swordfish@atalk.sytes.net/atalk-1tsh01p' id='6YRF5-37' type='result'>
  <data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org' max_age='86400' type='image/jpeg'>
  /9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3Nw

2024-05-13 07:58:45.351467+08:00 [notice] <0.4438.2> (tls|<0.4438.2>) Received XML on stream = 
...
GPvj0lsMsSfxr8nfGZvCuq57CT2QhMHmOvcsN7HVc0rVNl2KlsHgCmIFIPo6EvFln3o8roKkRmqR1DcEKKx0SyTWjdG1McPGMhyjnnP69/qxbk0cW855mxM2eh2OHNWTgSbp5yDR1N4Fq7ppvF6qTmR0k2kQQDXKuHvH0muEl4ist8xba3IDKpIIEe5uw/I+Ij+R1Q2aye73XCll3R+wt+C8b2BFIHcxklpmSYInpWi

2024-05-13 07:58:53.544397+08:00 [notice] <0.4438.2> (tls|<0.4438.2>) Received XML on stream =
  ...
  C9yBuL6nRs6Nrjbe6u3rXaRRRKZZtdo3RmSr520yF9Z32nqOGvMXkkXJYjMBcg1LLWIq2tK5SwNra+hbNWu61zf1ra3Sjbud7MYH//Z
 </data>
</iq>

// ==== ejabberd immediately relay all Bob data to swordfish on complete received of the Bob data from swan === 
2024-05-13 07:58:53.572463+08:00 [notice] <0.4433.2> (tls|<0.4433.2>) Send XML on stream =
<iq xml:lang='en-US' to='swordfish@atalk.sytes.net/atalk-1tsh01p' from='swan@atalk.sytes.net/atalk-1jgccqn' type='result' id='6YRF5-37'>
  <data xmlns='urn:xmpp:bob' cid='sha1+5222d9938627302cc16ac8a7b587be40880b1dc8@bob.xmpp.org' max_age='86400' type='image/jpeg'>
  /9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZ
  ....
  OGvMXkkXJYjMBcg1LLWIq2tK5SwNra+hbNWu61zf1ra3Sjbud7MYH//Z
  </data>
</iq>

I found that the sent stanza segmentation also happens for other xmpp protocols with large data transfer i.e.
a. Avatar data
b. vCard BINVAL

I did an estimation of each segment data size received by ejabberd (based on its log), found that each is ~8K; and each segment send interval is 7~9s, except in the case for Avatar data second data segment which occur in ms.

Base on Maximum Packet Size for a TCP Connection, it states the TCPIP max data size is 64K. Not sure if smack has limited its send data buffer size to only 8K.

1. Introduction

Transmission Control Protocol (TCP) is helpful to send a file or message over a connected network. Each file gets divided into packets at the sender network. The packets get merged on arrival at the receiving network. The maximum size of a TCP packet is 64K (65535 bytes). Generally, the packet size gets restricted by the Maximum Transmission Unit (MTU) of network resources. MTU is the maximum size of the data transfer limit set by hardware in a network. The packet size should never exceed MTU . In this tutorial, we’ll try to explain the concept behind each of these terms and explore various aspects of it.

// ======= Avatar segmented byte size = 8K ======
2024-06-03 06:37:20.490915+08:00 [notice] (tls|<0.11992.1>) Received XML on stream = <<"<iq id='DFLCV-36' type='set'><pubsub xmlns='http://jabber.org/protocol/pubsub'><publish node='urn:xmpp:avatar:data'><item id='e068b4aafe48bf1943f2a0707b18146b8dc5bc63'><data xmlns='urn:xmpp:avatar:data'>iVBORw0KGgoAAAANSUhEUgAAAGwAAABsCAIAAAAABMCaAAAAAXNSR0IArs4c6QAAAANzQklUCAgI\n2+FP4AAA

2024-06-03 06:37:20.496760+08:00 [notice] (tls|<0.11992.1>) Received XML on stream = <<"4N3Q+OYwRZACIIeO8H\nAMVQoL2N3hNkheDYBBZrrPchNsSugjhfBFItgf7k5384tf6YG2692qQzjcZsEOS+CIo9BMJKxEiI\n4Vn5XDiK

2024-06-03 06:37:27.689317+08:00 [notice] (tls|<0.11992.1>) Received XML on stream = <<"McePOW2+Bimw6a+Fn42o2o8W7t13+7Q9OW2QKqL3RorTG3lqtyfLHGXl9H0l+bzK/\nwky7Hzb5ZVbdLzsJrQE3wXQcyNwXEyaliRSpyd51PmjDIsTCBKUUSKmJsyiKEBNUWZZxYilLxcOL\nUkoVzrug0kR3R/6elVE81QgVvvSNy4Lu5M50V3cBXkdxHIKUeadF1vc+9e/vTgSoYBOoSNX5SGeT\nPrT95PTYyn4wbt9DOb7gPnYiA2ujStcuOw5X1K6IIwOQiFF
...
RgAAAAASUVORK5CYII=</data></item></publish></pubsub></iq><r xmlns='urn:xmpp:sm:3'/>">>


// ======= vCard BINVAL segmented byte size = 8K ======
2024-06-03 06:37:31.980172+08:00 [notice] (tls|<0.11992.1>) Received XML on stream = <<"<iq id='DFLCV-35' type='set'><vCard xmlns='vcard-temp'><BDAY>Dec 18, 1992</BDAY><PHOTO><BINVAL>iVBORw0KGgoAAAANSUhEUgAAAGwAAABsCAIAAAAABMCaAAAAAXNSR0IArs4c6QAAAANzQklUCAgI2+FP4AAAIABJREFUeJzkvXm0ZVV1L/ybq9ndae499966VVRDAdIjGOyb2CRqlNjEJsRANMHmJRoTu4yo70kiMcZgfCbRaOKz1xg/

2024-06-03 06:37:40.172978+08:00 [notice] (tls|<0.11992.1>) Received XML on stream = <<"RWldSsM61aS+aIqBj0QvA+a/Q+u2T0Kf2RiVWmKycWIdRoRgoJwCEoZiBrXBpp90m0fKkrWSkYFwKSRjrFm900qUNfYcVJgquCZFMBKj8qqmaTwVdbK7unhixf8pM/N/33W+5sbj2CKvJjuaJA0lBAI

2024-06-03 06:37:48.364488+08:00 [notice] (tls|<0.11992.1>) Received XML on stream = <<"lf+dTpzlIqm47Sx7Rc3TWUmFue6uS9X3/bXf/zyUx/dtFAeDYVIAaGC1mNnSdbU2X7Ju1+DCU37ZCNkzUUkjM1ohjHwDGNgI8sInkWzIQUCfP
....
AAASUVORK5CYII=</BINVAL><TYPE>image/jpeg</TYPE></PHOTO></vCard></iq><a xmlns='urn:xmpp:sm:3' h='47'/>">>

At this point a tcp dump would be helpful. Especially the timing of the arrival of the ACKs of those 8 KiB TCP packets would be interesting. But maybe it reveals also something else.

No, Smack has no such limit. At least directly. I could speculate that 8 KiB is the limit of a involved BufferedWriter, as it is exactly 2x 4 KiB pages. But even if it is the case, then there is probably something additionally going on, like a delayed ACK.

Test Setup:
a. Swan (file sender) on android AVD API-34 running on Ubuntu 22.05
b. Swordfish (file recipient) on android Note10+ device
c. ejabberd server on host with Ubuntu 20.04
d. WireShark app is running on Swan Ubuntu Host

The Thumbnail send file size : image/png 128x96;
Below are all the log info for your analysis:

// =========== swordfish - file recipient ==========
// swordfish - recipient
07:14:43.505  D  SENT (0): 
                 <iq to='swan@atalk.sytes.net/atalk-23mgn7a' id='6XTWH-56' type='get'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+389ab700eb3c8a9b8c6b99bb600fbe7691a03832@bob.xmpp.org'/>
                 </iq>
07:14:48.912  D  RECV (0): 
                 <iq xml:lang='en-US' to='swordfish@atalk.sytes.net/atalk-kok1g0' from='swan@atalk.sytes.net/atalk-23mgn7a' type='result' id='6XTWH-55'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+389ab700eb3c8a9b8c6b99bb600fbe7691a03832@bob.xmpp.org' max_age='86400' type='image/png'>
07:14:48.912  D      /9j/4AAQSkZJRgABAQAAAQABAAD ..... +PW6q+hyLXyfhHI</data>

// =========== swan - file sender (Thumbnail ~12KB) ==========
07:14:42.910  D  RECV (0): 
                 <iq xml:lang='en' to='swan@atalk.sytes.net/atalk-23mgn7a' from='swordfish@atalk.sytes.net/atalk-kok1g0' type='get' id='6XTWH-56'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+389ab700eb3c8a9b8c6b99bb600fbe7691a03832@bob.xmpp.org'/>
                 </iq>
07:14:42.936  D  SENT (0): 
                 <iq to='swordfish@atalk.sytes.net/atalk-kok1g0' id='6XTWH-56' type='result'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+389ab700eb3c8a9b8c6b99bb600fbe7691a03832@bob.xmpp.org' max_age='86400' type='image/png'>
07:14:42.936  D      /9j/4AAQSkZJRgABAQAAAQABAAD .... </data>

For this test, the file send is formatted as png with 128x96. The file size captured on ejabberd is
a. File send from swan: Size = 6937
b. File Relay to swordfish: Size = 23120

Because the generated thumbnail size < 8K, swan actual upload to ejabberd in one single transaction ~5s after received Bob request from swordfish. It seems that ejabberd performs some image conversion before relay the thumbnail to swordfish.
Note: the thumbnail file is pre-generated before file send request is initiated.

Will do another test with image/jpeg format to see the difference if any.

// ===== ejabberd log =====
2024-06-05 07:14:43.239412+08:00 [notice] (tls|<0.6290.0>) Received XML on stream = "<iq to='swan@atalk.sytes.net/atalk-23mgn7a' id='6XTWH-56' type='get'><data xmlns='urn:xmpp:bob' cid='sha1+389ab700eb3c8a9b8c6b99bb600fbe7691a03832@bob.xmpp.org'/></iq>"

2024-06-05 07:14:43.252622+08:00 [notice] (tls|<0.6283.0>) Send XML on stream = "<iq xml:lang='en' to='swan@atalk.sytes.net/atalk-23mgn7a' from='swordfish@atalk.sytes.net/atalk-kok1g0' type='get' id='6XTWH-56'><data xmlns='urn:xmpp:bob' cid='sha1+389ab700eb3c8a9b8c6b99bb600fbe7691a03832@bob.xmpp.org'/></iq>"

2024-06-05 07:14:48.491390+08:00 [notice] (tls|<0.6283.0>) Received XML on stream = "Av8/8/wBn/wCfrk/1H4bzYLY8wEsVNWa4eNSxDwmCsqKrnH/jVj+HEnSmiQRJba1NEbHkdrQ93KlkTDhOz1i2jaCa1F/

2024-06-05 07:14:48.518206+08:00 [debug] Flushing packets of swan@atalk.sytes.net from CSI queue of swordfish@atalk.sytes.net/atalk-kok1g0
2024-06-05 07:14:48.518891+08:00 [notice] (tls|<0.6290.0>) Send XML on stream = "<iq xml:lang='en-US' to='swordfish@atalk.sytes.net/atalk-kok1g0' from='swan@atalk.sytes.net/atalk-23mgn7a' type='result' id='6XTWH-55'><data xmlns='urn:xmpp:bob' cid='sha1+389ab700eb3c8a9b8c6b99bb600fbe7691a03832@bob.xmpp.org' max_age='86400' type='image/png'>/9j/4AAQSkZJRgA...NWaiK6Cn//2Q==</data></iq>"

Pcap captured IP Address:port info:
a. 202.166.54.243:5222 (ejabberd server)
b. 192.168.194 (swan)
c. 192.168.1.167 (swordfish)

swan_sender_pcap.pcapng (63.1 KB)

File transfer info: Setup as before. swan => swordfish
a. Thumbnail file size = 39352 bytes (image/jpeg)
b. No image file conversation found at ejabberd
d. ejabberd receive data in 4 segmentation
e. Delay in thumbnail received by swordfish after Bob request: ~23s

// =========== swordfish - file recipient ==========
// swordfish - recipient
10:06:36.203  D  SENT (0): 
                 <iq to='swan@atalk.sytes.net/atalk-kkvbff' id='KMXZM-37' type='get'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+d6dc2496d08c5428dadb817cb61927391507996c@bob.xmpp.org'/>
                 </iq>
10:06:59.583  D  RECV (0): 
                 <iq xml:lang='en-US' to='swordfish@atalk.sytes.net/atalk-18s3579' from='swan@atalk.sytes.net/atalk-kkvbff' type='result' id='KMXZM-37'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+d6dc2496d08c5428dadb817cb61927391507996c@bob.xmpp.org' max_age='86400' type='image/jpeg'>
10:06:59.583  D      /9j/4AAQSkZJRgABAQAAAQABA .... nOFr/FTJeFOkGD4Xexfq9ZBUAf+FKuMT49lFO2rWxWi6TVgD8fNhDbdFRt2
                  </data>


// =========== swan - file sender ==========
10:06:35.078  D  RECV (0): 
                 <iq xml:lang='en' to='swan@atalk.sytes.net/atalk-kkvbff' from='swordfish@atalk.sytes.net/atalk-18s3579' type='get' id='KMXZM-37'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+d6dc2496d08c5428dadb817cb61927391507996c@bob.xmpp.org'/>
                 </iq>
10:06:35.259  D  SENT (0): 
                 <iq to='swordfish@atalk.sytes.net/atalk-18s3579' id='KMXZM-37' type='result'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+d6dc2496d08c5428dadb817cb61927391507996c@bob.xmpp.org' max_age='86400' type='image/jpeg'>
                     /9j/4AAQSkZJRgABAQAAAQABAAD...
                   </data>

swan_sender_pcap_2.pcapng (60.0 KB)

// =========== ejabberd log ==========
2024-06-05 10:06:35.517333+08:00 [notice] (tls|<0.682.0>) Send XML on stream =
<iq xml:lang='en' to='swan@atalk.sytes.net/atalk-kkvbff' from='swordfish@atalk.sytes.net/atalk-18s3579' type='get' id='KMXZM-37'><data xmlns='urn:xmpp:bob' cid='sha1+d6dc2496d08c5428dadb817cb61927391507996c@bob.xmpp.org'/></iq>

2024-06-05 10:06:35.553097+08:00 [notice] (tls|<0.682.0>) Received XML on stream =
<iq to='swordfish@atalk.sytes.net/atalk-18s3579' id='KMXZM-37' type='result'><data xmlns='urn:xmpp:bob' cid='sha1+d6dc2496d08c5428dadb817cb61927391507996c@bob.xmpp.org' max_age='86400' type='image/jpeg'>
/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1...

2024-06-05 10:06:42.332253+08:00 [notice] (tls|<0.682.0>) Received XML on stream =
1toKkqlrjSrtuSh1EZ4NzNJSeoLyXIarJcAZQYbhSzFY2KYnQQ1EHNoJKfFTv3sBXR+Z+NzM2z20K25JT1Jq6teZsuaQfg2vlc8FSUA1SKOIKrFY5NjgY8783qKml...

2024-06-05 10:06:50.525184+08:00 [notice] (tls|<0.682.0>) Received XML on stream =
/t52gLCMBMMlCSJCmOZjDDBS8F5idgQxE+/uze7J1KlyVtGGzo6zepZ67UEdyI0wohBKlKErHYxHM6JxZeyOO/aH6nQILH9MpjFVibMdIFSZ7btdI8lNlsuavAM57....

2024-06-05 10:06:58.718099+08:00 [notice] (tls|<0.682.0>) Received XML on stream =
OBN0whZu3I1E4TL4KHCP1tk+yg/NFRbTNfwFrSbUIVW8jrKgA7B08Xy+HxXSiTw....IDBmDC30Hyx//9k=</data></iq>

2024-06-05 10:06:58.751052+08:00 [notice] (tls|<0.683.0>) Send XML on stream = <iq xml:lang='en-US' to='swordfish@atalk.sytes.net/atalk-18s3579' from='swan@atalk.sytes.net/atalk-kkvbff' type='result' id='KMXZM-37'><data xmlns='urn:xmpp:bob' cid='sha1+d6dc2496d08c5428dadb817cb61927391507996c@bob.xmpp.org' max_age='86400' type='image/jpeg'>/9j/4AAQSkZJRgAB
XK/ehp3v8AEB6PDbHymACulgAxIDBmDC30Hyx//9k=</data></iq>

Attached is the pcap captured on ejabberd server (at different file transfer instance), but with similar setup except: Swordfish (sender) => swan (recipient).

192.168.1.8 => ejabberd local IP
202.166.54.243 => ejabberd public IP.

ejabberd_pcap.pcapng (90.3 KB)

On further investigation, it seems the problem is with ejabberd. I have just raised a bug report ticket with ejabberd team for their investigation.

Request of Bob data from sender has a long wait to receive the replied Bob data #4230

The problem is resolved. It lies in the ejabberd.yml ‘shaper#normal’ configuration setting.

###.  ===============
###'  TRAFFIC SHAPERS

shaper:
  ##
  ## The "normal" shaper limits traffic speed to 3000 B/s (Default)
  ##
  normal: 50000

  ##
  ## The "fast" shaper limits traffic speed to 100KB/s
  ##
  fast: 100000

  ##
  ## The "proxyrate" shaper limits traffic speed to 200 KBytes/sec
  ##
  proxyrate: 204800

###.  ============
###'  SHAPER RULES

shaper_rules:
  ## For C2S connections, all users except admins use the "normal" shaper
  c2s_shaper:
    - none: admin
    - normal: all
  ## All S2S connections use the "fast" shaper
  s2s_shaper: fast

  ## proxy shaper settings
  proxy65_shaper:
    - none: admin
    - proxyrate: proxy_users

Earlier ‘normal’ value was set to 1000 B/s. Changing this value to 50000 B/s improves the reply time to be <1s. Thumbnail byteData size: 31786

08:36:37.764  D  SENT (0): 
                 <iq to='swordfish@atalk.sytes.net/atalk-2lqn7ri' id='YYYDT-37' type='get'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+ed064968b0d058efced093d9466dd32254c13e0c@bob.xmpp.org'/>
                 </iq>

08:36:38.027  D  RECV (0): 
                 <iq xml:lang='en' to='swan@atalk.sytes.net/atalk-3c04nc9' from='swordfish@atalk.sytes.net/atalk-2lqn7ri' type='result' id='YYYDT-37'>
                   <data xmlns='urn:xmpp:bob' cid='sha1+ed064968b0d058efced093d9466dd32254c13e0c@bob.xmpp.org' max_age='86400' type='image/png'>
                     iVBO ... umrgAAAABJRU5ErkJggg==
                   </data>
                 </iq>