Algorithm¶
See also
This algorithm is an adaptation of the algorithm described in RFC 815.
|
Data Sequence Number |
|
TCP Acknowledgement |
|
TCP Synchronisation Flag |
|
TCP Finish Flag |
|
TCP Reset Connection Flag |
|
Buffer Identifier |
|
Hole Discriptor List |
|
Initial Sequence Number |
|
source IP |
|
destination IP |
|
source TCP port |
|
destination TCP port |
DO {
BUFID <- src|dst|srcport|dstport|ACK;
IF (SYN is true) {
IF (buffer with BUFID is allocated) {
flush all reassembly for this BUFID;
submit datagram to next step;
}
}
IF (no buffer with BUFID is allocated) {
allocate reassembly resources with BUFID;
ISN <- DSN;
put data from fragment into data buffer with BUFID
[from octet fragment.first to octet fragment.last];
update HDL;
}
IF (FIN is true or RST is true) {
submit datagram to next step;
free all reassembly resources for this BUFID;
BREAK.
}
} give up until (next fragment);
update HDL: {
DO {
select the next hole descriptor from HDL;
IF (fragment.first >= hole.first) CONTINUE.
IF (fragment.last <= hole.first) CONTINUE.
delete the current entry from HDL;
IF (fragment.first >= hole.first) {
create new entry "new_hole" in HDL;
new_hole.first <- hole.first;
new_hole.last <- fragment.first - 1;
BREAK.
}
IF (fragment.last <= hole.last) {
create new entry "new_hole" in HDL;
new_hole.first <- fragment.last + 1;
new_hole.last <- hole.last;
BREAK.
}
} give up until (no entry from HDL)
}
The following algorithm implement is based on IP Datagram
Reassembly Algorithm introduced in RFC 815. It described an
algorithm dealing with RCVBT
(fragment received bit table)
appeared in RFC 791. And here is the process:
Select the next hole descriptor from the hole descriptor list. If there are no more entries, go to step eight.
If
fragment.first
is greater thanhole.last
, go to step one.If
fragment.last
is less thanhole.first
, go to step one.Delete the current entry from the hole descriptor list.
If
fragment.first
is greater thanhole.first
, then create a new hole descriptornew_hole
withnew_hole.first
equal tohole.first
, andnew_hole.last
equal tofragment.first
minus one (-1
).If
fragment.last
is less thanhole.last
andfragment.more_fragments
istrue
, then create a new hole descriptornew_hole
, withnew_hole.first
equal tofragment.last
plus one (+1
) andnew_hole.last
equal tohole.last
.Go to step one.
If the hole descriptor list is now empty, the datagram is now complete. Pass it on to the higher level protocol processor for further handling. Otherwise, return.