How to use tc filter on ap's wireless interface like ap1-wlan1?

430 views
Skip to first unread message

Bruce

unread,
Mar 12, 2021, 4:19:48 AM3/12/21
to mininet-wifi-discuss
Hi! I want to know how to use tc command correctly on a access point's wireless interface.

I found ap's wireless interface ap1-wlan1 can not filter packets correctly!!!

Here are my commands for you to reproduce:
  1. sudo mn --wifi
  2. xterm ap1
  3. in ap1's xterm: sudo tc qdisc del dev ap1-wlan1 root (to delete queues already exist because I need prio qdisc)
  4. then create qdiscs and classes:
    1. sudo tc qdisc add dev ap1-wlan1 root handle 1: prio
    2. sudo tc qdisc add dev ap1-wlan1 parent 1:1 handle 10: sfq
    3. sudo tc qdisc add dev ap1-wlan1 parent 1:2 handle 20: tbf rate 20kbit buffer 1600 limit 3000
    4. sudo tc qdisc add dev ap1-wlan1 parent 1:3 handle 30: sfq
  5. then create filters:
    1. sudo tc filter add dev ap1-wlan1 parent 1:0 protocol ip prio 1 u32 match ip tos 0x28 0xff flowed 1:1
    2. sudo tc filter add dev ap1-wlan1 parent 1:0 protocol ip prio 1 u32 match ip tos 0x48 0xff flowed 1:2
    3. sudo tc filter add dev ap1-wlan1 parent 1:0 protocol ip prio 1 u32 match ip tos 0x68 0xff flowed 1:3
After input these commands, I use ping to test:(in Mininet-wifi CLI)
  1. sta1 ping sta2 -c 5 -Q 0x28
  2. sta1 ping sta2 -c 5 -Q 0x48
  3. sta1 ping sta2 -c 5 -Q 0x68
Then use "sudo tc -s qdisc show dev ap1-wlan1" to see statistics. On my computer, all packets go to 1:2 qdisc which refers to tos 0x48, this confuses me!

I think there should be 3 packets in 1:1, and 3 packets in 1:2, and 3 packets in 1:3. Did I do something wrong?
Please tell me, thank you ver much!

Ramon Fontes

unread,
Mar 12, 2021, 6:35:05 AM3/12/21
to Bruce, mininet-wifi-discuss
Hello Bruce, please find the answer below.

>I found ap's wireless interface ap1-wlan1 can not filter packets correctly!!!

Well, you found something known by the community: qdiscs on ingress traffic provide only policing with no shaping. In order to shape ingress, the IFB (Intermediate Functional Block) device has to be used.

According to the reproducible steps you are not using IFB, am I right?

Please refer to https://wiki.linuxfoundation.org/networking/ifb for more information. 


Ps: Shouldn't the flowed flag be flowid?

--
Ramon Fontes

Em sex., 12 de mar. de 2021 às 06:19, Bruce <boya...@bupt.edu.cn> escreveu:
Hi! I want to know how to use tc command correctly on a access point's wireless interface.

Here are my commands for you to reproduce:
  1. sudo mn --wifi
  2. xterm ap1
  3. in ap1's xterm: sudo tc qdisc del dev ap1-wlan1 root (to delete queues already exist because I need prio qdisc)
  4. then create qdiscs and classes:
    1. sudo tc qdisc add dev ap1-wlan1 root handle 1: prio
    2. sudo tc qdisc add dev ap1-wlan1 parent 1:1 handle 10: sfq
    3. sudo tc qdisc add dev ap1-wlan1 parent 1:2 handle 20: tbf rate 20kbit buffer 1600 limit 3000
    4. sudo tc qdisc add dev ap1-wlan1 parent 1:3 handle 30: sfq
  5. then create filters:
    1. sudo tc filter add dev ap1-wlan1 parent 1:0 protocol ip prio 1 u32 match ip tos 0x28 0xff flowed 1:1
    2. sudo tc filter add dev ap1-wlan1 parent 1:0 protocol ip prio 1 u32 match ip tos 0x48 0xff flowed 1:2
    3. sudo tc filter add dev ap1-wlan1 parent 1:0 protocol ip prio 1 u32 match ip tos 0x68 0xff flowed 1:3
After input these commands, I use ping to test:(in Mininet-wifi CLI)
  1. sta1 ping sta2 -c 5 -Q 0x28
  2. sta1 ping sta2 -c 5 -Q 0x48
  3. sta1 ping sta2 -c 5 -Q 0x68
Then use "sudo tc -s qdisc show dev ap1-wlan1" to see statistics. On my computer, all packets go to 1:2 qdisc which refers to tos 0x48, this confuses me!

I think there should be 3 packets in 1:1, and 3 packets in 1:2, and 3 packets in 1:3. Did I do something wrong?
Please tell me, thank you ver much!

--
You received this message because you are subscribed to the Google Groups "mininet-wifi-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mininet-wifi-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mininet-wifi-discuss/ca901126-b901-4fe7-b3a7-ac534e1fcb8an%40googlegroups.com.
Message has been deleted

Bruce

unread,
Mar 12, 2021, 8:32:20 AM3/12/21
to mininet-wifi-discuss
Thank you very much!!!
I will go to study how to use IFB and solve my problem.
Oh, it should be flowid, my fault :)

