GithubHelp home page GithubHelp logo

exception168 / wiresham Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abstracta/wiresham

0.0 0.0 0.0 53 KB

Simple TCP service mocking tool for replaying https://www.wireshark.org and http://www.tcpdump.org captured service traffic

License: Apache License 2.0

Java 98.50% Shell 1.50%

wiresham's Introduction


Simple TCP service mocking tool for replaying tcpdump or Wireshark captured service traffic.

This project is inspired in other tools like WireMock, mountebank and MockTCPServer, but provides following features that are partially supported by listed tools:

  • TCP mocking support, with async messages sent (i.e: allows sending welcome messages which are not supported by mountebank).
  • Load mocking specification from tcpdump .pcap or Wireshark .json dump files and provides a reduced .yaml format for easy versioning.
  • Allows to easily run the mock embedded in Java projects for easy testing

Take into consideration that this tool is very simple, and only replays TCP traffic that has previously been recorded, so if user interacts with the tool in unexpected ways, then the service will not answer until next expected packet is received. For more complex scenarios consider using one of previously mentioned tools.

Usage

This tool (as previously listed ones) is particularly useful to implement integration tests without the hassle of flaky connections, or complex environment setup or restrictions (VPN, quotas, etc).

Note: If you use .pcap, since Wiresham uses pcap4j for .pcap files support, you need to install libpcap or winpcap as detailed in pcap4j website.

The general use case for the tool takes following steps:

  1. User captures traffic with tcpdump (with something like tcpdump port 23 -w ~/traffic.pcap) or Wireshark between a client application and a service.
  2. If traffic has been captured with Wireshark then store the captured traffic, filtering with proper condition for service port, in a .json file (File -> Export Packet Dissections -> As JSON...)
  3. At this point user might follow two potential courses:
    1. Start Wiresham in standalone mode with stored .pcap or .json and connect to it with the client application to reproduce previously stored traffic.

      E.g.: java -jar wiresham-standalone.jar -p 2324 -a 0.0.0.0 wireshark-dump.json

      Latest version of wiresham-standalone.jar can be downloaded from maven central.

      A similar example for a tcpdump traffic:

      E.g.: java -jar wiresham-standalone.jar -p 2324 -a 0.0.0.0 traffic.pcap

      Run java -jar wiresham-standalone.jar -h to get usage instructions and help.

    2. Convert the tcpdump or Wireshark dump to a reduced .yaml file (an example file can be found in simple.yaml), optionally manually tune it (response times or binary packets), add it to the project repository and implement tests using VirtualTcpService class.

      To convert a script run something like java -jar wiresham-standalone.jar -d reduced-dump.yml -a 0.0.0.0 wireshark-dump.json.

      To add Wiresham as dependency in maven project include in pom.xml the dependency:

      <dependency>
       <groupId>us.abstracta</groupId>
       <artifactId>wiresham</artifactId>
       <version>0.1</version>
      </dependency>

      Check what is the latest version in releases

      Check VirtualTcpServiceTest for simple and raw examples on how to use VirtualTcpService class.

Build

In case you want to build this project from scratch, it is required JDK8+ and maven 3.3+.

Then just run mvn clean install and the library (and standalone version) will be built and installed in the local maven repository.

Release

To release the project, define the version to be released by checking included changes since last release and following semantic versioning. Then, create a release (including v as prefix of the version, e.g. v0.1), this will trigger a Travis build which will publish the jars to maven central repository (and make it general available to be used as maven dependency projects) in around 10 mins and can be found in maven central search after up to 2 hours.

wiresham's People

Contributors

rabelenda-abstracta avatar rabelenda avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.