| The current network architecture based on OpenFlow is increasingly difficult to support users’ complex requirements for data transmission due to its solidified management structure.In order to provide users with more flexible real-time data transmission services in the IoT environment,this paper will research and implement a publish-subscribe system based on P4,aimed at using P4 programmable technology to realize data layer packet processing logic and control layer logic to provide support for topic message forwarding,and then develop a topic-based distributed message forwarding system,which makes the system extensible and protocol independent,and provides users with more flexible messaging services for different businesses.The main contributions are as follows:(1)Topic mapping based on P4.Adding new matching fields or adding new protocol features can be costly for OpenFlow.To solve this problem,this paper implements the construction and unique encoding oftopic relation tree,and then use P4 technology to define the parsing and forwarding process of topic-based packet,and add the support of topicencode header to the data layer,the topic-encode field in this header will be used in the data layer as a matching rule to support the forwarding of topic packets,which solves the problems of OpenFlow’s insufficient programmability and poor expansion ability,and provides users with more efficient and reasonable publishing and subscription services.(2)System route calculation based on P4 controller.The global topology is established through negotiation mechanism,and topology maintenance is carried out through periodic heartbeat information.Based on topology information and subscription information,the system also needs to complete the calculation of the topic message path with minimum cost.In complex service scenarios,processing too many flow entries will degrade switch forwarding performance,in order to solve this problem,this paper proposes a topic aggregation and parent-child flow table algorithm,which enables the system to reduce the number of flow entries by using different aggregation strategies according to different topic subscription scenarios.Moreover,the system uses the parent-child topic flow table to realize muti-table processing on the data transport layer,which improves the flexibility of programming processing logic and reduces the data forwarding pressure on the switch.(3)Web Service Notification Service layer.WSN layer is implemented to provide publishing and subscription Web service and dispatch the received topic messages,which decouples publishers and subscribers.In addition,subscription event delivery and dispatch are realized by double blocking mechanism,which can reduce the packet loss rate in the case of high concurrency.Based on the above functional modules,this paper implements a complete publish-subscribe system based on P4 technology,and completes various tests in the P4 simulation network environment.The test results prove the reliability of each module and prove that the system can run continuously and stably. |