I want to build such a system, there are 3 nodes, A, B and C A and B establish a TCP connection, then A tell C the ports, sequence number (seq_no)and Acknowlegement sequence number(ack_seq_no). Then C sends packet to B (C and A share the same IP but they are far away from each other, e.g, C spoof IP of A)
if B never sends data packets to IP(A)(only ACK), C can send packets to B with correct seq_no and ack_seq_no but sometimes if B send a data packet P1to IP(A),
1 A immediately send ACK for the data packet P1 to B, and A tell C the new ack_seq_no. But there is a delay between A and C, so before C knows the new ack_seq_no C may send some data packets(with spoofed IP(A)) to B with obsolete ack_seq_no.
my first question is: what will C behave when it receives a data packet with obsolete ack_seq_no
2 if I delay the ACK for p1 from A to B, I let A tell C first, and then sends the ACK for p1. there are 2 questions:
1) since B is waiting for the ACK of p1 from A, it may retransmit the packet p1, how to increase the retransmission timeout? if each time A reply with the ACK with such a delay, the timeout will be naturally increased, then it is not a problem?
2) if C sends data packets to B(with IP of A) before the ACK(for p1) from A to B. This means the data packets are with updated ack_seq_no, but B doesn't know whether its new ack_seq_no has been known by A or not(coz ACK hasn't arrived yet), so it may regard the ACK is piggybacked over the data packets? then how will B deal with the late ACK?
If an obsolete ACK is received, the ACK will be ignored (it's assumed to be an old packet that was delayed). Every ACK acknowledges everything leading up to it (I'm assuming you're not sending selective ACKs).
The sender should adjust its retransmission timeouts based on the acknowledgement response times.
B can't tell the difference between an ACK from A or C. As far as it's concerned, this is the same as question #1 -- the late ACK will be ignored.
Related
I read in my network textbook that in a TCP communication between host A and host B, if A sends an FIN to B, B will send an ACK back to A (suppose the Ack number of this packet is x) and enter the CLOSE-WAIT state. Then, B may still want to send some data to A. If not, B will right away sends back an FIN to A. No matter which case, the Ack number of this FIN sent by B should also be x.
My question is: When B is sending data in CLOSE-WAIT state, will it still receive ACK from A? If so, considering that the Ack number of the FIN to be sent by B should also be x, what will the SEQ of these ACK sent by A be? In other words, what will the Ack number of the packets sent by B in CLOASE-WAIT state be? Are all of them also x? If not, how could B know whether A has received the data or not?
I tried to search CLOSE-WAIT send data and something like this on Google but didn't find anything about this. And I also tried to search CLOSE-WAIT in RFC 793 but still didn't find anything about this question while browsing. It seems that I didn't use the correct keywords for retrieval.
I would be very grateful if you could attach the related contents in the RFC.
I was reading a book about computer network written by Tanenbaum specifically about handshaking. In there he explains two-way handshake is not enough, considering this case:
A wants to transfer money to B, so A sends a SYN to B, and then B sends an ACK to A. Connection is established and then A can send his money and then drop the connection after it's done. If there is a delayed duplicate SYN from A to B, B will send its ACK again and A will be transferring its money again.
That is one of the weakness of two-way handshake based on the book written by Tanenbaum if I understands it right. The book says three-way handshake can solve this problem.
With a delayed duplicate SYN from A, B sends an ACK and SYN which get rejected by A. This is where I don't get it, it's as if "Hey B why do you send me a SYN and ACK? Oh I know, this is from a delayed SYN, I should just drop it.". Why not, in two-way handshake, A doesn't know that the ACK is made by a delayed duplicate SYN?
Thanks.
To establish a connection, the three-way (or 3-step) handshake occurs:
SYN: The active open is performed by the client sending a SYN to the server. The client sets the segment's sequence number to a random value A.
SYN-ACK: In response, the server replies with a SYN-ACK. The acknowledgment number is set to one more than the received sequence number i.e. A+1, and the sequence number that the server chooses for the packet is another random number, B.
ACK: Finally, the client sends an ACK back to the server. The sequence number is set to the received acknowledgement value i.e. A+1, and the acknowledgement number is set to one more than the received sequence number i.e. B+1.
At this point, both the client and server have received an acknowledgment of the connection. The steps 1, 2 establish the connection parameter (sequence number) for one direction and it is acknowledged. The steps 2, 3 establish the connection parameter (sequence number) for the other direction and it is acknowledged. With these, a full-duplex communication is established.
According to Kurose and Ross's "Computer Networking: A top-down approach", 6th Edition, p. 232,
The first two segments carry no payload, that is, no application-layer data; the third of these segments may carry a payload. Because three segments are sent between the two hosts, this connection-establishment procedure is often referred to as a three-way handshake
In other words, A does not need to wait for the three-way handshake to complete before sending data. Only B needs to wait for the three-way handshake to complete.
And why does B need to wait? As S. Richmond says, B needs to know that A has received its sequence number before it starts sending data.
The three-way handshake is necessary because both parties need to synchronize their segment sequence numbers used during their transmission.
So, they(in turn) send a SYN segment with a sequence number set to a value n, which then is acknowledged by the other party via a ACK segment with a sequence number set to n+1.
Suppose that client does not send ACK(case of 2 way handshake). Now there might exist a case where seq number of client is not synchronized, but the server will assume that it is synchronized. This could cause a problem.
if there is a tcp connection between A and B,
A send some packets and then a TCP RST(or TCP FIN/ACK) to close the connection,
let me say?
PKT1, PKT2, PKT3, TCP_RST
or
PKT1, PKT2, PKT3, TCP_FIN/ACK
but the packet arrival is out of order
PKT1, TCP_RST(or TCP_FIN/ACK), PKT2, PKT3
then how will B react?
according to the sequence number of TCP_RST and TCP_FIN/ACK,
B knows there are some packets missing(PKT2 and PKT3),
will B wait for PKT2 and PKT3 before it close the connection,
or B immediately close the connection when it receives TCP_RST(or TCP_FIN/ACK)?
thanks
The TCP protocol will reorder the packets before sending them further up the stack. This means it will wait for out of order packets according to the sequence number, ask for retransmission if needed, etc. and wait for the last ack before closing the connection.
You can find the TCP state diagram here:
http://www.ssfnet.org/Exchange/tcp/tcpTutorialNotes.html#ST
TCP guarantees sequence. That includes the sequence of the EOS. It must be delivered after all the data.
Can anyone please let me know the procedures that happens in closing a tcp connection.
suppose there is A(Client) and B(Server) that A establish a TCP connection
A is creating a TCP connection with B
In opening a connection what happens if SYN packet from A drops in reaching the B, even if u do some retransmissions.
What happens if SYN+ACK drops in the network if B sending the packet to A.
What happens if ACK drops in the network from A to B.
A is closing the connection with B.
In closing a connection what happens if FIN packet from A drops in reaching the B, even if u do some retransmissions.
What happens if FIN+ACK drops in the network if B sending the packet to A.
What happens if ACK drops in the network from A to B.
Initial SYN packets are re-transmitted with an exponential backoff, usually starting at 2 seconds. I.e. 2s, 4s, 8s, 16s, etc.
The same goes for re-transmitted SYN-ACK packets (though there are some odd implementations that you really don't want to know about).
No ACK is ever re-transmitted blindly. If the other side re-transmits a packet, then another ACK will be sent.
The above is true for FIN as well, just substitute FIN where you see SYN. Of course, the starting re-transmit time is not 2s but whatever has been calculated to be the round-trip-time over the course of the session.
A SYN/FIN packet is treated the same as a data packet with regard to re-transmissions and reliability. Those flags even take up a sequence number so they can be properly tracked.
Say our client is sending the packets at a constant rate. Now, if server goes down temporarily there can be two situations
(We are using the TCP protocol)
1) The packet won't be delivered to the server. Consequently, the other packets in the line have to wait for the server to respond. And the communication can be carried out from there.
2) The packet won't be delivered and will be tried again, but the other packages won't be affected by this packet.
Say, packets A, B and C are to be transferred. While I am sending packet A the server goes down temporarily, then the packets B and C will be sent at the time they were initially scheduled to be or they will be sent once A is received by the server.
TCP is a stream-oriented protocol. This means that if, on a single TCP connection, you send A followed by B then the reciever will never see B until after it has seen A.
If you send A and B over separate TCP connections, then it is possible for B to arrive before A.
When you say "goes down temporarily", what do you mean? I can see two different scenarios.
Scenario 1: The connection between Server and Client is interrupted.
Packet A is sent on its way. Unfortunately, as it is winding its ways through he cables, one cable breaks and A is lost. Meanwhile, depending on the exact state of the TCP windowing algorithm, packets B and C may or may not be sent (as that would depend on the window size, the size of A/B7C and the amount of as-yet unacknowledged bytes sent). I guess that is saying both your "1" and "2" may be right?
If B and/or C have been sent, there will be no ack of A, until it has been resent. If they have been sent, once A has arrived, the server will ack up until the end of the last frame received in sequence (so, C, if taht is the case).
Scenario 2: The sever goes down
If this happens, all TCP state will be lost and connections will have to be re-established after the server has finished rebooting.