-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample code for WartsWriter class
- Loading branch information
rbeverly
committed
Aug 30, 2018
1 parent
4e88dad
commit 0b946e4
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |