These two are different protocols that have different problems.
In the case of Go-Back-N, you are right. The window size can be up to 255. (2 ^ 8-1 is the last number of packets to send, starting from 0. And this is also the maximum window size for the Go-Back-N protocol.)
However, the Selective Repeat protocol has a window size limit to half the maximum q, because the receiver cannot distinguish a retransmitted packet with the same number # with the packet already included, but it is lost and was never sent to the sender in the previous window. Therefore, the window size should be in the half-range of seq # so that successive windows cannot duplicate each other.
Go-Back-N does not have this problem, because the sender pushes n packets to the window size (which is at max: n-1) and never slides through the window until it accumulates to n. And these two protocols have different windows of maximum size.
Note. For Go-Back-N, the maximum window size is the maximum number of unique sequence numbers - 1. If the window is equal to the maximum number of unique sequence numbers, if all confirmations are lost, the receiver will receive all retransmitted messages as a separate set of messages and forward messages to extra time for the application. To avoid this inconsistency, the maximum window size = the maximum number of unique serial numbers is 1. This answer was updated in accordance with the fact presented in the comment from @noamgot.
source share