Re: BSD Sockets in mainline, and how that affects design decisions for the rest of IP stack (e.g. send MTU handling)
Tomasz Bursztyka
On 26/10/2017 14:37, Paul Sokolovsky wrote:
Hello Tomasz,I was indeed only responding on MTU handling (as both PR do in a way). There're definitely a lot to improve and optimize in our IP stack, andAs I am not using at all user APIs, I can't tell what would be the best. But the issue is mostly found in the API usage it seems. On socket you have one opaque type to access the network and read/write on it. The data buffer is then split in two: user has to manage his raw data in his own buffers, (and take to/from it when receiving/sending) where the actual network data (encapsulated raw data) is handled behind by socket on send/recv. Both sending/receiving logic is easy, as long as you have enough memory for user's buffer. In zephyr, both are directly found at once in net_pkt. The user does not have to create its own buffers: he just has to pick from net slabs, populate it, finalize and done. From a memory usage point of view, the later is easier and more efficient as long as the net stack is doing it well, obviously, like properly handling MTU, etc... but mostly on _tx_ only. On rx, as the data is scattered around buffer fragments, it requires the user do add logic on his side to parse the received data (the encapsulated one). Thus the net_frag_read() and derived functions. Which can be a bit complicated to grasp I guess. About the "mini-inifinite", that's up to the user to handle net_pkt_append() returned amount. A bit like send() in socket. Though the difference here if of course data still needs to be send. As I did change net_nbuf to net_pkt, my point doing it was exactly that net_pkt should represent one unique IP packet. So from that, I would say net_pkt_append() must not go over MTU. Note however that this MTU can be either HW MTU or IP based one. For instance on 15.4/6lo you don't want to limit IPv6 packets on HW MTU, but you use this IPv6 (minimum) size of 1280 bytes which in turn is fragmented through 6lo to fit in as many as necessary 15.4 frames. But if not using 6lo, it would need to use HW MTU only. (There is a possibility to handle bigger IPv6 packets through IPv6 fragmentation, I can't remember is that generates as many net_pkt as necessary, or if it does all on one which would go against net_pkt usage) As I am not working against user API, I don't have good overview on how it's supposed to work. Well, maybe my blabbering can help you guys to decide which way should be the best. Tomasz
|
|