金 智,劉 蓉
面向物聯網應用的動態切換CoAP模式
金 智,劉 蓉
(長沙醫學院 信息工程學院,長沙 410219)
為了平衡物聯網時延與數據包傳輸可靠性之間的關系,根據受限制的應用協議(CoAP)中確認模式和非確認模式的特點,對CoAP模式進行研究:依據無線信道條件,推導CoAP的2個模式下的數據包丟失率的表達式;利用最大似然估計算法估計參數,并計算確認模式和非確認模式下的數據包丟失率;最后依據應用對數據包丟失率的要求,采用動態CoAP模型達到平衡傳輸時延和吞吐量的目的。實驗結果表明,推導的數據包丟失率表達式能夠與實驗數據相匹配,同時,動態CoAP模式能夠有效地平衡傳輸時延和吞吐量性能。
物聯網;受限制的應用協議;數據包丟失率;確認模式;非確認模式
作為無線傳感網絡(wireless sensor networks, WSNs)的特殊應用,物聯網(internet of things, IoT)[1-2]涉及到處理物理層、網絡層、傳輸層和應用層信息傳輸問題的技術。IoT系統主要包含4類節點:傳感節點和執行節點(actuator nodes, ACNs)、網關(gateways)、服務器、客戶端。傳感節點和ACNs常部署于網絡的邊緣環境,而邊緣環境的無線信道易受多徑衰落[3-4]影響,最終導致數據包丟失。
此外,為了延長傳感節點的電池壽命需要低功率消耗;但低功率消耗會導致低的信噪比(signal-noise ratio, SNR),這會導致數據包丟失[5-6]。因此,傳感節點的能效問題也是影響數據包傳輸性能的一個關鍵因素。
目前有幾種協議處理節點能耗問題,如消息隊列遙測傳輸(message queue telemetry transport, MQTT)、可擴展消息出席協議(extensive messaging and presence protocol, XMPP)、高級消息隊列協議(advanced message queuing protocol, AMQP)和受限制的應用協議(constrained application protocol, CoAP)[7-9], 其中CoAP協議廣泛應用于能量受限的網絡。
CoAP協議給終端間提供了請求和響應模式,并支持服務、資源發現模式。此外,CoAP協議很容易與超級文本傳輸協議(hypertext transfer protocol, HTTP)相融合。
相比上述的其他協議,CoAP協議最顯著的不同在于:CoAP協議引用用戶報協議(user datagram protocol, UDP)。CoAP協議依據對數據包丟失率要求,引入了不可靠模式和可靠模式。然而,為了提高數據傳輸的可靠性(可靠模式),可能加大了重傳次數,就會增加節點能耗和傳輸時延。
盡管傳輸數據包時都要求低時延和低數據包率;但是在不同應用環境,對時延要求不同。例如:對于無人機應用,飛機的飛行路徑是建立在多個傳感器所感測的數據基礎上的,而這些數據的傳輸時間直接影響它的飛行路徑;而對于電網應用,對數據包丟失率的要求高于傳輸時延。
本文基于無線信道,結合CoAP傳輸模式,推導數據包丟失概率的閉合表達式,并將數據包丟失率要求(閾值)作為輸入參數,再依據此參數動態選擇可靠傳輸模式和非可靠傳輸模式,進而平衡時延和數據包傳輸可靠性之間的關系。
作為應用層協議,CoAP協議運行于UDP之上,而不是像HTTP協議運行于傳輸控制協議(transmission control protocol, TCP)之上。同時,CoAP協議通過優化數據報長度,克服對HTTP協議受環境限制的不足,但CoAP協議不是盲目地壓縮HTTP協議。圖1顯示了HTTP和CoAP協議棧。CoAP協議在邏輯上可分為Message和Request/ Respone 2層。

圖1 HTTP和CoAP協議棧
此外,CoAP提供2類傳輸模式[10-11]:①非確認模式(non-confirmable),只提供最大能力傳輸數據包,但不保證數據包能可靠傳輸;②確認模式,只有接收了終端的確認包才考慮傳輸數據包。相比于非確認模式,確認模式提高了數據包傳輸率。
考慮動態的無線信道環境時,假定無線信道環境具有2類狀態:①低丟失率(low loss, LL);②高丟失率(high loss, HL)。在低丟失率狀態下信道環境較好,其數據包的傳輸環境優于高丟失率狀態環境。依據馬爾可夫(Markov)模型,這2個狀態間的轉換模型如圖2所示。

