mirror of
https://github.com/cmand/scamper.git
synced 2024-05-19 06:50:05 +00:00
Add sample code for WartsWriter class
This commit is contained in:
@ -1,9 +1,9 @@
|
|||||||
# Scamper Tools
|
# Scamper Python Tools
|
||||||
|
|
||||||
Scamper is a scalable, efficient, and feature-rich Internet packet
|
Scamper is a scalable, efficient, and feature-rich Internet packet
|
||||||
prober from CAIDA (http://www.caida.org/tools/measurement/scamper/).
|
prober from CAIDA (http://www.caida.org/tools/measurement/scamper/).
|
||||||
|
|
||||||
Scamper is written in C and stores data in a binary "warts" format.
|
Scamper stores data in a binary "warts" format.
|
||||||
|
|
||||||
These tools replicate the functionality of scamper's utilities by
|
These tools replicate the functionality of scamper's utilities by
|
||||||
providing native python implementations. The following files
|
providing native python implementations. The following files
|
||||||
@ -17,4 +17,5 @@ are included:
|
|||||||
* sc_analysis_dump.py: covert scamper traces to easily parsed text
|
* sc_analysis_dump.py: covert scamper traces to easily parsed text
|
||||||
* sc_wartsgrep.py: create warts file containing only records of specified target
|
* sc_wartsgrep.py: create warts file containing only records of specified target
|
||||||
* sc_sample.py: sample python using warts class (for developers)
|
* sc_sample.py: sample python using warts class (for developers)
|
||||||
|
* sc_sample_writer.py: sample python using warts_writer class (for developers)
|
||||||
* sc_attach.py: interact with scamper over control socket
|
* sc_attach.py: interact with scamper over control socket
|
||||||
|
39
sc_sample_writer.py
Executable file
39
sc_sample_writer.py
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Program: $Id: $
|
||||||
|
# Author: Robert Beverly <rbeverly@nps.edu>
|
||||||
|
# Description: Example use of sc_warts_writer library.
|
||||||
|
#
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from sc_warts_writer import WartsWriter, WartsTrace
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
assert len(sys.argv) == 2
|
||||||
|
|
||||||
|
now = time.time()
|
||||||
|
w = WartsWriter(sys.argv[1])
|
||||||
|
w.write_list(1, 1, 'sc_sample_writer demo')
|
||||||
|
w.write_cycle(1, 1, 1, now)
|
||||||
|
tr = WartsTrace()
|
||||||
|
tr.add({'listid' : 1, 'srcport' : 1234, 'dstport' : 80,
|
||||||
|
'srcaddr' : '1.2.3.4', 'dstaddr' : '5.6.7.8',
|
||||||
|
'attempts' : 2, 'tracetyp' : 2, 'probehop' : 7,
|
||||||
|
'probesent' : 5, 'firsttl' : 4, 'timeval' : now + 1})
|
||||||
|
|
||||||
|
# hopflags (SCAMPER_TRACE_HOP_FLAG_REPLY_TTL)
|
||||||
|
reply = {'addr' : '4.4.4.4', 'rtt' : 23456,
|
||||||
|
'ipid' : 1234, 'probesize' : 60,
|
||||||
|
'replysize' : 54, 'probettl' : 4,
|
||||||
|
'replyttl' : 60, 'tos' : 0,
|
||||||
|
'icmp' : 4, 'hopflags' : 0x10}
|
||||||
|
tr.add_reply(reply)
|
||||||
|
reply = {'addr' : '6.6.6.6', 'rtt' : 834567,
|
||||||
|
'ipid' : 1234, 'probesize' : 60,
|
||||||
|
'replysize' : 54, 'probettl' : 6,
|
||||||
|
'replyttl' : 58, 'tos' : 0,
|
||||||
|
'icmp' : 4, 'hopflags' : 0x10}
|
||||||
|
tr.add_reply(reply)
|
||||||
|
w.write_object(tr)
|
||||||
|
|
||||||
|
# finish
|
||||||
|
w.write_cycle_stop(1, now+10)
|
Reference in New Issue
Block a user