Do not fragment (DF) in a UDP transmission.

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Do not fragment (DF) in a UDP transmission.

Roger Cover
Greetings,

I am writing a video transmitter. The protocol I am using requires that a "test packet" has its do not fragment bit set. This is used to determine the maximum usable MTU of the intervening network nodes.

I would like to know the recommended method for setting this bit in my UDP transmission. I am currently using the ip_output_if() function, and it does not have any arguments to allow this.

Regards,
Roger W. Cover
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Do not fragment (DF) in a UDP transmission.

goldsimon@gmx.de
Am 06.03.2020 um 21:37 schrieb Roger Cover:
> Greetings,
>
> I am writing a video transmitter. The protocol I am using requires that a "test packet" has its do not fragment bit set. This is used to determine the maximum usable MTU of the intervening network nodes.
>
> I would like to know the recommended method for setting this bit in my UDP transmission. I am currently using the ip_output_if() function, and it does not have any arguments to allow this.

That's currently not supported (hasn't been requested so far). If you
tell me a standard way to do that (e.g. how is it done on sockets), I
guess adding this should not be too hard.

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Do not fragment (DF) in a UDP transmission.

Roger Cover
Greetings Simon,

The Linux man pages mention the IP_PMTUDISC_DO flag that "forces the don't-fragment flag to be set on all outgoing packets" in the setsockopt() description.

The documentation for setsockopt() for BSD 4.3 lists the similar flag "IP_DONTFRAG", with the qualifier "This option is supported for sockets with an address family of AF_INET and type of SOCK_DGRAM or SOCK_RAW only."

The Microsoft documentation at: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options lists an option called IP_DONTFRAGMENT, about which they state "Microsoft TCP/IP providers respect this option for UDP and ICMP."

There is also a reference for the .NET framework at https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.dontfragment?view=netframework-4.8 if you have any interest in that.

There is also a comment I do not completely understand in the lwIP ip.c file (line 790 in the ip_output_if() function, version 1.4.1) that states "don't fragment if interface has mtu set to 0."

I am not very familiar with sockets programming. I did some 20 years ago, but I am sure it has changed since then. I have been using the lwIP callback API in all my products for the last 14 years. Since I am using the callback API, I will need something that works through that API. I hope this information is sufficient. I am very willing to patch my system and do testing for you. I just need some guidance about where to make the changes. I have been using lwIP for some time, but I have not paid that much attention to its interior. It has always just worked for me, straight out of the box.

Regards,
Roger W. Cover
________________________________________
From: lwip-users <lwip-users-bounces+rcover=[hidden email]> on behalf of [hidden email] <[hidden email]>
Sent: Saturday, March 7, 2020 2:02 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Do not fragment (DF) in a UDP transmission.

Am 06.03.2020 um 21:37 schrieb Roger Cover:
> Greetings,
>
> I am writing a video transmitter. The protocol I am using requires that a "test packet" has its do not fragment bit set. This is used to determine the maximum usable MTU of the intervening network nodes.
>
> I would like to know the recommended method for setting this bit in my UDP transmission. I am currently using the ip_output_if() function, and it does not have any arguments to allow this.

That's currently not supported (hasn't been requested so far). If you
tell me a standard way to do that (e.g. how is it done on sockets), I
guess adding this should not be too hard.

Regards,
Simon

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

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Do not fragment (DF) in a UDP transmission.

goldsimon@gmx.de
Am 09.03.2020 um 18:08 schrieb Roger Cover:
> Greetings Simon,
>
> The Linux man pages mention the IP_PMTUDISC_DO flag that "forces the don't-fragment flag to be set on all outgoing packets" in the setsockopt() description.

That will be for TCP only? Since we don't suppor MTU path discovery
(yet?), that's of no use to us.
>
> The documentation for setsockopt() for BSD 4.3 lists the similar flag "IP_DONTFRAG", with the qualifier "This option is supported for sockets with an address family of AF_INET and type of SOCK_DGRAM or SOCK_RAW only."

That could be an option for lwIP. The real problem is that there doesn't
seem to be a standard way for this, which is why we don't support it
yet. But I guess adding this for IPv4 UDP and RAW would be a valid option.

Regards,
Simon

