I am trying to implement a packet_in method in order to receive a packet from the switch to the controller, according to p4runtime.proto file.
My code does not work and i have no idea what is going wrong.
In the beginning, i thought that i had to send a StreamMessageRequest of packet out message to get a StreamMessageResponse of packet_in message, but as i can see they work independent.
My method written in python into the switch.py file in p4runtime library looks like this:
def packet_in(self, **kwargs):
print("Before loop")
for response in self.stream_msg_resp:
print("I am into it")
if response.HasField("packet"):
print("Packet is set")
else:
print(response.WhichOneof("update"))
return(response)
When i call it from my_controller.py program, it blocks after “Before loop” print message.
I suspect that switch, when it has to send a packet to the cpu_port, it does not create a StreamMessageResponse of packet_in message in order to send it through grpc StreamChannel that is created when a connection between the stub and the server is established.
Am i doing anything or thinking it wrong? Can anybody help me?