0

I am a beginner in P4, and currently learning P4. Currently experiment with the meter in P4. How may I limit the bandwidth using P4 by identifying packets?

Here I have created an indirect meter like this in Ingress Processing

control MyIngress(inout headers hdr,
                  inout metadata meta,
                  inout standard_metadata_t standard_metadata) {

    meter(32w16384, MeterType.bytes) my_meter;

    action drop() {
        mark_to_drop(standard_metadata);
    }

    action m_action(bit<32> meter_index) {
        my_meter.execute_meter<bit<32>>(meter_index, meta.meter_tag);
    }


    table m_read {
        key = {
            hdr.ethernet.srcAddr: exact;
        }
        actions = {
            m_action;
            NoAction;
        }
        default_action = NoAction;
        size = 16384;
    }

    table m_filter {
        key = {
            meta.meter_tag: exact;
        }
        actions = {
            drop;
            NoAction;
        }
        default_action = drop;
        size = 16;
    }

    apply {
        // Same egress port for all packets in this example
        standard_metadata.egress_spec = 2;

        // Check meter
        m_read.apply();

        // Filter based on meter status
        m_filter.apply();

    }
}

In Commands.txt file

table_add m_filter NoAction 0 =>
meter_array_set_rates my_meter 100000:1 200000:1

Now my question is, how do I limit the bandwidth using P4 programing so that the iperf speed comes with a speed limit say 200KB/s.

mhovd
  • 3,724
  • 2
  • 21
  • 47
COLLiDER
  • 31
  • 5
  • I have edited your question with regards to formatting, please make sure that your original intent and details of your setup remained accurate. – mhovd Dec 12 '22 at 18:37

0 Answers0