What is the best way to simulate a network in Java?
I'm in the early stages of a networked peer to peer project, and to determine some of the required characteristics of the clients I'd like to be able to simulate 100+ instances concurrently on my PC.
Ideally I'd like to create a "simulation" version of the sockets, with their own inputs and output streams. Eventually, I'm going to use these streams for data transfer instead of just moving data around between java objects, so what I'm wanting to simulate is the kind of latency, data loss and other errors you might get in an actual network.
Ideally these simulation methods would be very close to the actual stream standards of java.net.*
, so I wouldn't need to do much of a rewrite in order to move from simulation to the actual client.
Can anyone point me in the right direction?
You can use Akka to create millions of Actors on a single machine, then organize communication between them similar to 'real' network.
Here's an example project: https://github.com/adelbertc/scalanet
Well you don't really need to use any tools but put your brains to design it better.
You need interfaces for the under lying communication framework.
All you need is to mock/substitute the real implementation with a dummy one once you have coded against the interfaces.This dummy implementation can introduce features like latency,dummy data etc.
You can go with spring container.You can write some dummy server sockets in the container to simulate conversations between multiple instances or better use a web container to take that headache away from you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With