When allocating a pbuf, the end of it is defined by the length passed to pbuf_alloc, while the start is defined by the layer: pbuf_alloc allocates a pbuf (or a chain) of length + layer offset. E.g. if you call pbuf_alloc(PBUF_IP, 10, PBUF_RAM), a pbuf with a total length of 10 + 20 + 16 = 46 bytes (your length + IP header + ethernet header), while the initial payload pointer points to 36 bytes after the actual reserved memory. This can later be adjusted by calling pbuf_header.

However, a pbuf cannot be lengthend at the end*: you have to allocate a new pbuf and chain the two to one packet. Doing that, tot_len of all pbufs in the chain will grow by 'len' of the newly chained pbuf. Theoretically, this could of course result in chains with tot_len > MTU + ethernet header, but a driver is not required to send this: the core code makes sure this does not happen!

Simon


John Kennedy wrote:
Ok, so what determines the length of a pbuf when it's allocated and what 
determines if pbufs are chained or not, and if chained will tot_len ever exceed 
the max Ethernet frame size?
Specifically, when sending an IP packet does lwip allocate a pbuf big enough 
for a max Ethernet frame then set tot_len to the actual packet length?



_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to