[asterisk-dev] [Code Review] Add the ability to capture and analyze packets

Matt Jordan reviewboard at asterisk.org
Thu Dec 15 10:28:26 CST 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1623/#review5013
-----------------------------------------------------------



/asterisk/trunk/lib/python/asterisk/TestCase.py
<https://reviewboard.asterisk.org/r/1623/#comment9270>

    This probably should be a .debug, so as not to spam the messages.txt file (which generally is set to INFO and higher)
    
    Also: can packet have its __str__ method implemented?  That way you could send out to debug a brief textual representation of the packet, which I imagine would be pretty useful in a debug log



/asterisk/trunk/lib/python/pcap_listener.py
<https://reviewboard.asterisk.org/r/1623/#comment9267>

    Since these classes are in the /lib/ directory (and are going to be used by multiple people), commenting them would be nice



/asterisk/trunk/lib/python/sip_message.py
<https://reviewboard.asterisk.org/r/1623/#comment9269>

    Would it make sense having this inherit from unittest.TestCase?



/asterisk/trunk/lib/python/sip_message.py
<https://reviewboard.asterisk.org/r/1623/#comment9268>

    Red blobs and such



/asterisk/trunk/tests/channels/SIP/pcap_demo/test-config.yaml
<https://reviewboard.asterisk.org/r/1623/#comment9273>

    The problem with having yappcap be a dependency here is that if a build agent doesn't have it, the test flat out won't run - which in reality, we really want it as a feature that only enables if the library is present.
    
    What do you think about putting a detection for the library into PcapListener?  If the library isn't available, it can either throw an exception (handled by TestCase) or just log the fact that the library isn't installed and not attempt to listen for packets.  That way we won't disable any tests by default, and we can have the pcap capture capability put in automatically across a large number of tests.


- Matt


On Dec. 14, 2011, 10:30 p.m., Terry Wilson wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1623/
> -----------------------------------------------------------
> 
> (Updated Dec. 14, 2011, 10:30 p.m.)
> 
> 
> Review request for Asterisk Developers and Paul Belanger.
> 
> 
> Summary
> -------
> 
> This patch allows one to capture live network traffic, write tests based on that traffic, and to save capture files for later use. Currently the savefile directory must be specified by the test, so it might be nice to add the ability to easily record he pcap file somewhere where runtests.py will archive it.
> 
> There is also a pseudo SIP message parser for breaking generally well-formed SIP messages into the request/response line, headers, and body to facilitate writing SIP-based pcap tests. A cheesy demo test is included as a proof of concept.
> 
> The pcap functionality relies on the yappcap library (which I also wrote) which is available at https://github.com/otherwiseguy/yappcap . The library is still under active development and I desperately need to document it, but the API in use by the tests should not change. Other python pcap libraries were missing one or more features I needed/wanted.
> 
> The pcap demo test uses the Construct python library to navigate to the application-layer data in the raw packet because I didn't want to bother writing code to do that myself.
> 
> I've been staring at and obsessing over this code (and yappcap) too long. It is time for some other eyes.
> 
> 
> Diffs
> -----
> 
>   /asterisk/trunk/lib/python/asterisk/TestCase.py 2892 
>   /asterisk/trunk/lib/python/pcap_listener.py PRE-CREATION 
>   /asterisk/trunk/lib/python/sip_message.py PRE-CREATION 
>   /asterisk/trunk/tests/channels/SIP/pcap_demo/configs/ast1/extensions.conf PRE-CREATION 
>   /asterisk/trunk/tests/channels/SIP/pcap_demo/configs/ast1/sip.conf PRE-CREATION 
>   /asterisk/trunk/tests/channels/SIP/pcap_demo/run-test PRE-CREATION 
>   /asterisk/trunk/tests/channels/SIP/pcap_demo/test-config.yaml PRE-CREATION 
>   /asterisk/trunk/tests/channels/SIP/tests.yaml 2892 
> 
> Diff: https://reviewboard.asterisk.org/r/1623/diff
> 
> 
> Testing
> -------
> 
> I ran the included test and opened the saved capture file to make sure it looked right.
> 
> 
> Thanks,
> 
> Terry
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20111215/50b310dd/attachment-0001.htm>


More information about the asterisk-dev mailing list