圖2 2個狀態間的Markov模型
在非確認模式下,CoAP協議單向地、固定間隔地傳輸數據,如圖3所示。服務器以固定間隔地傳輸數據包,并且不關心客戶端是否收到數據包。




圖3 非確認模式下的消息傳輸

圖4顯示了CoAP協議在確認模式下的數據包傳輸過程。假定服務器先傳輸了con(MID)= 0x2015,在規定的時間內,未能收到確認包ACK,因此,服務器再重傳,并將時限擴大一步。重復執行,直到收到確認包。但重傳次數超過上限,則停止數據包的傳輸。

圖4 確認模式下的消息傳輸
義為














考慮如圖5所示的網絡模型,其中傳感節點數為20。傳感節點每50 s讀取環境數據。依據文獻[18]設定仿真。每次仿真獨立重復10次,取平均值作為最終的仿真數據。
首先,分析推導在非確認模式、確認模式下的數據包丟失率(式(12)、式(13))的正確性。將實驗得出的數據標記為Experimental,而通過本文所推導的數據標記為Theoretical。
表1、表2分別表示了非確認模式下Theoretical、Experimental的數據包丟失率(Packet Loss Ratio, PLR)。從這2表可知,實驗數據與由推導式(12)計算的PLR相近,特別是在的低值范圍,2項數據相近。但是,隨著值的增大,誤差逐漸增加,實驗數據的波動較大。這也說明,值越大,對PLR的影響越大。

表1 非確認模式下的PLR(理論值)

表2 非確認模式下的PLR(實驗值)
表3、表4分別顯示了在確認模式下的實驗數據、理論推導的PLR。
相比于非確認模式,確認模式下的PLR明顯下降。然而,隨著值的增加,數據包丟失率迅速增加,原因在于:值越大,信道環境越差,加大了數據包丟失率。

表3 確認模式下的PLR(理論值)

表4 確認模式下的PLR(實驗值)


圖5 數據包傳輸時延

本次實驗進一步分析確認模式、非確認模式和動態模式下的吞吐量,如圖6所示。


