Java Network Traffic Generator: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 37: Line 37:
./bin/send -Djava.net.preferIPv4Stack=true ...
./bin/send -Djava.net.preferIPv4Stack=true ...
</pre>
</pre>


==Common Arguments==
==Common Arguments==
Line 46: Line 45:
--interface=<interface-name>|<address>
--interface=<interface-name>|<address>
</pre>
</pre>
The network interface name is one of those returned by <tt>ip addr</tt>, or by <tt>./info</tt>. An IP address can also be used.


Example:
Example:
Line 57: Line 58:
</pre>
</pre>


====--local-port====
====--address====


Forces the local port.
====--port====


Listen for multicast:
====--local-address====


<pre>
====--local-port====
java -jar multicast.jar listen <network-interface-name> <multicast-address>:<port>
</pre>


The network interface name is one of those returned by <tt>ip addr</tt>.
Forces the local port.
 
Send multicast:
 
<pre>
java -jar multicast.jar send <network-interface-name> <multicast-address>:<port>
</pre>


The network interface name is one of those returned by <tt>ip addr</tt>.
The network interface name is one of those returned by <tt>ip addr</tt>.
Line 83: Line 76:
==Usage Examples==
==Usage Examples==


===Sending Multicast on Mac===
===Sending/Receiving Multicast on Mac===
 
Listening:
 
<pre>
./bin/receive -v -Djava.net.preferIPv4Stack=true --protocol=multicast --address=225.5.5.5:5555
</pre>
 
Sending:
 
<pre>
./bin/send -v -Djava.net.preferIPv4Stack=true --protocol=multicast --address=225.5.5.5:5555 sometext
</pre>

Revision as of 18:11, 20 March 2017

External

Internal

Overview

A Java program sends multicast socket using DatagramSocket and listens for multicast traffic with MulticastSocket.

GitHub

https://github.com/NovaOrdis/playground/tree/master/java/network/network-traffic

User Manual

Global Arguments

-d

Start in debug mode.

-v

Display verbose information about the network operation in process.

Any -D system properties are propagated verbatim to the JVM:

./bin/send -Djava.net.preferIPv4Stack=true ...

Common Arguments

--interface

--interface=<interface-name>|<address>

The network interface name is one of those returned by ip addr, or by ./info. An IP address can also be used.

Example:

--interface=eth0
--interface=172.20.1.11

--address

--port

--local-address

--local-port

Forces the local port.

The network interface name is one of those returned by ip addr.

Payload

send accepts a payload argument.

Usage Examples

Sending/Receiving Multicast on Mac

Listening:

./bin/receive -v -Djava.net.preferIPv4Stack=true --protocol=multicast --address=225.5.5.5:5555

Sending:

./bin/send -v -Djava.net.preferIPv4Stack=true --protocol=multicast --address=225.5.5.5:5555 sometext