>
> The Microsoft documentation at: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options lists an option called IP_DONTFRAGMENT, about which they state "Microsoft TCP/IP providers respect this option for UDP and ICMP."
>
> There is also a reference for the .NET framework at https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.dontfragment?view=netframework-4.8 if you have any interest in that.
>
> There is also a comment I do not completely understand in the lwIP ip.c file (line 790 in the ip_output_if() function, version 1.4.1) that states "don't fragment if interface has mtu set to 0."
>
> I am not very familiar with sockets programming. I did some 20 years ago, but I am sure it has changed since then. I have been using the lwIP callback API in all my products for the last 14 years. Since I am using the callback API, I will need something that works through that API. I hope this information is sufficient. I am very willing to patch my system and do testing for you. I just need some guidance about where to make the changes. I have been using lwIP for some time, but I have not paid that much attention to its interior. It has always just worked for me, straight out of the box.
>
> Regards,
> Roger W. Cover
> ________________________________________
> From: lwip-users <lwip-users-bounces+rcover=[hidden email]> on behalf of [hidden email] <[hidden email]>
> Sent: Saturday, March 7, 2020 2:02 AM
> To: Mailing list for lwIP users
> Subject: Re: [lwip-users] Do not fragment (DF) in a UDP transmission.
>
> Am 06.03.2020 um 21:37 schrieb Roger Cover:
>> Greetings,
>>
>> I am writing a video transmitter. The protocol I am using requires that a "test packet" has its do not fragment bit set. This is used to determine the maximum usable MTU of the intervening network nodes.
>>
>> I would like to know the recommended method for setting this bit in my UDP transmission. I am currently using the ip_output_if() function, and it does not have any arguments to allow this.
>
> That's currently not supported (hasn't been requested so far). If you
> tell me a standard way to do that (e.g. how is it done on sockets), I
> guess adding this should not be too hard.
>
> Regards,
> Simon
>
> _______________________________________________
> lwip-users mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
> _______________________________________________
> lwip-users mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Do not fragment (DF) in a UDP transmission.

Roger Cover
Greetings Simon,

I have implemented this by adding a flag bit for the struct pbuf field "flags". There were two unused bits, so I named one PBUF_FLAG_DF. I then altered ip.c to use this flag to decide whether to set the DF flag in the IP packet header upon transmission. This method only added 2 lines to pbuf.h and added 3 lines and altered one in ip.c.

Here is the diff for pbuf.h (I am using lwIP 1.4.1):
diff -r C:\Users\RCover\Documents\C_Source\9870\lwIP_1_4_1_lib\src\include\lwip\pbuf.h M:\DRAWINGS\9870-_ECO3389\9870-.zip\lwIP_1_4_1_lib\src\include\lwip\pbuf.h
78,79d77
< /** indicates the IP header for this pbuf should have the DF flag set on transmission */
< #define PBUF_FLAG_DF 0x40U

Here is the diff for ip.c:
diff -r C:\Users\RCover\Documents\C_Source\9870\lwIP_1_4_1_lib\src\core\ipv4\ip.c M:\DRAWINGS\9870-_ECO3389\9870-.zip\lwIP_1_4_1_lib\src\core\ipv4\ip.c
738,741c738
<     IPH_OFFSET_SET(iphdr, (p->flags & PBUF_FLAG_DF) ? PP_HTONS(IP_DF) : 0);
< #if CHECKSUM_GEN_IP_INLINE
<     chk_sum += iphdr->_offset;
< #endif /* CHECKSUM_GEN_IP_INLINE */
---
>     IPH_OFFSET_SET(iphdr, 0);

I have tested this, and it works well. It has minimal impact on the lwIP source, so hopefully it will be accepted.

Regards,
Roger W. Cover
________________________________________
From: lwip-users <lwip-users-bounces+rcover=[hidden email]> on behalf of [hidden email] <[hidden email]>
Sent: Tuesday, March 10, 2020 1:26 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Do not fragment (DF) in a UDP transmission.

Am 09.03.2020 um 18:08 schrieb Roger Cover:
> Greetings Simon,
>
> The Linux man pages mention the IP_PMTUDISC_DO flag that "forces the don't-fragment flag to be set on all outgoing packets" in the setsockopt() description.

That will be for TCP only? Since we don't suppor MTU path discovery
(yet?), that's of no use to us.
>
> The documentation for setsockopt() for BSD 4.3 lists the similar flag "IP_DONTFRAG", with the qualifier "This option is supported for sockets with an address family of AF_INET and type of SOCK_DGRAM or SOCK_RAW only."

