Reputation: 1
I had written a code for micro-controller in which HTML text is sent on a LAN to browser via Ethernet,the code works fine until the Ethernet frame size exceed to 1500 bytes.
Is there any way of sending HTML text to browser successfully in a fragments via Ethernet?
CASE: If text is fragmented prior sending! The Browser in this case only display's first part of text fragment. While the rest fragments aren't updated on the browser.
Any support in this regard would be appreciated!
Upvotes: 0
Views: 343
Reputation: 5457
I'm assuming you are using a TCP stack and have not attempted to write the TCP/IP headers directly with your own code on the device. Then your problem most likely has to do with the Ethernet MTU (maximum transmission unit).
MTU is the maximum payload that can be transmitted (and received) by all devices on the network. Typical MTU size is 1500 bytes, but unfortunately it is common to have networks that require a lower MTU (e.g. when PPPoE or VLAN headers get added at some point). Usually it is just a configuration problem. Most Ethernet hardware supports MTUs well over 1500 bytes.
What usually happens is that as soon as TCP attempts to send a packet that is too large, it gets dropped at some point (sender, receiver, switch or router). A packet sniffer like Wireshark will do TCP analysis and tell you about suspected packet loss and TCP retransmission attempts.
It's TCP that is is splitting a stream into packets, so the TCP stack needs to know what the MTU is. On Linux the TCP stack it will get this setting from the network interface. You can see the current value with ip link
or ifconfig
. It needs to be configured on both sides of TCP the connection, but your problem should go away by just setting a lower MTU in the TCP stack of the embedded device.
In addition to that, IP fragmentation can happen when a router wants to forward a frame from a network with high MTU to a network with lower MTU (or if it has added another Ethernet header, and the frame is now too large). Unless you are using a very poorly implemented IP stack that doesn't support fragmentation, this should not be a problem. (But it's wasting bandwidth.) Depending on the flags, the router may then send an ICMP message to notify the sender about the problem. But if there is a firewall in-between that drops ICMP packets this will not work, and result in retransmission attempts without lowering the MTU.
Upvotes: 1