试试支持 DTLS 的 FreeCoAP
原创
©著作权归作者所有:来自51CTO博客作者zoomdy的原创作品,请联系作者获取转载授权,否则将追究法律责任
FreeCoAP 是 C 语言实现的 CoAP 服务器、客户端、HTTP/CoAP 代理。FreeCoAP 支持 DTLS ,引用的是 GnuTLS 库的 DTLS 。
mingdu.zheng at gmail dot com
系统环境是 Xubuntu 16.04,理论上其他版本的 Ubuntu 都可以。
首先安装必要的工具:
$ sudo apt update
$ sudo apt install git autoconf libtool-bin libgnutls-dev wireshark-qt
从 github 克隆 FreeCoAP:
$ git clone https://github.com/keith-cullen/FreeCoAP ~/FreeCoAP
编译 FreeCoAP:
$ cd ~/FreeCoAP
$ autoreconf --install
$ ./configure
$ make
编译 Demo:
$ cd ~/FreeCoAP/sample/time_server
$ make
$ cd ~/FreeCoAP/sample/time_client
$ make
调用 tcpdump 捕获通信数据包:
$ sudo tcpdump -i lo -w ~/dtls.pcap "udp port 5684"
打开一个新的终端,运行 Demo 的服务器:
$ cd ~/FreeCoAP/sample/time_server
$ ./time_server 0.0.0.0 5684
再打开一个新的终端,运行 Demo 的客户端
$ cd ~/FreeCoAP/sample/time_client
$ ./time_client 127.0.0.1 5684
在运行 tcpdump 命令的终端按下 Ctrl+C 结束数据包捕获,使用 wireshark 查看捕获的数据包: