How can tcp handle urgent data




















A recipient of a TCP segment with the Urgent flag enabled must add the value provided in the Urgent Pointer to the Sequence Number field of the current segment, and use the resulting value to determine the ending sequence number. What this means is that the Urgent Pointer off-set can refer to a byte location in another TCP segment, allowing urgent data to span across multiple segments if needed.

This mechanism reflects a specific design as mandated in RFC Instead, TCP provides an urgent mode. Assume a process has written N bytes of data to a TCP socket and that data is queued by TCP in the socket send buffer, waiting to be sent to the peer.

We show this in Figure TCP places the data in the next available position in the socket send buffer and sets its urgent pointer for this connection to be the next available location. As discussed on pp. Given the state of the TCP socket send buffer shown in Figure But this segment may or may not contain the byte that we have labeled as OOB. Whether the OOB byte is sent depends on the number of bytes ahead of it in the socket send buffer, the segment size that TCP is sending to the peer, and the current window advertised by the peer.

We have used the terms urgent pointer and urgent offset. At the TCP level, the two are different. The bit value in the TCP header is called the urgent offset and it must be added to the sequence number field in the header to obtain the bit urgent pointer. TCP looks at the urgent offset only if another bit in the header is set, and this bit is called the URG flag.

From a programming perspective, we need not worry about this detail and just refer to TCP's urgent pointer. Indeed, if the sending TCP is stopped by flow control the receiver's socket receive buffer is full, so its TCP has advertised a window of 0 to the sending TCP , the urgent notification is sent without any data pp.

This is one reason why applications use TCP's urgent mode i. The intelligible RFC , pages says:. Considering that as long as both the TCP sender and the TCP receiver implement the same semantics for the Urgent Pointer there is no functional difference in having the Urgent Pointer point to "the sequence number of the octet following the urgent data" vs.

Note: Linux provides the net. You can gain urgent data in two ways keep in mind that the TCP concept of "urgent data" is mapped to the socket API as "out-of-band data" :. The data will be read separately from the normal data stream. The data remain "in-line". And you can determine the Urgent Pointer with a help of ioctl :.

Besides it is recommended for new applications not to use the mechanism of urgent data at all to use if so receiving in-line, as mentioned above. From RFC TCP does not attempt to define what the user specifically does upon being notified of pending urgent data.

Accordingly, the answer to your question about acknowledgements when all other data was dropped is "You can implement it in your application". As for tcp-ack, I found nothing special about it in the case of urgent data. Almost all implementations really can provide only one byte of "out-of-band data". RFC says:. If successive indications of "urgent data" are received before the application reads the pending "out-of-band" byte, that pending byte will be discarded i.

So TCP urgent mode and its urgent pointer cannot provide marking the boundaries of the urgent data in practice.

Rumor has it that there are some implementations that queue each of the received urgent bytes. Some of them have been known to fail to enforce any limits on the amount of "urgent data", that they queue. The pseudo header is a combination of 5 different fields, used during the calculation of the TCP checksum.

It is important to note and remember! When the segment arrives at its destination and is processed through the OSI layers, once the transport layer Layer 4 is reached, the receiver will recreate the pseudo header in order to recalculate the TCP header checksum and compare the result with the value stored in the segment it has received.

If we assume the segment somehow managed to find its way to a wrong machine, when the pseudo header is recreated, the wrong IP Address will be inserted into the Destination IP Address field and the result will be an incorrect calculated checksum.

Therefore, the receiver that wasn't supposed to receive the segment will drop it as it's obviously not meant to be there. Now you know how the checksum field guarantees that the correct host will receive the packet, or that it will get there without any errors!

However, be sure to keep in mind that even though these mechanisms exist and work wonderfully in theory, when it comes to the practical part, there is a possibility that packets with errors might make their way through to the application! It's quite amazing once you sit down and think for a minute that this process happens for every single packet that is sent and received between hosts that use TCP and UDP UDP calculates the same way its checksum as their transport protocol!

Lastly, during the TCP header checksum calculation, the field is set to zero 0 as shown below. This action is performed only during the checksum calculation on either end because it is unknown at the time. Once the value is calculated, it is then inserted into the field, replacing the inital zero 0 value. In summarising the procedure followed when calculating the checksum, the following process occurs, from the sender all the way to the receiver:.

The sender prepares the segment that is to be sent to the receiving end. The checksum is set to zero, in fact 4 zeros hex or 8 zeros if you look at it in binary, because the checksum is an 8 bit field. The checksum in then calculated using the pseudo header, TCP header and lastly the data to be attached to the specific segment.

The result is then stored in the checksum field and the segment is sent! The segment arrives at the receiver and is processed. The receiver will then create its own pseudo header for the segment received by entering its own IP Address in the Destination IP Address field as shown in the previous diagrams and makes use of the TCP header and data to calculate the new checksum. If all is successfully accomplished, the result should be identical with the one the checksum field segment had when it arrived.

When this occurs, the packet is then further processed and the data is handed to the application awaiting it. If, however, the checksum is different, then the packet should be discarded dropped and a notification will be sent to the receiver depending on how the TCP stack is implemented on the receiver's operating system. The urgent pointer flag in the TCP Flag allows us to mark a segment of data as 'urgent', while this urgent pointer field specifies where exactly the urgent data ends.

You may also be interested to know that the Urgent Pointer can also be used when attacking remote hosts. From the case studies we have analysed, we see that certain applications, which supposedly guard your system from attack attempts, do not properly log attacks when the URG flag is set.

One particular application happens to be the famous BlackIce Server v2.



0コメント

  • 1000 / 1000