How to create an adhoc network between laptops in java?


How to create an adhoc network between laptops in java?



I want to create an adhoc between labtops were they will communicate using wireless communication. I will use java for this but still I do not know how to start..
I think I'll have to use sockets for the connections right? How will a laptop notice other laptops in its local network or the other way around? Do i need a server to handle the communication between laptops? Another thing, how to broadcast a message from one laptop to other laptops in the network? Please reply as soon as you can. Any help will be appreciated. Thanks in advance.





Do you explicitly want to create the adhoc network in java on your own? I mean, you can use the existing application/services to create the network. Once the network is on, you can communicate between them as you would do on a normal LAN.
– Vikram.exe
Dec 31 '10 at 7:35




4 Answers
4



Generally changing network settings is both a privileged and system-specific task, so it's not ordinarily something that java applications should or would be permitted to do.



That's not to say it's necessarily impossible. For example, if you can figure out how to create and/or join a network from the command line, you may be able to issue those commands if the JVM permits it and you can somehow secure the necessary permissions. On a linux machine, this would probably be some combination of iwconfig and/or ifconfig usage - but normally requires root.



One you have a network up then you can deal with socket type traffic over it - an area where java is far more at home, and one that is often possible without special privileges, at least as far as the operating system is concerned.



Can you restate the problem:



This is what the answers above try to handle...



In this case you have some other tools available. You start with advertising a service using somthing like Zeroconf (Bonjour, available as jmDNS in open source). The other party is able to look up the service using jmDNS again. This works using UDP.



Once found you can establish direct IP communication as usual.



To broadcast information you have to program sockets on UDP level. If you don't want to go to greatest detail, there are also frameworks around (Apache MINA).





But, how to go to the greatest details?
– mathmaniage
Mar 31 at 15:11



If u have to use java, I would advice u to have a look at the JANE, Java Ad Hoc Network Development Environment.



Good luck.



Is this academic? If so, try using simulators first. There are a lot of good simulators available for free (For eg. NS2, glomosim). It is a good place to start for proof of concept. These simulators have good mobile communication protocols (including mobile adhoc setup). You will not have to deal with nitty-gritty details and concentrate more on your application.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

List of Kim Possible characters

Audio Livestreaming with Python & Flask

NSwag: Generate C# Client from multiple Versions of an API