I was trying to understand how TCP works (not in detail of course). I was surfing the web for easy-to-understand flow diagrams and a question arose and couldn't find a straight answer.
Let's suppose that we have this nice flow where everything is sync (ignore the ending part with FIN and crossing packets):
I would like to know what would happen if both A and B would want to send packets at the same time (from what I understand TCP is a bidirectional protocol so each entity can send whenever it wants). Basically how the sequence numbers would behave. Having crossing data packets.
Also I read that TCP is a SWP (Sliding window protocol), I would like to know how ACKs are formed in this case. TCP is responding with number of bytes basically as Seq number, I can't really imagine how that can happen inside a window (where you can receive in any order). Is the implementation using two sets of seq numbers and two windows for both receiver and sender?
Any spec references or other helpful resources are more than welcome.