Subject: ECN and the DSCP field
To: None <,,,>
From: Rui Paulo <>
List: tech-net
Date: 06/06/2006 17:49:39
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:

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 */
			u_int8_t  ds_ecn:2;	/* ecn field */
			u_int8_t  ds_cp:6;	/* diffserv codepoint */
			u_int8_t  ds_cp:6;	/* diffserv codepoint */
			u_int8_t  ds_ecn:2;	/* ecn field */
		} 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