MCPcopy Index your code
hub / github.com/NetCrusherOrg/netcrusher-java

github.com/NetCrusherOrg/netcrusher-java @netcrusher-core-0.10

Chat with this repo
repository ↗ · DeepWiki ↗ · release netcrusher-core-0.10 ↗ · + Follow
919 symbols 3,196 edges 127 files 128 documented · 14% updated 9y ago★ 733 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

NetCrusher for Java

NetCrusher is TCP/UDP proxy for Java that is placed in the middle between client and server and allows to check both sides on failover.

  • emulates network failures
  • emulates frozen connection
  • supports both TCP and UDP
  • supports multiple dynamic connections through the same proxy tunnel
  • allows to check the state of connections
  • allows to filter/dump data
  • supports throttling (delay and/or throughput control)
  • garbage-less buffering
  • high performance (16.6 Gbits on loopback interface of my laptop)
  • supports IP4/IP6

NetCrusher is build on top of Java 8 NIO and has no external dependencies except SLF4J.

Documentation is available on wiki

TCP

NioReactor reactor = new NioReactor();

TcpCrusher crusher = TcpCrusherBuilder.builder()
    .withReactor(reactor)
    .withBindAddress("localhost", 10080)
    .withConnectAddress("google.com", 80)
    .buildAndOpen();

// ... some actions

// emulate reconnect
crusher.reopen();

// ... check the client connection is reestablished successfully

// closing
crusher.close();
reactor.close();

UDP

NioReactor reactor = new NioReactor();

DatagramCrusher crusher = DatagramCrusherBuilder.builder()
    .withReactor(reactor)
    .withBindAddress("localhost", 10188)
    .withConnectAddress("time-nw.nist.gov", 37)
    .buildAndOpen();

// ... some actions

// check data is sent
Assert.assertTrue(crusher.getInner().getReadDatagramMeter().getTotal() > 0);

// closing
crusher.close();
reactor.close();

Additional samples

Checks additional samples in the project root folder:

Command line

For manual QA the command-line wrapper is available both for TCP and Datagram mode

$ ./run-tcp-crusher.sh 127.0.0.1:12345 google.com:80
# Version: 0.8
# Print `HELP` for the list of the commands
# enter the command in the next line
CLOSE
[20:19:20.586] INFO  TcpCrusher </127.0.0.1:12345>-<google.com/64.233.161.101:80> is closed
[20:19:20.586] INFO  Crusher is closed
# enter the command in the next line
OPEN
[20:19:21.655] INFO  TcpCrusher </127.0.0.1:12345>-<google.com/64.233.161.101:80> is open
[20:19:21.655] INFO  Crusher is open

More about the command line mode in wiki.

Maven

<dependency>
    <groupId>com.github.netcrusherorg</groupId>
    <artifactId>netcrusher-core</artifactId>
    <version>0.9</version>
</dependency>

Performance

See wiki page

License

Apache License Version 2.0, http://www.apache.org/licenses/LICENSE-2.0.html

Links to the similar projects

  • Jepsen - Distributed Systems Safety Analysis
  • Java-NIO-TCP-Proxy - Simple TCP proxy
  • netem - Linux kernel module allows to distort network facilities
  • socat - bridges everything with everything

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Method 770
Class 134
Interface 14
Enum 1

Languages

Java100%

Modules by API surface

core/src/main/java/org/netcrusher/tcp/TcpChannel.java33 symbols
core/src/main/java/org/netcrusher/datagram/DatagramCrusherOptions.java33 symbols
core/src/main/java/org/netcrusher/datagram/DatagramInner.java31 symbols
core/src/main/java/org/netcrusher/tcp/TcpCrusherOptions.java29 symbols
core/src/main/java/org/netcrusher/datagram/DatagramOuter.java29 symbols
core/src/main/java/org/netcrusher/tcp/TcpCrusherBuilder.java26 symbols
core/src/main/java/org/netcrusher/datagram/DatagramCrusherBuilder.java25 symbols
core/src/main/java/org/netcrusher/tcp/TcpCrusher.java24 symbols
core/src/main/java/org/netcrusher/datagram/DatagramCrusher.java23 symbols
core/src/main/java/org/netcrusher/tcp/TcpQueue.java18 symbols
core/src/main/java/org/netcrusher/tcp/TcpCrusherSocketOptions.java18 symbols
core/src/test/java/org/netcrusher/tcp/bulk/TcpBulkClient.java16 symbols

For agents

$ claude mcp add netcrusher-java \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page