于Floodlight模块假设要packet in消息,就对对应的消息类型进行监听就可以。然后在receive方法中就能够操纵这个上传上来的packet_in。
关键代码:
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD); if(eth.getEtherType() == Ethernet.TYPE_IPv4){ IPv4 ipPkt = (IPv4)eth.getPayload(); if(ipPkt.getProtocol() == IPv4.PROTOCOL_UDP){ UDP udpPkt = (UDP)ipPkt.getPayload(); Data dataPkt = (Data)udpPkt.getPayload(); System.out.println(dataPkt.getData().length); byte[] arr = dataPkt.getData(); for (int i = 0; i < dataPkt.getData().length; i++){ System.out.print((char)arr[i]); } } }转载请注明出处谢谢:http://blog.csdn.net/vonzhoufz/article/details/31356485
版权声明:本文博主原创文章,博客,未经同意不得转载。