Bruce

unread,
Mar 14, 2021, 9:57:42 AM3/14/21
to mininet-wifi-discuss
Sorry to bother you again.
I try to use ifb but it seems doesn't work:(
my steps are below:
  1. sudo mn --wifi , then xterm ap1, in ap1's xterm:
  2. modprobe ifb numifbs=1
  3. ip link set dev ifb0 up
  4. config ifb0:
    1. tc qdisc add dev ifb0 root handle 1: prio
    2. tc qdisc add dev ifb0 parent 1:1 handle 10: sfq
    3. tc qdisc add dev ifb0 parent 1:2 handle 20: tbf rate 20kbit buffer 1600 limit 3000
    4. tc qdisc add dev ifb0 parent 1:3 handle 30: sfq
    5. tc filter add dev ifb0 parent 1: protocol ip prio 1 u32 match ip tos 0x28 0xff flowid 1:1
    6. tc filter add dev ifb0 parent 1: protocol ip prio 1 u32 match ip tos 0x48 0xff flowid 1:2
    7. tc filter add dev ifb0 parent 1: protocol ip prio 1 u32 match ip tos 0x68 0xff flowid 1:3
  5. and config ap1-wlan1:
      1. tc qdisc del dev ap1-wlan1 root
      1. tc qdisc add dev ap1-wlan1 root handle 1: htb default 2
      2. tc class add dev ap1-wlan1 parent 1: classid 1:1 htb rate 800kbit
      3. tc class add dev ap1-wlan1 parent 1: classid 1:2 htb rate 800kbit
      4. tc class add dev ap1-wlan1 parent 1:1 classid 1:10 htb rate 256kbit ceil 284kbit
      5. tc class add dev ap1-wlan1 parent 1:1 classid 1:20 htb rate 512kbit ceil 648kbit
      6. tc filter add dev ap1-wlan1 parent 1: protocol ip prio 1 u32 match ip dst 10.0.0.1/24 flowid 1:10 action mirred egress redirect dev ifb0
    1. now use ping or to test:
      1. in mininet_wifi_CLI: sta1 ping sta2 -c 5 -Q 0x28, and use tc -s qdisc show dev ifb0 in ap1's xterm,  it seems useless to use ifb...
    Also, my original opinion is to use tc prio qdisc on ap's wireless interface like ap1-wlan1, I want this interface to transmit packets to other nodes by telling tos_values, I think this is about egress traffic shaping(Because the wireless interfaces just need to recognize packet's tos_value and choose which class to send packet out), am I right?

    Or can you tell me the way to use tc prio qdisc on ap's wireless interface, like ap1-wlan1?
    Thank you!

    在2021年3月12日星期五 UTC+8 下午7:35:05<ramonre...@gmail.com> 写道:

    Ramon Fontes

    unread,
    Mar 14, 2021, 2:08:44 PM3/14/21
    to Bruce, mininet-wifi-discuss
    Have you ever tried that network setup with OVS before? OVS APs/Switches work at L2 and the ToS field is at L3, right? My question is: How could the AP process the L3 header if it works at L2? Wouldn't it ignore the TC rule?

    Bruce

    unread,
    Mar 18, 2021, 10:19:42 AM3/18/21
    to mininet-wifi-discuss
    Thank you!
    >Have you ever tried that network setup with OVS before?
    No, in fact I use ofsoftswitch usually. Dose OVS APs/Switchs and ofsoftswitch all work in L2?
    I change my filter command like the photo, which use src MAC address to match,  and this works well, so all the problem above is L2 device can not process L3 header?
    BTW, may I ask how could ap(OVS or ofsoftswitch) use IP layer ToS to filter packets, is it possible?

    tc_commands.png

    Ramon Fontes

    unread,
    Mar 18, 2021, 11:02:19 AM3/18/21
    to Bruce, mininet-wifi-discuss
    > Does OVS APs/Switchs and ofsoftswitch all work in L2
    A. Yes. By default they (only) provide L2 functionality.

    I change my filter command like the photo, which use src MAC address to match,  and this works well, so all the problem above is L2 device can not process L3 header?
    A. No. OVS may process L3/L4 headers through the OpenFlow protocol and its flow table. As far as I know you are not considering the OF protocol in your network scenario.

    BTW, may I ask how could ap(OVS or ofsoftswitch) use IP layer ToS to filter packets, is it possible?
    A. Answered above.

    Sent from my android

    --
    You received this message because you are subscribed to the Google Groups "mininet-wifi-discuss" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to mininet-wifi-dis...@googlegroups.com.

    Bruce

    unread,
    Mar 20, 2021, 11:23:52 PM3/20/21
    to mininet-wifi-discuss
    Can you tell me how to use OF protocol and tc together, to make ofsoftswitch aps able to process L3/L4 headers?
    I checked netdev.c, dpctl.c and  dp_ports.c of ofsoftswitch, but I didn't figure out how ofsoftswitch do to combine OF protocol and tc, it seems map flows to queues through skb->priority, I don't know how it change class_id into queues
    Thank you!
    Reply all
    Reply to author
    Forward
    0 new messages