Converting Openflow packet into Ptr<Packet>

39 views
Skip to first unread message

Kam

unread,
Sep 20, 2015, 5:14:27 PM9/20/15
to ns-3-users
Hello ns3 community,

I am working on a project, where I am trying to study GTPU processing in an Openflow controller.
I have a topology where LTE EPC traffic would go through an Openflow switch.

I am trying to modify the following function in openflow/model/openflow-interface.cc

LearningController::ReceiveFromSwitch (Ptr<OpenFlowSwitchNetDevice> swtch, ofpbuf* buffer) {
     ofp_packet_in * opi = (ofp_packet_in*)ofpbuf_try_pull (buffer, offsetof (ofp_packet_in, data));
     Ptr<Packet> pkt = Create<Packet>(opi->data, opi->header.length); 

     // extract the GTPU header and print it
     int removed = pkt->RemoveHeader (gtpu);
     printf ("GTPU Header length: %d\n", removed);
     gtpu.Print(std::cout << "GTPU Header Info: \n");  
}

Now after extracting the GTPU header, when I print it, I get all garbage data:
GTPU Header Info:  version=0 [], messageType=0, length=0, teid=65536, sequenceNumber=0, nPduNumber=0, nextExtensionType=8


I instrumented epc-enb-application.cc, which is generating this packet(in Uplink) and this is the kind of GTPU header that I should be getting:
Epc Enb Application GTPU Header Info:   version=1 [ PT  S  PN ], messageType=255, length=1056, teid=1, sequenceNumber=1, nPduNumber=0, nextExtensionType=0



Questions:
- How to cast ofp_packet_in into Ptr<Packet> ??? Is the Packet initialization im doing incorrect?
- Does the data portion of ofp_packet_in (ofp_packet_in->data) start at the GTPU header as I am expecting?


Please any help from the community would be greatly appreciated as I am completely stumped :(


Kind Regards,
Kam
Reply all
Reply to author
Forward
0 new messages