Implementation Difficulties of MIL Standard IP
5. Implementation Difficulties of MIL Standard IP
In addition to the problems discussed above, there are several features of the MIL standard IP specification [MILS83a] which lead to difficulties for the implementor. These difficulties, while not actually errors in the specification, take the form of assumptions which are not explicitly stated, but of which implementors must be aware.
5.1 Header Padding
In several places, the specification makes a computation of the length of a packet header without explicitly allowing for padding. The padding is needed because the specification requires [MILS83a, sec 9.3.14] that each header end on a 32-bit boundary.
One place this problem arises is in the need_to_frag decision function [MILS83a, sec 9.4.6.2.5]. This function is used to determine whether fragmentation is required for an outgoing datagram. It consists of the single statement
if ((from_ULP.length + (number of bytes of option data)
+ 20) > maximum transmission unit of the local subnetwork
then return YES
else return NO;
end if;
(A minor syntax error results from not terminating the first return statement with a semicolon [ADA83, sec 5.1, sec 5.3, sec 5.9].) In order to allow for padding, the expression for the length of the outgoing datagram should be
(((from_ULP.length + (number of bytes of option data) + 20)
+ 3)/4 * 4)
Another place that this problem arises is in the action procedure build_and_send [MILS83a, sec 9.4.6.3.2], which prepares unfragmented datagrams for transmission. To compute the header field header_length, which is expressed in words, i.e., units of four octets [MILS83a, sec 9.3.2], this procedure contains the statement
to_SNP.dtgm.header_length := 5 +
(number of bytes of option data)/4;
In order to allow for padding, this statement should read
to_SNP.dtgm.header_length :=
5 + ((number of bytes of option data)+3)/4;
The identical statement appears in the action procedure fragment_and_send [MILS83a, sec 9.4.6.3.7], which prepares datagram fragments for transmission, and requires the same correction.
The procedure fragment_and_send also has this problem in two other places. In the first, the number of octets in each fragment is computed by
data_per_fragment := maximum subnet transmission unit
- (20 + number of bytes of option data);
In order to allow for padding, this statement should read
data_per_fragment := maximum subnet transmission unit
- (((20 + number of bytes of option data)+3)/4*4);
(Actually, this statement must be changed to
data_per_fragment := (maximum subnet transmission unit
- (((20 + number of bytes of option data)+3)/4*4)/8*8;
in order to accomplish its intended purpose, for reasons which have been discussed above.)
A similar problem occurs in the statement which computes the header length for individual fragments:
to_SNP.dtgm.header_length := 5 +
(number of copy options octets/4);
To allow for padding, this should be changed to
to_SNP.dtgm.header_length := 5 +
(number of copy options octets+3/4);
Notice that all of these errors can also be corrected if the English phrase "number of bytes of option data", and similar phrases, are always understood to include any necessary padding.
5.2 Subnetworks with Small Transmission Sizes
When an outgoing datagram is too large to be transmitted as a single packet, it must be fragmented. On certain subnetworks, the possibility exists that the maximum number of bytes that may be transmitted at a time is less than the size of an IP packet header for a given datagram. In this case, the datagram cannot be sent, even in fragmented form. Note that this does not necessarily mean that the subnetwork cannot send any datagrams at all, since the size of the header may be highly variable. When this problem arises, it should be detected by IP. The proper place to detect this situation is in the function can_frag.
The can_frag decision function [MILS83a, sec 9.4.6.2.2] is used to determine whether a particular outgoing datagram, which is too long to be transmitted as a single fragment, is allowed to be fragmented. In the current specification, this function consists of the single statement
if (from_ULP.dont_fragment = TRUE)
then return NO
else return YES
end if;
(A minor syntax error is that the return statements should be terminated by semicolons; see [ADA83, sec 5.1, sec 5.3, sec 5.9].)
If the above problem occurs, the procedure fragment_and_send will obtain negative numbers for fragment sizes, with unpredictable results. This should be prevented by assuring that the subnetwork can send the datagram header and at least one block (eight octets) of data. The can_frag function should be recoded as
if ((8 + ((number of bytes of option data)+3)/4*4 + 20)
> maximum transmission unit of the local subnetwork)
then return NO;
elsif (from_ULP.dont_fragment = TRUE)
then return NO
else return YES
end if;
This is similar to the logic of the function need_to_frag, discussed above.
5.3 Subnetwork Interface
Provision is made for the subnetwork to report errors to IP [MILS83a, sec 6.3.6.2], but no provision is made for the IP entity to take any action when such errors occur.
In addition, the specification [MILS83a, sec 8.2.1.1] calls for the subnetwork to accept type-of-service indicators (precedence, reliability, delay, and throughput), which may be difficult to implement on many local networks.
5.4 ULP Errors
The IP specification [MILS83a, sec 9.4.6.3.6] states
The format of error reports to a ULP is implementation dependent. However, included in the report should be a value indicating the type of error, and some information to identify the associated data or datagram.
The most natural way to provide the latter information would be to return the datagram identifier to the upper-level protocol, since this identifier is normally supplied by the sending ULP [MILS83a, sec 9.3.5]. However, the to_ULP data structure makes no provision for this information [MILS83a, sec 9.4.4.3], probably because this information is irrelevant for datagrams received from the subnetwork. Implementors may feel a need to add this field to the to_ULP data structure.
5.5 Initialization of Data Structures
The decision function reass_done [MILS83a, sec 9.4.6.2.6] makes the implicit assumption that data structures within each finite state machine are initialized to zero when the machine is created. In particular, this routine will not function properly unless state_vector.reassembly_map and state_vector.total_data_length are so initialized. Since this assumption is not stated explicitly, implementors should be aware of it. There may be other initialization assumptions that we have not discovered.
5.6 Locally Defined Types
The procedures error_to_source [MILS83a, sec 9.4.6.3.5] and error_to_ULP [MILS83a, sec 9.4.6.3.6] define enumeration types in comments. The former contains the comment
error_param : (PARAM_PROBLEM, EXPIRED_TTL, PROTOCOL_UNREACH);
and the latter
error_param : (PARAM_PROBLEM, CAN'T_FRAGMENT, NET_UNREACH,
PROTOCOL_UNREACH, PORT_UNREACH);
These enumerated values are used before they are encountered [MILS83a, sec 9.4.6.1.1, sec 9.4.6.1.2, sec 9.4.6.1.3, et al.]; implementors will probably wish to define some error type globally.
5.7 Miscellaneous Difficulties
The specification contains many Ada syntax errors, some of which have been shown above. We have only mentioned syntax errors above, however, when they occurred in conjunction with other problems. One of the main syntactic difficulties that we have not mentioned is that the specification frequently creates unnamed types, by declaring records within records; such declarations are legal in Pascal, but not in Ada [ADA83, sec 3.7].
Another problem is that slice assignments frequently do not contain the same number of elements on the left and right sides, which will raise a run-time exception [ADA83, sec 5.2.1]. While we have mentioned some of these, there are others which are not enumerated above.
In particular, the procedure error_to_source [MILS83a, sec 9.4.6.3.5] contains the statement
to_SNP.dtgm.data [8..N+3] := from_SNP.dtgm.data [0..N-1];
We believe that N+3 is a misprint for N+8, but even so the left side contains one more byte than the right. Implementors should carefully check every slice assignment.