Sequence number wraparound underflow
Review this C++ receive-window check. `seq` is a sequence number from the wire (uint32_t) and `window` is the configured window size.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1class Receiver {
2public:
3 bool accept(uint32_t seq) {
4 if (!inWindow(seq, base_, window_)) {
5 return false; // drop: out of window
6 }
7 deliver(seq);
8 return true;
9 }
10private:
11 bool inWindow(uint32_t seq, uint32_t base, int window) {
12 int delta = seq - base;
13 return delta >= 0 && delta < window;
14 }
15 uint32_t base_; // lowest unacknowledged sequence number
16 int window_;
17};
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.