How to get Socket path when using controller to get information from data plane

Hello,
I am writing a P4 program in bmv2. I would like that P4 sends this information(including throughput and flow_id) by using digest + thrift to controller and set meter based on this digest.

I have already finish the function for get throughput and write digest in data plane, but when I try to write controller.py to receive the information, I always see the error: nnpy.errors.NNerror: Invalid argument.

I print the socket path and it shows ’ ', which means empty. What should I do to let the controller get correct socket path for specific P4 switch?

Here is my code part for get socket path in controller.py:
sock_path = sw.client.bm_mgmt_get_info().notifications_socket
sub = nnpy.Socket(nnpy.AF_SP, nnpy.SUB)
sub.connect(sock_path)
sub.setsockopt(nnpy.SUB, nnpy.SUB_SUBSCRIBE, b’')
print(“Connected to”, sock_path)

Thanks,
Yuexin.

I suspect what you are asking can be made to work, but I have not done it before, and have no examples I can think of to point you at that does exactly that.

I do have an example I can point you at that:

  • sends a packet to the CPU port with a header containing P4-program-defined metadata fields at the beginning of the packet, which is similar to a digest, except that the packet is sent with it.
  • Uses a small controller program written in Python to receive the PacketIn messages from the switch that the switch creates and sends to the controller for such packets.

In fact, I can point you at two examples, which perhaps confusingly use two different Python libraries for interacting with the switch from the controller program.

Thank you for your help! I will try that examples.