viewof fleetSize = Inputs.range([100, 10000], {
value: 5000,
step: 100,
label: "Number of devices"
})
viewof updateInterval = Inputs.range([10, 600], {
value: 30,
step: 10,
label: "Update interval (seconds)"
})
viewof payloadSize = Inputs.range([8, 256], {
value: 32,
step: 8,
label: "Payload size (bytes)"
})
viewof binaryPayloadSize = Inputs.range([4, 128], {
value: 9,
step: 1,
label: "Illustrative binary payload (bytes)"
})
viewof cellularCost = Inputs.range([0.1, 2], {
value: 0.5,
step: 0.1,
label: "Cellular cost ($/GB)"
})Protocol Migration Cost Analysis
Protocol Migration Cost Analysis
animation
http
protocols
Try Change Update interval (seconds) while keeping the payload sizes fixed. Then press Calculate cellular cost.
Observe After pressing Calculate cellular cost, watch GB/month and cost reduction as Update interval (seconds) changes.
Explain Explain why Illustrative binary payload (bytes) changes MQTT and HTTP/2 costs.
Technical boundaries. The comparison counts listed bytes only and uses decimal units with 30-day months. MQTT includes an illustrative uplink keepalive allowance; HTTP/2 assumes two fresh TLS setups per day.
NoteInteractive: Protocol Migration Cost Analysis
Compare the same listed-byte assumptions for fresh HTTPS POST, MQTT, and reused HTTP/2 in your IoT fleet:
{
const updatesPerDay = (24 * 3600) / updateInterval;
// Fresh HTTPS POST per reading; listed components only, decimal units
const httpOverhead = 180 + 6000 + 400 + 200 + 160; // TCP + TLS + headers + response + teardown
const httpBytesPerUpdate = httpOverhead + payloadSize;
const httpDailyPerDevice = (httpBytesPerUpdate * updatesPerDay) / 1e6; // MB
const httpMonthlyGB = (httpDailyPerDevice * fleetSize * 30) / 1000;
const httpMonthlyCost = httpMonthlyGB * cellularCost;
// MQTT persistent
const mqttBytesPerUpdate = 14 + binaryPayloadSize;
const mqttKeepalive = (2 * (24 * 3600) / 60); // illustrative uplink PINGREQ allowance
const mqttDailyPerDevice = ((mqttBytesPerUpdate * updatesPerDay) + mqttKeepalive) / 1e6;
const mqttMonthlyGB = (mqttDailyPerDevice * fleetSize * 30) / 1000;
const mqttMonthlyCost = mqttMonthlyGB * cellularCost;
// HTTP/2 optimized
const http2BytesPerUpdate = 15 + binaryPayloadSize; // assumed HPACK-compressed fields
const http2Setup = 2 * 6000; // assumed two fresh TLS setups per day
const http2DailyPerDevice = ((http2BytesPerUpdate * updatesPerDay) + http2Setup) / 1e6;
const http2MonthlyGB = (http2DailyPerDevice * fleetSize * 30) / 1000;
const http2MonthlyCost = http2MonthlyGB * cellularCost;
const httpSavings = httpMonthlyCost - mqttMonthlyCost;
const httpAnnualSavings = httpSavings * 12;
const protocols = [
{name: "Fresh HTTPS POST", cost: httpMonthlyCost.toFixed(2), gb: httpMonthlyGB.toFixed(1), color: "#E67E22"},
{name: "MQTT Persistent", cost: mqttMonthlyCost.toFixed(2), gb: mqttMonthlyGB.toFixed(1), color: "#16A085"},
{name: "HTTP/2 Optimized", cost: http2MonthlyCost.toFixed(2), gb: http2MonthlyGB.toFixed(1), color: "#3498DB"}
];
const maxCost = Math.max(...protocols.map(p => parseFloat(p.cost)));
return html`
<div style="font-family: Arial, sans-serif; padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #2C3E50;">
<p style="margin-top: 0; margin-bottom: 0.8em; color: #2C3E50; font-weight: 700; font-size: 1.1em;">Monthly Cellular Cost Comparison</p>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin: 20px 0;">
${protocols.map(p => `
<div style="background: white; padding: 15px; border-radius: 6px; border-top: 3px solid ${p.color};">
<div style="font-size: 0.9em; color: #7F8C8D; margin-bottom: 5px;">${p.name}</div>
<div style="font-size: 1.8em; font-weight: bold; color: ${p.color};">$${p.cost}</div>
<div style="font-size: 0.9em; color: #7F8C8D; margin-bottom: 10px;">per month</div>
<div style="width: 100%; height: 8px; background: #e0e0e0; border-radius: 4px; overflow: hidden;">
<div style="width: ${(parseFloat(p.cost) / maxCost * 100).toFixed(1)}%; height: 100%; background: ${p.color};"></div>
</div>
<div style="font-size: 0.8em; color: #7F8C8D; margin-top: 5px;">${p.gb} GB/month</div>
</div>
`).join('')}
</div>
<div style="background: white; padding: 15px; border-radius: 6px;">
<strong style="color: #16A085;">Annual savings (HTTP → MQTT): $${httpAnnualSavings.toFixed(2)}</strong><br/>
<span style="color: #7F8C8D; font-size: 0.9em;">
Fleet: ${fleetSize.toLocaleString()} devices × ${updatesPerDay.toFixed(0)} updates/day<br/>
Useful payload fraction of fresh HTTPS: ${(payloadSize / httpBytesPerUpdate * 100).toFixed(1)}%;
MQTT counted bytes/update: ${mqttBytesPerUpdate}<br/>
Cost reduction: ${((httpMonthlyCost - mqttMonthlyCost) / httpMonthlyCost * 100).toFixed(1)}%
</span>
</div>
</div>
`;
}