圖6 吞吐量
圖5、圖6數據表明,動態模式能夠有效地平衡傳輸時延與吞吐量之間的關系,即通過動態地切換CoAP的傳輸模式,可平衡時延和吞吐量。
本文推導了數學模式,其能夠依據網絡層參數預測確認和非確認應用層數據包丟失率。再將所估計的數據包丟失率與數據包丟失率閾值進行比較,并動態切換確認模式和非確認模式,從而平衡吞吐量和傳輸時延的性能。
將本文所推導的模式進一步擴展,并計算應用層的時延,進而分析QoS性能,這將是后期研究工作的方向。
[1] 徐楊, 王曉峰, 何清漪. 物聯網環境下多智能體決策信息支持技術[J]. 軟件學報, 2014, 25(10): 2325-2345.
[2] NIAYESH G, KAMALRU A, MOHD H S. Collaborative mobile sink sojourn time optimization scheme for cluster-based wireless sensor networks[J]. IEEE Sensors Journal, 2018, 4(7): 23-31.
[3] CIRSTEA C, CERNAIANU M O, GONTEAN A.Packet loss analysis in wireless sensor networks routing protocols[EB/OL]. [2019-04-26]. https://www.researchgate.net/publication/260863298_Packet_Loss_Analysis_in_ Wireless_Sensor_Networks_Routing_Protocols.
[4] JAN M A, JAN S R U, RAHMAN I U. A comprehensive analysis of congestion control protocols in wireless sensor networks[J].Mobile Networks and Applications, 2018, 23(3): 456-468.
[5] THANGAVEL D, MA Xiaoping, VALERA A C, et al. Performance evaluation of MQTT and CoAP via a common middlewares[EB/OL]. [2019-04-26]. https://www.researchgate.net/publication/267636202_Performance_evaluation_ of_MQTT_and_CoAP_via_a_common_middleware.
[6] DESCHANBAULT O, GHERBI A, LéGARé C.Efficient implementation of the MQTT protocol for embedded systems[J]. Journal of Information Processing System, 2017, 13(1): 26-39.
[7] KARAGIANNIS V, CHATZIMISIOS P, VAZQUEZ-GALLEGO F, et al. A survey on application layer protocols for the internet of things[J]. Transaction on IoT and Cloud Computing, 2015,1(1):12-21.
[8] SLABICKI M, GROCHL K. Performance evaluation of CoAP, SNMP and NETCONF protocols in fog computing architecture[EB/OL].[2019-04-26].https://www.researchgate.net/publication/301694346_Performance_evaluation_ of_CoAP_SNMP_and_NETCONF_protocols_in_fog_computing_architecture.
[9] GRANJAL J, MONTEIRO E, SILVA J S.Security for the internet of things: a survey of existing protocols and open research issues[J]. IEEE Communications Surveys Tutorials, 2015, 17(3):1294-1312.
[10] 胡國強, 李茵, 蔚繼承. 基于6LoWPAN和CoAP的農業環境信息傳感系統的設計與實現[J]. 現代電子技術, 2016, 39(23): 152-157.
[11] BIMONTE S. Current approaches, challenges and prespectives on spatial OLAP for Agi-environment analysis[J]. International Journal of Agricultural and Environmental Information System, 2016, 7(4): 32-49.
[12] BARTON M, LEMBERG H, SARRAF M,et al. Performance analysis of packet loss concealment in mobile environments with a two-state loss model[C]//The Institute of Electrical and Electronic Engineers(IEEE). Proceedings of 2010 IEEE International Workshop Technical Committee on Communications Quality and Reliability (CQR). [S.l.]: IEEE, 2015: 1-6.
[13] AKBARI B, RABIEE H R, GHANBARI M. Performance analysis of packet loss recovery policies in P2P video streaming[J]. International Journal of Internet Protocol Technology, 2014, 8(1): 44-53.
[14] 李琦, 張康, 王月明. 基于CoAP協議的數據采集網關設計[J]. 計算機技術與應用, 2015, 41(6): 152-157.
[15] KIM H S, SEO J S, SEO J W. Performance evaluation of a smart CoAP gateway for remote home safety rervices[J]. KSII Transactions on Internet and Information System, 2015, 9(8): 3079-3089.
[16] POOR H V.An introduction to signal detection and estimation[M]. 2ed ed.New York: Springer-Verlag New York, Inc., 2014.
[17] KATZ D, WARD D D.Bidirectional forwarding detection [EB/OL]. [2019-04-26]. http://www.freepatentsonline. com/7561527.pdf.
[18] VPS.Visual protostack protocol emulator[EB/OL]. [2019-04-26]. http://www.vprotostack.com.
Discussion on dynamic CoAP mode in internet of things
JIN Zhi, LIU Rong
(School of Information Engineering, Changsha Medical University, Changsha 410219, China)
In order to balance the relationship between the delay and packet transmission reliability in internet of things, according to the characteristics of non-confirmable mode and confirmable mode in the constrained application protocol (CoAP), the paper studied on the CoAP mode: according to the condition of wireless channel, the expressions of data packet loss rate in the two modes of CoAP were deduced; the parameters were estimated by maximum likelihood estimation (MLE), and the data packet loss rates under the two modes were calculated then; finally the dynamic CoAP mode was used to balance the delay and data throughput with the requirement of the application layer on packet loss rate. Experimental result showed that the formula of packet loss rate could match the experimental data, meanwhile, dynamic CoAP mode could effectively balance the delay and throughput performance.
internet of things; constrained application protocol; packet loss rate; confirmable mode; non-confirmable mode
P228
A
2095-4999(2019)04-0024-06
金智, 劉蓉.面向物聯網應用的動態切換CoAP模式[J].導航定位學報,2019,7(4): 24-29.(JIN Zhi, LIU Rong.Discussion on dynamic CoAP mode in internet of things[J].Journal of Navigation and Positioning,2019,7(4): 24-29.)
10.16547/j.cnki.10-1096.20190405.
2019-05-07
湖南省教育廳重點項目(18A496)。
金智(1979—),女,長沙人,碩士,副教授,研究方向為無線網絡、面向服務計算。
劉蓉(1979—),女,長沙人,碩士,副教授,研究方向為項目管理、信息安全、軟件工程。