Applicable Versions | Applicable to all Versions |
Applicable Releases | v13 |
MQTT (Message Queuing Telemetry Transport) is a lightweight, publish-subscribe messaging protocol designed for low-bandwidth, unreliable networks. It is one of the most popular protocols for the Internet of Things (IoT) and M2M (Machine-to-Machine) communication.
The following method can be used to model a simple MQTT application using HTTP. In this scenario, we'll use GET requests to simulate both publishing and subscribing to topics.
1. Topic as HTTP Request URL: We can use the HTTP Request from client to server to represent MQTT topics. A separate HTTP application can be configured for each topic from the respective client.
2. Publishing to a Topic: To simulate publishing a message to an MQTT topic, use the HTTP Request parameters. For publishing, again we'll use HTTP GET requests from the clients. Configure the Inter Arrival Time (in seconds) for each client to control the publishing frequency. When a client wants to publish a message, it will send a GET request to the corresponding server. Please note that here the server need not send anything back in response. So, in this case, the page size can be set to the minimum possible value.
3. Subscribing to a Topic: To simulate subscribing to an MQTT topic, again use the HTTP Request parameters. Configure the Inter Arrival Time (in seconds) for each client to represent the subscribing frequency. When a client wants to subscribe to a topic, it will send a GET request to the corresponding server node. The server will respond with an HTTP response, whose Page size can be set corresponding to the topic.
4. Message Size and Page Properties: Use the HTTP Page Properties to simulate the size of MQTT messages. Configure the Page size Distribution (Constant or Exponential) and Page size in bytes to represent the variability in message sizes. The server's HTTP pages will contain the messages to be sent back as responses to subscribers.
5. Broker/Server Handling: The HTTP server can be treated as the broker. The server will handle incoming GET requests from clients for both publishing and subscribing. For publishing, the server will not send any reply. For subscribing, the server will respond with the HTTP page.
6. Client and Server IDs: As before, configure unique client and server IDs for each HTTP application to differentiate between multiple publishers and subscribers in the simulation.
Here's the updated example of how the HTTP application model in NetSim might look like:
Consider an IoT network in NetSim with devices Wireless_Sensor_1, Wireless_Sensor_2, Wireless_Sensor_3, Wireless_Sensor_4, Wireless_Sensor_5, 6_LOWPAN_GATEWAY_6, ROUTER_7, WIRED_NODE_8
- Topic: Temperature
- HTTP Application 1
- Application name: MQTT Publishing-Temperature
- Server: Wired_Node_8
- Client: Wireless_Sensor_1
- Inter Arrival Time:
- Distribution: Exponential (for publishing frequency)
- Time(s): 5 - Page Properties:
- Page size Distribution: Exponential (for message size variability)
- Page size in bytes: 2 (for example)
- Page count: 1 (for example)
- HTTP Application 2
- Application name: MQTT Subscribing-Temperature
- Server: Wired_Node_8
- Client: Wireless_Sensor_1
- Inter Arrival Time:
- Distribution: Exponential (for publishing frequency)
- Time(s): 15 - Page Properties:
- Page size Distribution: Exponential (for message size variability)
- Page size in bytes: 100 (for example)
- Page count: 10 (for example)
- HTTP Application 3
- Application name: MQTT Publishing-Humidity
- Server: Wired_Node_8
- Client: Wireless_Sensor_2
- Inter Arrival Time:
- Distribution: Constant (for publishing frequency)
- Time(s): 8 - Page Properties:
- Page size Distribution: Constant (for message size)
- Page size in bytes: 2 (for example)
- Page count: 1 (for example)
- HTTP Application 4
- Application name: MQTT Subscribing-Humidity
- Server: Wired_Node_8
- Client: Wireless_Sensor_2
- Inter Arrival Time:
- Distribution: Constant (for publishing frequency)
- Time(s): 10 - Page Properties:
- Page size Distribution: Constant (for message size)
- Page size in bytes: 50 (for example)
- Page count: 5 (for example)
- HTTP Application 1