怎样测试mqtt协议实现im功能的publish的速度

&&国之画&&&& &&&&&&
&& &&&&&&&&&&&&&&&&&&&&
鲁ICP备号-4
打开技术之扣,分享程序人生!今天看啥 热点:
[5] MQTT,mosquitto,Eclipse Paho---MQTT消息格式分析概述,mqttpaho---mqtt
我们知道MQTT是一个物联网协议的一个规范,MQTT的协议最新的两个版本是:3.1.1和3.1.0
(1) 3.1.0的规范如下
http://public./software/dw/webservices/ws-mqtt/mqtt-v3r1.html
(2) 3.1.1的规范如下
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc
规范3.1.0和3.1.1还是有不少的区别。比如可变头部中,在3.1.0的规范中,其关键字是,“MQISdP”
表1. MQTT V3.1规范可变消息头的前8个字节
Description
Protocol Name
Length MSB (0)
Length LSB (6)
而在MQTT V3.1.1的规范中,其可变消息的头的协议名称的关键字是“MQTT”.如下图所示意.
表2.&MQTT V3.1.1可变消息头的前6个字节
Length MSB (0)
Length LSB (4)
Protocol Level
规范主要描述了消息的通用格式,消息的命令,消息流动等等的规范和规则。在前面的四个章节,我们对MQTT有了一个感性的大概认识,在接下来的系列文章,我将带大家把MQTT的下面14种命令消息通过抓包软件(WireShark)并结合具体的规范和大家全部过一遍。 注意,因为我用的Eclipse Paho API的java库,支持MQTT 3.1.1 的版本,且mosquitto也支持3.1.1的版本,所以本系列所有的抓包都会是基于MQTT 3.1.1的规范,而不是MQTT 3.1的规范,请大家注意。下面的表格描述了MQTT的14中不同的消息类型。
表3. MQTT的14种消息类型(Command message)
信息流方向
Client to Server
Client request to connect to Server
Server to Client
Connect acknowledgment
Client to Server
&&&&&&&&& or
Server to Client
Publish message
Client to Server
&&&&&&&&& or
Server to Client
Publish acknowledgment
Client to Server
&&&&&&&&& or
Server to Client
Publish received (assured delivery part 1)
Client to Server
&&&&&&&&& or
Server to Client
Publish release (assured delivery part 2)
Client to Server
&&&&&&&&& or
Server to Client
Publish complete (assured delivery part 3)
Client to Server
Client subscribe request
Server to Client
Subscribe acknowledgment
UNSUBSCRIBE
Client to Server
Unsubscribe request
Server to Client
Unsubscribe acknowledgment
Client to Server
PING request
Server to Client
PING response
DISCONNECT
Client to Server
Client is disconnecting
在接下来的章节我们将会逐一个给大家用WireShark抓包,并给大家一个一个分析其协议,敬请期待和关注,谢谢。
相关搜索:
相关阅读:
相关频道:
Android教程最近更新MQTT协议简记_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
MQTT协议简记
上传于||暂无简介
阅读已结束,如果下载本文需要使用1下载券
想免费下载本文?
下载文档到电脑,查找使用更方便
还剩1页未读,继续阅读
你可能喜欢mqtt向android推送消息(一)――发送端使用.net-asp.net-电脑编程网mqtt向android推送消息(一)――发送端使用.net作者:tedeum 和相关&&
使用.net进行mqtt协议通讯,主要是为了开发居于mqtt协议向android推送消息,使用.net开发可以参考mqtt.org上面的库,我用的是M2MQTT,网上资料很少,具体例子如下:一、消息发布:
if (this.sender == null)
this.sender = new MqttClient(IPAddress.Parse(host), 1883);
//var mqttClient = new MqttClient("localhost");
this.sender.Connect("sender");
this.sender.Publish("mobileGKTopic", System.Text.Encoding.Default.GetBytes(textBox2.Text));
二、消息接收
mqttClient = new MqttClient(IPAddress.Parse(host), 1883);
//mqttClient = new MqttClient("localhost");
mqttClient.Connect("Receiver");
mqttClient.MqttMsgPublishReceived += new MqttClient.MqttMsgPublishEventHandler(mqttClient_MqttMsgPublishReceived);
mqttClient.Subscribe(new string[] { "testTopic" }, new byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE });
private void mqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
//throw new NotImplementedException();
var msg = System.Text.Encoding.Default.GetString(e.Message);
if (!String.IsNullOrEmpty(msg))
textBox1.AppendText(Environment.NewLine);
textBox1.AppendText(msg);
需要注意的是,编译mqtt库时要把条件编译SSL关闭,SSL的编译我还没有高清。
相关资料:||||mqtt向android推送消息(一)――发送端使用.net来源网络,如有侵权请告知,即处理!编程Tags:                &                    

我要回帖

更多关于 mqtt协议详解 的文章

 

随机推荐