Can you control packet size on the Arduino WiFi shield?

Hello everyone,

I want to control the size of the packets that I send over a server. Is it possible to do so on the Arduino Uno. If so, what code or functions should I use?

Thank You!

Is it possible to do so on the Arduino Uno. If so, what code or functions should I use?

Yes.

client.print("This sends a small packet");

client.print("This sends a much larger packet, since there is more data to put in the packet");

Now, what is it you really want to do?

My project is a bit sophisticated, but loosely I'm trying to optimize computer networks with machine learning algorithms. I want to specifically calculate the most efficient size of a packet to lower energy consumption and time when communicating via wireless networks. I wanted to test this idea on the Arduino WiFi shield however, there seems to be no function that calculates energy consumption(and I'm afraid there might not be enough parameters for me to test this through the shield). I am not sure how I can vary the size of a packet because I am not sure where to find tutorials or books about using the shield.

Thank you for the help, are there any example of this in code?

I am not sure how I can vary the size of a packet because I am not sure where to find tutorials or books about using the shield.

If the wifi shield uses a w5100 chip, then you might study the datasheet for that chip. The last time I looked at the w5100 datasheet, it appeared to be quite extensive.

Hi

I think packet size is primarily a function of your network - my ADSL router/modem uses a packet size (MTU - maximum transmission unit) of 1458 bytes.

With the W5100 you can halve (or quarter) the number of sockets and double (or quadruple) the size of the transmit and receive socket buffers accordingly.

But it does not seem to make a significant difference. My testing indicates that the W5100 processes incoming data one packet at a time and via handshaking does not allow additional packets into its receive buffer - even if you increase buffer size and there is plenty of room.

The W5100 socket buffers are circular. Using handshaking the W5100 seems to process only one packet at a time to prevent a second packet wrapping around in the buffer and overwriting unprocessed data for the previous packet.

I am not a complete expert on this - I came to the above conclusions while testing file uploads (which involve large numbers of incoming packets) for four and two socket setups on my W5100. The W5100 seems to process each incoming packet very quickly but then goes into a quite long wait period where is sends a ready handshake command back to your network and then waits for the next packet of data to arrive.

The net effect is that file uploads are quite slow (but file downloads are very fast because your network devices are more sophisticated and can buffer lots of data packets and the W5100 can send the data quickly) and I cannot work out anyway to overcome the issue on the W5100.

Cheers

Catweazle NZ