I'm writing some server software that upgrades the firmware on an electronic device. It's a tricky task, because currently these devices don't have enough memory to hold a full firmware before installing it. As a result my server will switch the device into boot loader mode, and instruct the boot loader what to do, sending instructions and firmware data over the network. As you can imagine, there are some potentially massive downsides to this.
What I'm concerned with at the moment, is whether or not a single TCP segment that I send will be divided up across multiple Ethernet frames?
Due to the nature of the boot loader, the maximum size payload I can send in a TCP segment is 255 bytes.
From grabbing packets in Wireshark, it seems like the Frame size for a frame containing one of my TCP segments is 309 bytes (2,472 bits), well within the range allowed according to the Wikipedia page on Ethernet Frames :
I'm currently trying to handle what happens if the connection to the device is severed. As things are now I have no trouble reestablishing a connection with a device, but what I want to be sure of is what happens after a connection is reestablished.
If I can be sure that each instruction will always be contained in a single Ethernet frame, and as such, will either be delivered or won't be delivered then happy days! I can look at the last instruction sent and figure out what to do then.
However, if there's a possibility that the instruction can be split across two Ethernet frames then I have a much bigger problem. I don't think it should happen, but it sometimes looks like it does when I'm testing.
Say I have issued a write command, and the boot loader is waiting for data to write, I send my TCP segment with 255 bytes and it gets split across two Ethernet frames. The first frame gets delivered but the second one doesn't. Now when I reconnect I have to figure out exactly how many bytes the boot loader has already received, which means I need to push dummy data and listen for a response. I'd really like to avoid that if possible.
Reading from the comments in this thread, it seems that IP packets smaller than 576 bytes (4,608 bits) won't be split up. Am I safe in assuming that this is always the case?
Actually, If it is split up, then the WiFi module shouldn't deliver the TCP segment until it has been re-assembled, isn't that correct? And it will be discarded if the connection is lost.