Next: Recognising CC Options
Up: CC Options
Previous: tcp_calc_cc_options()
Now that the selection of CC options has been made, a mechanism for inserting
the CC options into the header is needed.
The tcp_build_cc_options() function accomplishes this. It's prototype is
as follows:
It takes in a pointer to the sock struct that is responsible for the packet
to be sent, a pointer to where the CC options are to be inserted, and the send_cc
parameter indicates which CC options to include. This parameter is set from
the tcp_calc_cc_options() function described previously.
A test is done on send_cc and then the appropriate CC option is added in using
the following code structure:
-
- switch (send_cc) {
case 1:
/* send just a CC option */
ptr[0] = TCPOPT_NOP;
ptr[1] = TCPOPT_NOP;
ptr[2] = TCPOPT_CC;
ptr[3] = TCPOLEN_CCOPT;
ptr[4] = (sk->cc_send) >> 24;
ptr[5] = ((sk->cc_send) << 8) >> 24;
ptr[6] = ((sk->cc_send) << 16) >> 24;
ptr[7] = ((sk->cc_send) << 24) >> 24;
break;
}
It would have been possible to use the htonl() library function but it was decided
to use pointer arithmetic and shifting operations for speed, htonl() introduces
the overhead of context switching and a function call. The speed improvement
is necessary in the kernel for high performance. The code is still portable
because all network segments are arranged in the same byte order. Appendix A.1.2
contains the code for this function.
Mark Stacey
Thu Apr 30 12:26:11 IST 1998