Interface Throughput From Wrapping Hardware Counters

Last updated: November 29, 2026

Quick Overview

Given periodic samples of an interface byte counter that is only 32 bits wide, compute the bits-per-second rate for each interval, correctly handling counter wraparound and bad timestamps.

Arista Networks
Coding & Algorithms
Software Engineer
Arista Networks
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given periodic samples of an interface byte counter that is only 32 bits wide, compute the bits-per-second rate for each interval, correctly handling counter wraparound and bad timestamps.

Interface counters read from switch hardware and SNMP are fixed width, and at 100G a 32-bit octet counter wraps in about a third of a second. The interviewer checks modular arithmetic and whether you know when a computed rate cannot be trusted.

What the Interviewer Expects
  • Compute deltas modulo 2^width to absorb a wrap
  • Convert octets to bits and divide by elapsed time
  • Skip intervals with non-positive elapsed time
  • Explain that more than one wrap per interval is undetectable
  • Mention counter resets (clear counters, agent restart) as a separate case
Key Topics to Cover
modular arithmetic
counters
telemetry
rate calculation
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • At what poll interval does a 32-bit octet counter become unusable on a 100G port?
  • How would you tell a wrap apart from a counter reset?
  • How would you smooth the rate (EWMA) for a dashboard?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: time-ordered (timestamp_seconds, octets) samples and a counter width (default 32). Output: one rate per adjacent pair in bits per second, or None when the interval is invalid....

High-Level Design

The counter is a value mod 2^w, so the true increase (assuming at most one wrap) is (c1 - c0) mod 2^w. In Python % with a positive modulus always returns a non-negative result, so a wrap like 4294...


Submit Your Answer
Markdown supported

Related Questions