Java Network Traffic Generator: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(14 intermediate revisions by the same user not shown)
Line 2: Line 2:


* https://docs.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html
* https://docs.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html
* https://docs.oracle.com/javase/8/docs/api/java/net/MulticastSocket.html


=Internal=
=Internal=


* [[Linux_7_Multicast_Configuration#Testing|Linux Multicast Configuration]]
* [[Linux_7_Multicast_Configuration#Testing|Linux Multicast Configuration]]
* [[java Networking]]


=Overview=
=Overview=
Line 13: Line 15:
=GitHub=
=GitHub=


{{External|https://github.com/NovaOrdis/playground/tree/master/java/multicast}}
{{External|https://github.com/NovaOrdis/playground/tree/master/java/network/network-traffic}}


=User Manual=
=User Manual=


Listen for multicast:
==Global Arguments==


<pre>
<pre>
java -jar multicast.jar listen  <network-interface> <multicast-address>:<port>
-d
</pre>
</pre>


Send multicast:
Start in debug mode.


<pre>
<pre>
java -jar multicast.jar send <network-interface> <multicast-address>:<port>
-v
</pre>
 
Display verbose information about the network operation in process.
 
Any -D system properties are propagated verbatim to the JVM:
 
<pre>
./bin/send -Djava.net.preferIPv4Stack=true ...
</pre>
 
==Common Arguments==
 
====--interface====
 
<pre>
--interface=<interface-name>|<address>
</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:
 
<pre>
--interface=eth0
</pre>
 
<pre>
--interface=172.20.1.11
</pre>
 
====--address====
 
====--port====
 
====--local-address====
 
====--local-port====
 
Forces the local port.
 
The network interface name is one of those returned by <tt>ip addr</tt>.
 
==Payload==
 
<tt>send</tt> accepts a payload argument.
 
==Usage Examples==
 
===Sending/Receiving Multicast on Mac===
 
Listening:
 
<pre>
./bin/ntg receive -v -Djava.net.preferIPv4Stack=true --protocol=multicast --address=225.5.5.5:5555
</pre>
 
Sending:
 
<pre>
./bin/ntg send -v -Djava.net.preferIPv4Stack=true --protocol=multicast --address=225.5.5.5:5555 sometext
</pre>
</pre>

Latest revision as of 22:10, 13 July 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/ntg receive -v -Djava.net.preferIPv4Stack=true --protocol=multicast --address=225.5.5.5:5555

Sending:

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