That could be an option for lwIP. The real problem is that there doesn't
seem to be a standard way for this, which is why we don't support it
yet. But I guess adding this for IPv4 UDP and RAW would be a valid option.

Regards,
Simon

>
> The Microsoft documentation at: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options lists an option called IP_DONTFRAGMENT, about which they state "Microsoft TCP/IP providers respect this option for UDP and ICMP."
>
> There is also a reference for the .NET framework at https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.dontfragment?view=netframework-4.8 if you have any interest in that.
>
> There is also a comment I do not completely understand in the lwIP ip.c file (line 790 in the ip_output_if() function, version 1.4.1) that states "don't fragment if interface has mtu set to 0."
>
> I am not very familiar with sockets programming. I did some 20 years ago, but I am sure it has changed since then. I have been using the lwIP callback API in all my products for the last 14 years. Since I am using the callback API, I will need something that works through that API. I hope this information is sufficient. I am very willing to patch my system and do testing for you. I just need some guidance about where to make the changes. I have been using lwIP for some time, but I have not paid that much attention to its interior. It has always just worked for me, straight out of the box.
>
> Regards,
> Roger W. Cover
> ________________________________________
> From: lwip-users <lwip-users-bounces+rcover=[hidden email]> on behalf of [hidden email] <[hidden email]>
> Sent: Saturday, March 7, 2020 2:02 AM
> To: Mailing list for lwIP users
> Subject: Re: [lwip-users] Do not fragment (DF) in a UDP transmission.
>
> Am 06.03.2020 um 21:37 schrieb Roger Cover:
>> Greetings,
>>
>> I am writing a video transmitter. The protocol I am using requires that a "test packet" has its do not fragment bit set. This is used to determine the maximum usable MTU of the intervening network nodes.
>>
>> I would like to know the recommended method for setting this bit in my UDP transmission. I am currently using the ip_output_if() function, and it does not have any arguments to allow this.
>
> That's currently not supported (hasn't been requested so far). If you
> tell me a standard way to do that (e.g. how is it done on sockets), I
> guess adding this should not be too hard.
>
> Regards,
> Simon
>
> _______________________________________________
> lwip-users mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
> _______________________________________________
> lwip-users mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>


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

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Do not fragment (DF) in a UDP transmission.

goldsimon@gmx.de
Am 31.03.2020 um 02:13 schrieb Roger Cover:

> Greetings Simon,
>
> I have implemented this by adding a flag bit for the struct pbuf field "flags". There were two unused bits, so I named one PBUF_FLAG_DF. I then altered ip.c to use this flag to decide whether to set the DF flag in the IP packet header upon transmission. This method only added 2 lines to pbuf.h and added 3 lines and altered one in ip.c.
>
> Here is the diff for pbuf.h (I am using lwIP 1.4.1):
> diff -r C:\Users\RCover\Documents\C_Source\9870\lwIP_1_4_1_lib\src\include\lwip\pbuf.h M:\DRAWINGS\9870-_ECO3389\9870-.zip\lwIP_1_4_1_lib\src\include\lwip\pbuf.h
> 78,79d77
> < /** indicates the IP header for this pbuf should have the DF flag set on transmission */
> < #define PBUF_FLAG_DF 0x40U
>
> Here is the diff for ip.c:
> diff -r C:\Users\RCover\Documents\C_Source\9870\lwIP_1_4_1_lib\src\core\ipv4\ip.c M:\DRAWINGS\9870-_ECO3389\9870-.zip\lwIP_1_4_1_lib\src\core\ipv4\ip.c
> 738,741c738
> <     IPH_OFFSET_SET(iphdr, (p->flags & PBUF_FLAG_DF) ? PP_HTONS(IP_DF) : 0);
> < #if CHECKSUM_GEN_IP_INLINE
> <     chk_sum += iphdr->_offset;
> < #endif /* CHECKSUM_GEN_IP_INLINE */
> ---
>>     IPH_OFFSET_SET(iphdr, 0);
>
> I have tested this, and it works well. It has minimal impact on the lwIP source, so hopefully it will be accepted.

Sorry, but I don't want to implement this in an lwIP specific way. If it
can be done using a standard interface (or more than one), I'm open to
implement it.

Regards,
Simon

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