<s> from twisted . python import usage <EOL> from scapy . all import IP , ICMP <EOL> from ooni . templates import scapyt <EOL> class UsageOptions ( usage . Options ) : <EOL> optParameters = [ [ '<STR_LIT:target>' , '<STR_LIT:t>' , '<STR_LIT>' , "<STR_LIT>" ] ] <EOL> class ExampleICMPPingScapy ( scapyt . BaseScapyTest ) : <EOL> name = "<STR_LIT>" <EOL> usageOptions = UsageOptions <EOL> def test_icmp_ping ( self ) : <EOL> def finished ( packets ) : <EOL> print packets <EOL> answered , unanswered = packets <EOL> for snd , rcv in answered : <EOL> rcv . show ( ) <EOL> packets = IP ( dst = self . localOptions [ '<STR_LIT:target>' ] ) / ICMP ( ) <EOL> d = self . sr ( packets ) <EOL> d . addCallback ( finished ) <EOL> return d </s>
