0

My aim is to measure MQTT device-to-device message latency (not throughput) and I'm looking for feedback on my code-hacks. The setup is simple; just one device serving as two end-points (old Linux PC with two terminal sessions; one running the subscriber and the other running the publisher sample app) and the default broker at tcp://m2m.eclipse.org:1883). I inserted time-capturing code-fragments into the C-language publish/subscribe sample apps on the src/samples folder.

Below are the changes. Please provide feedback.

Changes to the subscribe sample app (MQTTAsync_subscribe.c)

Inserted the lines below at the top of the msgarrvd (message arrived) function

//print arrival time
struct timeval tv;
gettimeofday (&tv, NULL);
printf("Message arrived: %ld.%06ld\n", tv.tv_sec, tv.tv_usec);

Changes to the publish sample app (MQTTAsync_publish.c)

Inserted the lines below at the top of the onSend (callback) function

struct timeval tv;
gettimeofday (&tv, NULL);
printf("Message with token value %d delivery confirmed at %ld.%06ld\n",
               response->token, tv.tv_sec, tv.tv_usec);

With these changes (after subtracting the time message arrived at the subscriber from the time that the delivery was confirmed at the publisher), I get a time anywhere between 1 millisecond and 0.5 millisecond.

Questions

Does this make sense as a rough benchmark on latency?

Is this the round-trip time?

Is the round-trip time in the right ball-park? Should be less? more?

Is it the one-way time?

Should I design the latency benchmark in a different way? I need a rough measurements (I'm comparing with XMPP).

I'm using the default QoS value (1). Should I change it?

The publisher takes a finite amount of time to connect (and disconnect). Should these be added?

auro
  • 1,079
  • 1
  • 10
  • 22
  • I moved away from the asynchronous sample apps (for pub sub) to the synchronous sample apps and see a round-trip latency of 200 milliseconds. Can anyone comment on this number? – auro Aug 06 '14 at 15:59
  • 1
    Run your own broker, you have no idea how load my change on m2m.eclipse.org between each run, how it's average load may compare to your application and finally what hardware/network it's connected to – hardillb Dec 14 '14 at 23:25

1 Answers1

0

The 200ms latency is high ! Can you please upload your code here ?

Does this make sense as a rough benchmark on latency?

-- Yes it makes sense. But a better approach is to make an automated time subtract with subscribed message and both synchronized to NTP.

Is this the round-trip time? Is it the one-way time?

-- Messages got published - you received ACK for publisher and same message got transferred to subscribed client.

Is the round-trip time in the right ball-park? Should be less? more?

-- It should be less.

Should I design the latency benchmark in a different way? I need a rough measurements (I'm comparing with XMPP).

I'm using the default QoS value (1). Should I change it?

-- Try with QoS 0 ( fire and forget )

The publisher takes a finite amount of time to connect (and disconnect). Should these be added?

-- Yes. It needs to be added but this time should be very small.

surfnerd
  • 127
  • 2
  • 3
  • 9