[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2021-02-26T00:44:22-05:00 http://petesqbsite.com/phpBB3/app.php/feed/topic/14865 2021-02-26T00:44:22-05:00 2021-02-26T00:44:22-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=39072#p39072 <![CDATA[IPV4 reassembly algorithm QB style]]>
Various websites including this one: https://www.heise.de/netze/rfc/rfcs/rfc815.shtml have an RFC815 that state that making large "holes" and filling them in is the way to go and if they were all filled in then a packet is said to be received.

This is my Qbasic code but it isn't quite finished because I don't understand the algorithm perfectly the way its written in the RFC. Maybe someone with Qbasic and networking experience can shed some light.

Here's my code:

Code:

DECLARE FUNCTION getfrag$ ()DECLARE SUB setfrag (d$, ofs%, mf%)DECLARE SUB firsthole ()DECLARE SUB addhole (first%, last%)'Hole descriptorsTYPE hd    first AS INTEGER    last AS INTEGER    set AS INTEGER 'If non-zero, it means this index has an entryEND TYPETYPE d    first AS INTEGER    last AS INTEGER    more AS INTEGER    dat AS STRING * 4000 'data in our fragmentEND TYPECONST maxhole = 1000  'Assume we deal with 1000 holes?DIM SHARED bigbuf AS STRING * 4000 'Our space of data after defragmentation is completeDIM SHARED hole(maxhole) AS hd, frag AS d'highest index in hole descriptor'increments when new entries are addedDIM SHARED nhs% nhs% = 0CALL firsthole'our fragment (will need more of these eventually)CALL setfrag("TEST", 0, 1)'run through each hole (this kills efficiency I think...)FOR hs% = 0 TO maxhole - 1    IF hole(hs%).set <> 0 THEN 'dont go through a hole if its not setup as a hole        hf% = hole(hs%).first        hl% = hole(hs%).last        IF frag.first <= hl% AND frag.last >= hf% THEN 'This satisfies steps 2 and 3 of the algorithm            hole(hs%).set = 0 'This satisfies step 4            mf = frag.more            IF frag.first > hf% THEN CALL addhole(hf%, frag.first - 1) 'This satisfies step 5            IF frag.last < hl% AND mf% = 1 THEN CALL addhole(frag.last + 1, hl%) 'This satisfies step 6            hs% = -1 'redo count        END IF    END IFNEXT'All hole descriptors are processed so we jam in the data I guess??MID$(bigbuf, frag.first + 1, frag.last - frag.first) = getfrag$'then what???END'Here we add a hole to the new index and set it as a holeSUB addhole (first%, last%)nhs% = nhs% + 1hole(nhs%).set = 1hole(nhs%).first = first%hole(nhs%).last = last%END SUB'We setup the first hole per algorithm as 0 to length of output data spaceSUB firsthole'first hole = all spacehole(0).first = 0hole(0).last = LEN(bigbuf)hole(0).set = 1END SUB'We load our fragmentFUNCTION getfrag$getfrag$ = LEFT$(frag.dat, frag.last - frag.first)END FUNCTION'We setup our fragment. 2nd parameter is offset of fragment the "remote" host reports it to be.'3rd parameter if non-zero means remote host has set the MF (more fragments) flag.SUB setfrag (d$, ofs%, mf%)frag.dat = d$frag.first = ofs%frag.last = ofs% + LEN(d$)frag.more = 0IF mf% <> 0 THEN frag.more = 1END SUB
Am I beating around the bush with the way I written my code?

I want to receive the remote fragments but I don't want huge spaces in my output data if all the fragments come in an awkward order. (like say first fragment is offset 100, and second at offset 10 and third at offset 200 etc).

Statistics: Posted by mikefromca — Fri Feb 26, 2021 12:44 am


]]>