Subject: Re: ECN and the DSCP field
To: Rui Paulo <rpaulo@fnop.net>
From: Matt Thomas <matt@3am-software.com>
List: tech-net
Date: 06/06/2006 10:03:58
Rui Paulo wrote:
> Hi,
> As you might know, RFC 2474 introduces a new field called
> "Differentiated Services".
> 
> Quoting the RFC:
> 
>    The DS field structure is presented below:
> 
> 
>         0   1   2   3   4   5   6   7
>       +---+---+---+---+---+---+---+---+
>       |         DSCP          |  CU   |
>       +---+---+---+---+---+---+---+---+
> 
>         DSCP: differentiated services codepoint
>         CU:   currently unused
> 
> This replaces the ip_tos field with a more fine grained type of
> service control.
> DSCP can have serveral values, assigned from IANA and available from:
> http://www.iana.org/assignments/dscp-registry.
> 
> The CU bits are now used by ECN indicating (from RFC 3168):
> 
>    Bits 6-7, ECN Field:
> 
>    Binary  Keyword                                  References
>    ------  -------                                  ----------
>      00     Not-ECT (Not ECN-Capable Transport)     [RFC 3168]
>      01     ECT(1) (ECN-Capable Transport(1))       [RFC 3168]
>      10     ECT(0) (ECN-Capable Transport(0))       [RFC 3168]
>      11     CE (Congestion Experienced)             [RFC 3168]
> 
> So, what I was thinking was replacing our ip_tos field in 'struct ip'
> by something like:
> 
> struct ip {
> 
> 	[...]
> 
> 	union {
> 		struct ip_ds {		/* differentiated services */
> #if BYTE_ORDER == LITTLE_ENDIAN
> 			u_int8_t  ds_ecn:2;	/* ecn field */
> 			u_int8_t  ds_cp:6;	/* diffserv codepoint */
> #endif
> #if BYTE_ORDER == BIG_ENDIAN
> 			u_int8_t  ds_cp:6;	/* diffserv codepoint */
> 			u_int8_t  ds_ecn:2;	/* ecn field */
> #endif
> 		} ip_ds __attribute__((__packed__));
> 
> 		u_int8_t  ip_tos;	/* type of service */
> 	} ip_dsf __attribute__((__packed__));
> 
> 	[...]
> 
> } __attribute__((__packed__));
> 
> 
> This raises two issues:
> 
> 	1) Some files are using local variables called ip_tos, so I
>            can't do:
> 	   #define ip_tos ip_dsf.ip_tos
> 	   #define ip_ds  ip_dsf.ip_ds
> 	   without fixing them.
> 	2) I guess that we don't want to go fix every file that
>            references ip->ip_tos. Out of question, right?
> 
> Concluding, doing this change is not strictly necessary for
> implemeting ECN, but it could help future implementations of CoS/ToS
> classifiers.
> 
> Comments?

The use of bitfields by IP was historical mistake.  Don't perpetuate it.
Simply use normal bitmask operations on ip_tos.  Or defined accessor
macros for IP_TOS.

-- 
Matt Thomas                     email: matt@3am-software.com
3am Software Foundry              www: http://3am-software.com/bio/matt/
Cupertino, CA              disclaimer: I avow all knowledge of this message.