viewof wakesPerDay = Inputs.range([1, 288], {
value: 96,
step: 1,
label: "Wake cycles per day"
})
viewof cellularRtt = Inputs.range([50, 500], {
value: 100,
step: 10,
label: "Cellular RTT (ms)"
})
viewof radioCurrent = Inputs.range([100, 500], {
value: 300,
step: 10,
label: "Radio current draw (mA)"
})
viewof batteryVoltage = Inputs.range([3.0, 5.0], {
value: 3.7,
step: 0.1,
label: "Battery voltage (V)"
})
viewof batteryCapacity = Inputs.range([500, 5000], {
value: 2000,
step: 100,
label: "Battery capacity (mAh)"
})
// RTT multipliers
k_http11 = 3.5
k_http2 = 2.5
k_http3 = 1.0
// Active time calculations (in seconds)
activeTime_http11 = wakesPerDay * k_http11 * (cellularRtt / 1000)
activeTime_http2 = wakesPerDay * k_http2 * (cellularRtt / 1000)
activeTime_http3 = wakesPerDay * k_http3 * (cellularRtt / 1000)
// Power and energy
power_W = (radioCurrent / 1000) * batteryVoltage
energy_http11 = activeTime_http11 * power_W
energy_http2 = activeTime_http2 * power_W
energy_http3 = activeTime_http3 * power_W
// Savings
savings_http2 = ((energy_http11 - energy_http2) / energy_http11 * 100)
savings_http3 = ((energy_http11 - energy_http3) / energy_http11 * 100)
// Battery life estimation (rough)
totalEnergy_mAh_http11 = (activeTime_http11 * radioCurrent) / 3600 // Convert to mAh
totalEnergy_mAh_http3 = (activeTime_http3 * radioCurrent) / 3600
dailySetupSaving_mAh = totalEnergy_mAh_http11 - totalEnergy_mAh_http3
html`<div style="background: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 4px solid #3498DB; margin-top: 15px;">
<p style="color: #2C3E50; margin-top: 0; font-weight: 700;">Energy Consumption Comparison</p>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 15px;">
<div style="background: white; padding: 15px; border-radius: 6px; border: 1px solid #dee2e6;">
<div style="color: #7F8C8D; font-size: 0.85em; text-transform: uppercase; margin-bottom: 5px;">HTTP/1.1</div>
<div style="font-size: 1.3em; font-weight: bold; color: #E67E22;">${energy_http11.toFixed(1)} J/day</div>
<div style="font-size: 0.85em; color: #7F8C8D; margin-top: 3px;">${activeTime_http11.toFixed(1)}s active</div>
</div>
<div style="background: white; padding: 15px; border-radius: 6px; border: 1px solid #dee2e6;">
<div style="color: #7F8C8D; font-size: 0.85em; text-transform: uppercase; margin-bottom: 5px;">HTTP/2</div>
<div style="font-size: 1.3em; font-weight: bold; color: #E67E22;">${energy_http2.toFixed(1)} J/day</div>
<div style="font-size: 0.85em; color: #7F8C8D; margin-top: 3px;">${activeTime_http2.toFixed(1)}s active</div>
</div>
<div style="background: white; padding: 15px; border-radius: 6px; border: 1px solid #dee2e6;">
<div style="color: #7F8C8D; font-size: 0.85em; text-transform: uppercase; margin-bottom: 5px;">HTTP/3 (0-RTT)</div>
<div style="font-size: 1.3em; font-weight: bold; color: #16A085;">${energy_http3.toFixed(1)} J/day</div>
<div style="font-size: 0.85em; color: #7F8C8D; margin-top: 3px;">${activeTime_http3.toFixed(1)}s active</div>
</div>
</div>
<div style="margin-top: 20px; padding: 15px; background: white; border-radius: 6px; border: 1px solid #dee2e6;">
<div style="color: #7F8C8D; font-size: 0.85em; margin-bottom: 10px;">ENERGY SAVINGS</div>
<div style="display: flex; gap: 20px;">
<div style="flex: 1;">
<div style="font-size: 0.85em; color: #7F8C8D; margin-bottom: 5px;">HTTP/2 vs HTTP/1.1</div>
<div style="font-size: 2em; font-weight: bold; color: #E67E22;">${savings_http2.toFixed(0)}%</div>
</div>
<div style="flex: 1;">
<div style="font-size: 0.85em; color: #7F8C8D; margin-bottom: 5px;">HTTP/3 vs HTTP/1.1</div>
<div style="font-size: 2em; font-weight: bold; color: #16A085;">${savings_http3.toFixed(0)}%</div>
</div>
</div>
</div>
<div style="margin-top: 15px; padding: 12px; background: #e8f5f2; border-radius: 6px; font-size: 0.9em; color: #2C3E50;">
<strong>Setup-only estimate:</strong> Under the chosen assumptions, resumption saves about <strong>${dailySetupSaving_mAh.toFixed(2)} mAh/day</strong> of radio current, reducing modeled setup time from ${activeTime_http11.toFixed(1)}s to ${activeTime_http3.toFixed(1)}s per day. The ${batteryCapacity}mAh battery's lifetime also depends on payload transfer, idle tails, sleep current, and usable capacity.
</div>
</div>`Interactive Calculator: QUIC 0-RTT Setup Energy
Interactive Calculator: QUIC 0-RTT Setup Energy
animation
http
protocols
Try Increase "Wake cycles per day" while keeping "Cellular RTT (ms)" unchanged. Then press Calculate setup energy.
Observe Watch HTTP/1.1 and HTTP/3 (0-RTT) J/day as "Wake cycles per day" changes.
Explain Explain why "Cellular RTT (ms)" changes modeled setup time and energy after you press Calculate setup energy.
Technical boundaries. This estimates radio energy for connection setup under chosen 0-RTT resumption assumptions, not whole-device battery life. Payload transfer, idle tails, sleep current, and usable capacity also affect lifetime.