Giter Club home page Giter Club logo

Comments (6)

edgar-costa avatar edgar-costa commented on July 24, 2024 1

Yes it does.

You have to use the thrift API: https://github.com/nsg-ethz/p4-utils/blob/master/p4utils/utils/thrift_API.py#L1976

You can find examples in the p4-learning repo:

https://github.com/nsg-ethz/p4-learning/blob/master/examples/recirculate_and_add_header/fill_register.py
https://github.com/nsg-ethz/p4-learning/blob/master/exercises/11-Packet-Loss-Detection/solution/packet-loss-controller.py (here you can find reads and writes from the controller)

from p4-utils.

MohamadAlAdraa avatar MohamadAlAdraa commented on July 24, 2024

Hi @edgar-costa,

Thank you so much for your answer, I was able to get it to work.
I have another question if you can help I would appreciate that.

I need for each incoming packet to have the queue size of each egress port. Indeed, I know that in the ingress using the standard metadata we can have access to the queue size of the port that the packet enq and deq in it.

However, what I need is for each incoming packet to check the current queue size of each egress port so I wanna send on the least congested port. Is there any solution or tricks or resources that might help in this?

Again thank you so much for your help.

from p4-utils.

edgar-costa avatar edgar-costa commented on July 24, 2024

That is something related to specific P4 architectures not P4-utils.

Using the simple_switch you can not know the queue depth at the ingress, you could know it once you are at the egress and write it into a register, since you can access registers globally you can then read it with a bit of delay for the next packet.

Otherwise, you can not know it beforehand.

With a real hardware architecture you will need them to support this. There is something similar in tofino2 I think.

By the way, this paper: https://dl.acm.org/doi/10.1145/3098822.3098839 is doing what you want to do, but its a pre-p4 paper.

from p4-utils.

Tyler-ytr avatar Tyler-ytr commented on July 24, 2024

Hello,

I just want to ask if P4-UTILS supports reading and writing to registers. I highly appreciate your help.

Thank you.

You can do so like:

register<int<32>,bit<8>>(32) test_reg;
bit<8> index1=0;
int<32> result;
conv_reg.read(result,index1);

from p4-utils.

Hyq-p4cool avatar Hyq-p4cool commented on July 24, 2024

I am writing the source ip address and destination ip address of the header to the register, why is the data read by the controller a set of numbers, how to translate the bit IP address

from p4-utils.

edgar-costa avatar edgar-costa commented on July 24, 2024

@huyongqingandczw That has nothing to do with P4. Addresses are 32-bit integers. When you read them, you need to translate them yourself. This code will do that

import socket
import struct

def int_to_ip(int_ip):
    # Convert the integer to a binary string
    packed_ip = struct.pack("!I", int_ip)
    # Unpack the binary string into a readable IPv4 address
    readable_ip = socket.inet_ntoa(packed_ip)
    return readable_ip```

from p4-utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.