uModbus icon indicating copy to clipboard operation
uModbus copied to clipboard

Can i control if single or multiple Modbus payloads are in a single TCP frame?

Open StefanR71 opened this issue 1 year ago • 2 comments

Hi,

i'm using the modbus-cli which uses uModbus.

When i'm doing a query for some registers, modbus-cli is grouping this registers and i need perhaps 3 modbus requests. This 3 requests will be put in 2 TCP packets, the first TCP packet has one Modbus payload and the second TCP packet contains the last 2 Modbus payloads.

image

Who is controlling the creation of the TCP packets?

Can i change here something, that each Modbus packet is getting a own TCP packet?

And this is every time the same, ich have every time 2 TCP packets, the first TCP packet has every time one Modbus packet inside and the second TCP packet has all the rest inside, i have seen up to 19 Modbus packets here in my tests.

Best Regards Stefan

StefanR71 avatar Mar 07 '24 14:03 StefanR71

Just as a heads-up, this project seems currently abandoned. I haven't got feedback on my issues and pull requests for a couple of years, so I don't expect anyone to jump in and answer your questions.

As to your actual matter, sorry I can't help you much, having used only the RTU version so far. But in principle, TCP is a stream protocol, not packet-oriented. The operating system's network stack usually decides where to cut off that stream and push it into an underlying IP packet. The logic / heuristics for that can be buried quite deeply. If you can trace it down to actual network writes to the TCP socket within the Python code, that would of course be a natural opportunity to split at. But as long as TCP is not directly implemented in Python, it could be unpredictable, with shorter packets or even waiting to assemble longer packets.

Sorry if that doesn't really help you. Hope someone more knowledgeable will turn up ;-)

acolomb avatar Mar 07 '24 14:03 acolomb

No problem, this are already some helpful comments, perhaps someone else has seen a similar behavior and found a solution.

So let's see if someone else has a comment or hint to this problem.

StefanR71 avatar Mar 07 '24 15:03 StefanR71