UDP Recorder and UDP Replay

Alex Tweedly alex at tweedly.net
Sat May 27 13:18:31 EDT 2006


I've added a new stack to revonline - UDP Repay (under alextweedly, 
category programming)

It can be used to replay a stored log of UDP packets, such as you would 
want to do for application testing and stress testing. It simply replays 
a series of packets, keeping the original timing characteristics. 
Although it can handle multiple interleaved streams of packets to 
different ports, and can map them to new destination addresses and 
ports, it can't do anything intelligent (or indeed anything at all) to 
the streams themselves.

I will some day finish and upload the corresponding "UDP Recorder" stack 
- but the limitations on how you can insert a UDP recorder stack into a 
network context make it be of rather limited value. It's (generally) 
much easier to add recording functions to your own app, and then have it 
record a series of packets while in use.  Then you can take the 
resulting file of packets, and recreate it as a UDP stream, for testing 
while the real data source is unavailable (or simply because you want a 
repeatable set of test data).

Some sample functions that you could add to your stack are enclosed 
below; usage should be fairly obvious
 call "recorderStart pFilename"  to start recording
 call "recorderRecord pSock, pData" for every packet received (as near 
to the original receipt of the packet as possible)
 call "recorderFinish" when you're done

You can then use the UDP Replay stack to replay this file - with 
controls for
 - speed (%age of original)
 - jitter (random variation of +- 20% of inter-packet delay)
 - immediate start (often you'll set up the recorder, then have to go 
off and get everything else started, so there will be a long delay 
before the initial packet captured; this check box allows you to skip 
this initial delay on replay.


Note - it doesn't yet allow you to induce mis-ordered packets .... 
that's coming later, once I have researched current thinking about what 
kind of misordering is likely.


-- ------ functions to include in your app ------------

-- initial recode in the file
-- 1-4 length of first record *including* the length and the separating 
CR which is not part of the data recorder
-- 6-17 timestamp
-- <cr>
-- format of each record is
--   1-4 length *including* the length and the separating CR which is 
not part of the data recorder
--   6-9 socket number
--  11-22 timestamp
--   24 - (length-1)   actual data received / to be sent
--            <cr>


local lPorts, lStartTime, lPackets, lBytes, lFileName

on recorderStart pFileName
    put pFileName into lFileName
    put the milliseconds into lStartTime
    open file lFileName for binary write
    write format("%4d %12d", 18, lStartTime) & cr to file lFileName
    put 0 into lPackets
    put 0 into lBytes
end recorderStart

on recorderRecord pSock, pData
    put format("%12d", milliseconds() - lStartTime) into tMsec
    put 4 + 1 + 4 + 1 + 12 + 1 + len(pData)+1 into tLen
    write  format("%4d %4d %12d", tLen, pSock, tMsec) && pData &CR to 
file lFileName
    add 1 to lPackets
    add len(pData) to lBytes
end recorderRecord


function recorderStatus
    return the milliseconds - lStartTime, lPackets, lBytes
end recorderStatus

function recorderFinish
    close file lFileName
    return the milliseconds - lStartTime, lPackets, lBytes
end recorderFinish



-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.7.2/349 - Release Date: 26/05/2006




More information about the use-livecode mailing list