CPqD / ofsoftswitch13

OpenFlow 1.3 switch.
http://cpqd.github.com/ofsoftswitch13
304 stars 192 forks source link

How to use dscp_remark flexibly? #303

Closed caopeirui closed 4 years ago

caopeirui commented 4 years ago

We need to use dscp_remark to split traffic by a rate threshold. A successful case is:

dpctl unix:/tmp/s1 meter-mod cmd=add,meter=1 dscp_remark:rate=8000,prec_level=1
dpctl unix:/tmp/s1 flow-mod cmd=add,table=0 in_port=1 meter:1 goto:1
dpctl unix:/tmp/s1 flow-mod cmd=add,table=1 in_port=1,eth_type=0x800,ip_dscp=2 apply:output=2
dpctl unix:/tmp/s1 flow-mod cmd=add,table=1 in_port=1,eth_type=0x800,ip_dscp=4 apply:output=3
dpctl unix:/tmp/s3 flow-mod cmd=add,table=0 in_port=1, apply:output=2
dpctl unix:/tmp/s2 flow-mod cmd=add,table=0 in_port=2, apply:output=3
dpctl unix:/tmp/s2 flow-mod cmd=add,table=0 in_port=1, apply:output=3

dpctl unix:/tmp/s2 meter-mod cmd=add,meter=1 dscp_remark:rate=8000,prec_level=1
dpctl unix:/tmp/s2 flow-mod cmd=add,table=0 in_port=3 meter:1 goto:1
dpctl unix:/tmp/s2 flow-mod cmd=add,table=1 in_port=3,eth_type=0x800,ip_dscp=2 apply:output=1
dpctl unix:/tmp/s2 flow-mod cmd=add,table=1 in_port=3,eth_type=0x800,ip_dscp=4 apply:output=2
dpctl unix:/tmp/s3 flow-mod cmd=add,table=0 in_port=2, apply:output=1
dpctl unix:/tmp/s1 flow-mod cmd=add,table=0 in_port=3, apply:output=1
dpctl unix:/tmp/s1 flow-mod cmd=add,table=0 in_port=2, apply:output=1
topo:
        h1 --- s1 --- s2 --- h2
                |       |
                s3 ----
c0
s3 lo:  s3-eth1:s1-eth3 s3-eth2:s2-eth2
s1 lo:  s1-eth1:h1-eth0 s1-eth2:s2-eth1 s1-eth3:s3-eth1
s2 lo:  s2-eth1:s1-eth2 s2-eth2:s3-eth2 s2-eth3:h2-eth0
h2 h2-eth0:s2-eth3
h1 h1-eth0:s1-eth1

However, we have to use a additional parmeter --tos 0x8 in iperf test, such as,

h2 iperf -u -s -p 5566 -i 1 > iperfserver.log &
h1 iperf -u -c 10.0.0.2 -b 20M -p 5566 -t 3 --tos 0x08 > iperfclient.log

Looking up https://github.com/CPqD/ofsoftswitch13/blob/master/udatapath/meter_entry.c#L236 , we find the corresponding relationship is

--tos 0x08
prec_level = 1
no-marked ip_dscp = 2
marked ip_dscp = 4

Therefore, there are too many limits. How can we use ofsoftwitch13's dscp_remark function more flexibly? How can we use dscp_remark function without the --tos 0x08 ?

ederlf commented 4 years ago

With meters, you can only increase the precedence level of the DSCP field. The specification says on page 87:

This band increases the encoded drop precedence by this amount, not the raw DSCP value; it always results in a valid DSCP value, and DSCP values that do not encode a drop precedence are not modified.

Therefore you have to use the tos option to add some initial precedence level.

caopeirui commented 4 years ago

With meters, you can only increase the precedence level of the DSCP field. The specification says on page 87:

This band increases the encoded drop precedence by this amount, not the raw DSCP value; it always results in a valid DSCP value, and DSCP values that do not encode a drop precedence are not modified.

Therefore you have to use the tos option to add some initial precedence level.

Thank you for your help. I need to research the specification further.