Review this C++ receive-window check. seq is a sequence number from the wire (uint32_t) and window is the configured window size.
seq
window