Detailed Discussion of the Problems (1-3)
4. Detailed Discussion of the Problems
Problem 1: Failure to Insert Last Fragment
This problem occurs in the decision table corresponding to the state reassembling and the input "receive from lower layer" [MILS83a, sec 9.4.6.1.3]. The problem occurs in the following row of this table:[2]
________________________________________________________
check- SNP TTL where a reass ICMP
sum params valid to frag done check-
valid? valid? ? ? ? ? sum?
__________________________________________________________________
YES YES YES ULP YES YES d reass_
delivery;
state :=
INACTIVE
__________________________________________________________________
The reass_done function, as will be seen below, returns YES if the fragment just received is the last fragment needed to assemble a complete datagram and NO otherwise. The action procedure reass_delivery simply delivers a completely reassembled datagram to the upper-level protocol. It is the action procedure reassemble that inserts an incoming fragment into the datagram being assembled. Since this row does not call reassemble, the result will be that every incoming fragmented datagram will be delivered to the upper layer with one fragment missing. The solution is to rewrite this row of the table as follows:
________________________________________________________
check- SNP TTL where a reass ICMP
sum params valid to frag done check-
valid? valid? ? ? ? ? sum?
__________________________________________________________________
YES YES YES ULP YES YES d reassemble;
reass_
delivery;
state :=
INACTIVE
__________________________________________________________________
Incidentally, the mnemonic value of the name of the reass_done function is questionable, since at the moment this function is called datagram reassembly cannot possibly have been completed. A better name for this function might be last_fragment.
Problem 2: Missing State Transition
This problem is the omission of a row of the same decision table [MILS83a, sec 9.4.6.1.3]. Incoming packets may be directed to an upper-level protocol (ULP), or they may be network control messages, which are marked ICMP (Internet Control Message Protocol). When control messages have been completely assembled, they are processed by an IP procedure called analyze. The decision table contains the row
________________________________________________________
check- SNP TTL where a reass ICMP
sum params valid to frag done check-
valid? valid? ? ? ? ? sum?
__________________________________________________________________
YES YES YES ICMP YES NO d reassemble;
__________________________________________________________________
but makes no provision for the case in which where_to returns ICMP, a_frag returns YES, and reass_done returns YES. An additional row should be inserted, which reads as follows:
________________________________________________________
check- SNP TTL where a reass ICMP
sum params valid to frag done check-
valid? valid? ? ? ? ? sum?
__________________________________________________________________
YES YES YES ICMP YES YES d reassemble;
analyze;
state :=
INACTIVE
__________________________________________________________________
Omitting this row means that incoming fragmented ICMP messages will never be analyzed, since the state machine does not have any action specified when the last fragment is received.
Problem 3: Errors in reass_done
The function reass_done, as can be seen from the above, determines whether the incoming subnetwork packet contains the last fragment needed to complete the reassembly of an IP datagram. In order to understand the errors in this function, we must first understand how it employs its data structures.
The reassembly of incoming fragments is accomplished by means of a bit map maintained separately for each state machine. Since all fragments are not necessarily the same length, each bit in the map represents not a fragment, but a block, that is, a unit of eight octets. Each fragment, with the possible exception of the "tail" fragment (we shall define this term below), is an integral number of consecutive blocks. Each fragment's offset from the beginning of the datagram is given, in units of blocks, by a field in the packet header of each incoming packet. The total length of each fragment, including the fragment's header, is specified in the header field total_length; this length is given in octets. The length of the header is specified in the field header_length; this length is given in words, that is, units of four octets.
In analyzing this subroutine, we must distinguish between the "tail" fragment and the "last" fragment. We define the last fragment as the one which is received last in time, that is, the fragment that permits reassembly to be completed. The tail fragment is the fragment that is spatially last, that is, the fragment that is spatially located after any other fragment. The length and offset of the tail fragment make it possible to compute the length of the entire datagram. This computation is actually done in the action procedure reassembly, and the result is saved in the state vector field total_data_length; if the tail fragment has not been received, this value is assumed to be zero.
It is the task of the reass_done function [MILS83a, sec 9.4.6.2.6] to determine whether the incoming fragment is the last fragment. This determination is made as follows:
-
If the tail fragment has not been received previously and the incoming fragment is not the tail fragment, then return NO.
-
Otherwise, if the tail fragment has not been received, but the incoming fragment is the tail fragment, determine whether all fragments spatially preceding the tail fragment have also been received.
-
Otherwise, if the tail fragment has been received earlier, determine whether the incoming fragment is the last one needed to complete reassembly.
The evaluation of case (2) is accomplished by the following statment:
if (state_vector.reassembly_map from 0 to
(((from_SNP.dtgm.total_length -
(from_SNP.dtgm.header_length * 4) + 7) / 8)
+ 7) / 8 is set)
then return YES;
The double occurrence of the subexpression " + 7 ) / 8" is apparently a misprint. The function f(x) = (x + 7) / 8 will convert x from octets to blocks, rounding any remainder upward. There is no need for this function to be performed twice. The second problem is that the fragment_offset field of the incoming packet is ignored. The tail fragment specifies only its own length, not the length of the entire datagram; to determine the latter, the tail fragment's offset must be added to the tail fragment's own length. The third problem hinges on the meaning of the English "... from ... to ..." phrase. If this phrase has the same meaning as the ".." range indication in Ada [ADA83, sec 3.6], that is, includes both the upper and lower bounds, then it is necessary to subtract 1 from the final expression.
The expression following the word to, above, should thus be changed to read
from_SNP.dtgm.fragment_offset +
((from_SNP.dtgm.total_length -
(from_SNP.dtgm.header_length * 4) + 7) / 8) - 1
Another serious problem with this routine occurs when evaluating case (3). In this case, the relevant statement is
if (all reassembly map from 0 to
(state_vector.total_data_length + 7)/8 is set
then return YES
If the tail fragment was received earlier, the code asks, in effect, whether all the bits in the reassembly map have been set. This, however, will not be the case even if the incoming fragment is the last fragment, since the routine reassembly, which actually sets these bits, has not yet been called for this fragment. This statement must therefore skip the bits corresponding to the incoming fragment. In specifying the range to be tested, allowance must be made for whether these bits fall at the beginning of the bit map or in the middle (the case where they fall at the end has already been tested). The statement must therefore be changed to read
if from_SNP.dtgm.fragment_offset = 0 then
if (all reassembly map from
from_SNP.dtgm.fragment_offset +
((from_SNP.dtgm.total_length -
from_SNP.dtgm.header_length * 4) + 7) / 8
to ((state_vector.total_data_length + 7) / 8 - 1) is set)
then return YES;
else return NO;
end if;
else
if (all reassembly map from 0 to
(from_SNP.dtgm.fragment_offset - 1) is set)
and (all reassembly map from
from_SNP.dtgm.fragment_offset +
((from_SNP.dtgm.total_length -
from_SNP.dtgm.header_length * 4) + 7) / 8
to ((state_vector.total_data_length + 7) / 8 - 1) is set)
then return YES;
else return NO;
end if;
end if;
Note that here again it is necessary to subtract 1 from the upper bound.