Chapter XXIII. Traffic Management
Modifying the application
The application can also be modified to associate connections to scheduling classes. Follow the
steps mentioned below:
i.
Determine the TCP socket file descriptor in the application through which data is sent.
ii. Declare and initialize a variable in the application:
int cl=1;
Here,
cl is the TCP traffic class(scheduler-class-index) that the user wishes to assign the data stream
to. This value needs to be in the range of 0 to 7.
The application will function as per the parameters set for that traffic class.
iii. Add socket option definitions:
In order to use setsockopt() to set the options to the TCP socket, the following two definitions
need to be made:
•
SOL_SCHEDCLASS used for setting TCP traffic class, which has the value 290.
•
IPPROTO_TCP used for setting the type of IP Protocol.
# define SOL_SCHEDCLASS 290
# define IPPROTO_TCP 6
iv. Use the setsockopt() function to set socket options:
The setsockopt() call must be mentioned after the connect() call.
//Get the TCP socket descriptor variable
setsockopt (sockfd , IPPROTO_TCP, SOL_SCHEDCLASS, &cl, sizeof(cl));
Here,
sockfd
: The file descriptor of the TCP socket.
&cl
: Pointer to the class variables.
sizeof(cl) : The size of the variable.
v. Now, compile the application.
Chelsio Unified Wire for Linux
325
Need help?
Do you have a question about the Terminator Series and is the answer not in the manual?
Questions and answers