-
Notifications
You must be signed in to change notification settings - Fork 3k
Add an socket option to set type of service to set specific precedence for QoS #13671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@balajicyp, thank you for your changes. |
@pan- can you review? |
@pan- bump |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the submission @balajicyp.
The current PR is specific to LwIP and relies on internal of LwIP. However type of service is common socket feature.
I'd like to see parameter definitions in nsapi_types.h
like it is done with nsapi_ip_mreq_t
and the NSAPI_ADD_MEMBERSHIP
/NSAPI_DROP_MEMBERSHIP
options so it can be used by other stacks.
@@ -664,6 +664,12 @@ nsapi_error_t LWIP::setsockopt(nsapi_socket_t handle, int level, int optname, co | |||
return err_remap(igmp_err); | |||
} | |||
|
|||
case NSAPI_IPTOS: | |||
if (optlen != sizeof(int)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need an int ? What are the expected values ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pan-
The IPTOS ( is a field an IP header field ) of 8 bits ( with 6 bits (DSCP) + 2 bits (ECN)). The typical values of these used Priority differentiation following the RFC 791 https://tools.ietf.org/html/rfc791
Bits 0-2: Precedence.
Bit 3: 0 = Normal Delay, 1 = Low Delay.
Bits 4: 0 = Normal Throughput, 1 = High Throughput.
Bits 5: 0 = Normal Relibility, 1 = High Relibility.
Bit 6-7: Reserved for Future Use.
0 1 2 3 4 5 6 7
+-----+-----+-----+-----+-----+-----+-----+-----+
| | | | | | |
| PRECEDENCE | D | T | R | 0 | 0 |
| | | | | | |
+-----+-----+-----+-----+-----+-----+-----+-----+
This is used to prioritize Traffic class in transmit direction and the following are the values used
uint32_t tos_priority[4] = { 0x00, 0x40, 0xA0, 0xE0 }; // Best Effort, Background, Video, Voice
Regarding add it as nsapi_types.h , please can give more information, I know that NSAPI_ADD_MEMBERSHIP/NSAPI_DROP_MEMBERSHIP
is only used for muliticast traffic and how I should add, the following is used for unicast traffic.
Thanks
Balaji.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@balajicyp that doesn't really answer the question of why do we need an int as a single byte is required to code all the values.
For the options what I'd like to see is a list of these flags in NSAPI
. Something similar to what is presented in LwIP:
mbed-os/connectivity/lwipstack/lwip/src/include/lwip/sockets.h
Lines 347 to 389 in ad40b1b
/* | |
* The Type of Service provides an indication of the abstract | |
* parameters of the quality of service desired. These parameters are | |
* to be used to guide the selection of the actual service parameters | |
* when transmitting a datagram through a particular network. Several | |
* networks offer service precedence, which somehow treats high | |
* precedence traffic as more important than other traffic (generally | |
* by accepting only traffic above a certain precedence at time of high | |
* load). The major choice is a three way tradeoff between low-delay, | |
* high-reliability, and high-throughput. | |
* The use of the Delay, Throughput, and Reliability indications may | |
* increase the cost (in some sense) of the service. In many networks | |
* better performance for one of these parameters is coupled with worse | |
* performance on another. Except for very unusual cases at most two | |
* of these three indications should be set. | |
*/ | |
#define IPTOS_TOS_MASK 0x1E | |
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) | |
#define IPTOS_LOWDELAY 0x10 | |
#define IPTOS_THROUGHPUT 0x08 | |
#define IPTOS_RELIABILITY 0x04 | |
#define IPTOS_LOWCOST 0x02 | |
#define IPTOS_MINCOST IPTOS_LOWCOST | |
/* | |
* The Network Control precedence designation is intended to be used | |
* within a network only. The actual use and control of that | |
* designation is up to each network. The Internetwork Control | |
* designation is intended for use by gateway control originators only. | |
* If the actual use of these precedence designations is of concern to | |
* a particular network, it is the responsibility of that network to | |
* control the access to, and use of, those precedence designations. | |
*/ | |
#define IPTOS_PREC_MASK 0xe0 | |
#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK) | |
#define IPTOS_PREC_NETCONTROL 0xe0 | |
#define IPTOS_PREC_INTERNETCONTROL 0xc0 | |
#define IPTOS_PREC_CRITIC_ECP 0xa0 | |
#define IPTOS_PREC_FLASHOVERRIDE 0x80 | |
#define IPTOS_PREC_FLASH 0x60 | |
#define IPTOS_PREC_IMMEDIATE 0x40 | |
#define IPTOS_PREC_PRIORITY 0x20 | |
#define IPTOS_PREC_ROUTINE 0x00 |
The goal is to not let the user guess what can be used or hardcode these values. Other stacks may it should be clear what values are expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the NSAPI type defines for Type of Service
similar to mbed-os/connectivity/lwipstack/lwip/src/include/lwip/sockets.h (line 347 to 389).
I have fixed optlen check to u8_t
Please review them
Thanks
Balaji.
Pull request has been modified.
CI started |
Jenkins CI Test : ❌ FAILEDBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
CI errors unrelated, we are fixing CI targets that started to have issues, will rerun CI once it's all fixed. |
CI restarted |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 2 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
Add an socket option to set the IP type of service to set specific precedence for Quality of Service.
This change is required to send traffic apart from Best Effort on an Socket.
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers