I have to design an app in android for voice over WiFi communication for my university. Our university's infrastructure consists of interconnected LAN's(interconnection between multiple routers at different hostels and classrooms) and also a few wireless access point(all having wired interconnection). The speed of the university LAN is around 100Mbps. What I need my app to do is discover via broadcasting other instances of the app running in various devices within the campus(same android app will be installed on all devices),both within the same subnet(router) and also devices connected to other routers within the campus. The ultimate goal is to also enable end users who connect their phones using connectify me to their laptops to be able to communicate with each other,provided both the laptops are connected to the university network(may not share same subnet).However, even if that is not posible, atleast two devices residing on two different subnets must be able to discover each other. Thereafter, voice calls can be made from one device to another. The idea for discovery is via broadcast messages. There would be no central server. I am new to network programming and also android programming(though I have prior knowledge of core java). Kindly help with the procedure to broadcast messages across my university network for the initial device discovery stage and also suggest any protocols that I need to learn and any codecs for conversion from voice to data. Any other help regarding design and implementation would also be welcomed with gratitude. Please reply as soon as possible.
Broadcast does not cross subnets. For instance pinging 255.255.255.255 on a class C network is the same as pinging A.B.C.255 with A.B.C being the first 3 Octets of your IP address.
Since you mentioned
broadcast messages across my university network
I believe you want to reach destinations beyond your own subnet. You could do so by using DHCP , which would use the routers as a relay agent to forward broadcasts to different subnets. However, I would rather use Multicast as eee mentioned earlier.
Related
I am developing an app in which the first thing i need is how to get devices that are connected to my wifi network or same wifi network .ie ip adress,device name etc.
I don't have any idea how to do that have searched alot but there are no examples available.
I have done one thing that i will ping 255 ips and whichever will respond will be the connected ips but the problem here is that there are virtual ips already assigned to some websites so i need to detect only the real device ip addresses.
I want to do the same thing as done in the app WifiTalkie
Follow Any one of the following:
Way1:
If you mean you want to see all the devices connected to your current WiFi connection (and you are not trying to do Ad Hoc networking), then you are essentially wanting to run a network scanner.
There are a bunch of these around. This one has the source available on github
http://rorist.github.com/android-network-discovery/
Way2:
Refer How to detect all the Devices connected in a WiFi network from Android App
I created an Android/Desktop game which supports multiplayer on a local area network. I am using DatagramPackets and right now I have hard coded 2 local IP addresses for testing purposes.
How do I make it so when one device is hosting a game anyone else running the game can detect that hosted game on the LAN. Basically I need to get the Local IP Address of the person who is hosting my game from another device connected to the same router searching for a game on the network.
This is how I am currently detecting the other devices on the network by hard coding the address.
outgoingPacket.setAddress(InetAddress.getByName("192.168.1.20"));
I imagine I should be using a broadcast of some sort.
I suspect that you're looking for a more generic broadcast capability that's described here.
Multicast is a whole other kettle of fish!
I think that the best way to do this is to use 1 specific port for the games, and see if someone is online on that port in the network.
I would like to manage a connection between 2 applications, they will run on diffrent phones.
The purpose doesn't really matters let's say that it would be some kind of a chat.
How can I create this connection between the applications? I know how to do it on pc java programs using the socket and the serverSocket classes but I guess it's diffrent in here since the phone might change his ip when he moves between networks.
So how would you do that? how would you create a connection between 2 applications/phones
Given the scenario you described in your comment, using Push Notification i.e Google Cloud Messaging (GCM) might be sufficient.
So, when program B wants update from program A, it will ask the server to push a notification (via GCM) to program A. Note that program A will not connect to the server every x time to check for updates.
Another out-of-the-box solution is to use SMS if the communication is not so frequent and messages are short. Here I mean SMS that will be processed directly by your app (given it has certain attention word) and will not go to the inbox i.e. no SMS notification on the phone
Since the two phones will, as you note, have changing IP addresses, you'll probably need to use an intermediary.
The general design pattern here would be to have a server with a fixed IP or DNS address that relays messages between your two mobile devices. The simplest implementation would be a webserver, to which each phone would connect via HTTP(S) to transmit data or poll for updates.
There are a number of backend-as-a-service platforms that provide this type of functionality pre-built, and would likely suffice for something like a chat system. Check out Cloudmine and Parse.
If you need a low-latency or near-realtime connection, you could also consider implementing your own server that uses the Android C2DM (Cloud to Device Messaging) service.
See Android's Sample Bluetooth Chat App, It will give you an idea for how it can be achieved.
I have written a variety of network programmes such as chats and games, but the user always had to enter the ip of the server, which is very unusual.
I want to realize a server browser you may know from common games, which locates servers in the lan automatically. I want to do it in Java.
My questions are:
How does that browsing work? Also WiFi for example, just everything which automatically finds another party.
Would it be possible and also a good approach to broadcast status packages to whole lan all the time? Which time intervals would be useful?
For WiFi, the device listens to a certain frequency range and scans the range for signals. This is much the same process as a TV uses to pick-up stations, or a person might do to find local radio stations.
For an internet game server, you can't scan the entire internet. Normally the services provides a master server which is configured to send the list of servers on a known port. Typically it will also allow servers to update their information as well.
For a local game server, typically it's single packet every few seconds or so. There's actually quite a lot of traffic even on an idle network with various services requesting this sort of data (Apple's discovery protocol, Bonjour is commonly seen, as is the Windows network discovery protocol).
For internet games, there is a central set of servers that host the information needed to a set up a game. In the past, this is typically just the IP address and port of the person hosting the game, as well as any game information, such as the name, map, etc.
These days due to firewall/NAT issues and problems with cheating, most internet games actually send their data through those servers as well. This is expensive to do.
For games on your local network, UDP packets are sent to the broadcast address, which are received by all devices on that subnet. The hosting game sends the packet with information on where to connect, and those joining in receive those packets to know where the game server is. They then connect directly to the game server.
If you are on an IP network and your address is 192.168.1.100 with a subnet mask of 255.255.255.0, then your broadcast IP address is 192.168.1.255. See also: http://en.wikipedia.org/wiki/Broadcast_address#IP_networking
Let's say I have two android mobile devices, connected to the same wireless network, and that network hasnt external/internet access.
Without third party software, is it possible to transfer data through wifi without knowing the ip from each other and without creating an hotspot? Something like we do on Windows (if 2 pcs are on same network, they can share information directly without internet access)
Starting with the basics, I would like to develop an application, where android phones on same network appears on a list , and then a user choose on of them and writes something - and if the other user have the same app running, appears that on his phone (and then he can reply of course - basically, a chat.
I know this make no practical sense, but believe makes all the sense for what I need to do (it's not a chat of course). If anyone knows anything, please help me - i found nothing.
Thanks in advance.
If you want to send data or messages from one phone to another using the network you will eventually need the IP address of the recipient phone. However, If you don't care about targeting specific phones you could always send UDP broadcast packets that each device on the network should receive.
If you don't want to manually specify an IP you'll need to create a discovery protocol that a phone uses to discover all the other phones on the network. You could do this buy scanning all available IP addresses and checking to see if they are a valid android phone. Or you could have each phone broadcast its presence on the network using a UDP broadcast packet sent to a predefined port.
Once you have discovered all the phones on the network its really up to you to decide how you want to send the data between phones and there are hundreds of examples of how to send data between devices/computers/processes using sockets.