jugalshah / adhoc-on-android

Automatically exported from code.google.com/p/adhoc-on-android
0 stars 0 forks source link

Udp receiver doesn't see packets from other phones?? #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, 
This is not a bug report, but rather a question.  First of all, congratulations 
on an excellent project.  Your code is very nice and has been very helpful 
effort to implement adhoc networking in our project (see 
http://code.google.com/p/posit-mobile/). I have also recommended your project 
as a model to some of my students.

I've downloaded and adapted your Udp Code to use with our own protocol. 
Everything works fine when I implement it in infrastructure mode -- i.e., using 
a Wifi hotspot as the broadcast node.  But in adhoc mode I'm having trouble 
getting the packets to be received by the Udp receiver.   Here's how I set up 
each phone, with X being a unique hash code between 0 and 254. I'm doing this 
on G1 phones.

# insmod /system/lib/modules/wlan.ko
# wlan_loader -f /system/etc/wifi/Fw1251r1c.bin -e /proc/calibration -i 
/data/local/bin/tiwlan.ini
# ifconfig rmnet0 192.168.2.X  netmask 255.255.255.0
# ifconfig rmnet0 up

And in my tiwlan.ini  I have the phone set to Adhoc mode:

WiFiAdhoc = 1
dot11DesiredChannel = 6
dot11DesiredSSID = hfossadhoc
dot11DesiredBSSType = 0

And here's how I create and broadcast packets:

IPAddress = InetAddress.getByName("192.168.2.255");  // Broadcast address 
DatagramPacket packet = new DatagramPacket(bytes, bytes.length, IPAddress, 
8889);
datagramSocket = new DatagramSocket(8881);
datagramSocket.send(packet);

The Upd receiver socket listens on port 8889.   What happens is that the phone 
that sent the packet does receive it. But other phones either don't receive it 
at all or silently reject the packets. Can you think of any reason why this 
would be?  Hardware differences? Firewall?

I couldn't find your email or I would have contacted you that way.

Once again, congratulations on a nice thesis result!

Regards,
-- ralph (ralph.morelli@trincoll.edu)

Original issue reported on code.google.com by ram8...@gmail.com on 25 Oct 2010 at 8:53

GoogleCodeExporter commented 8 years ago
Hi,
Thank you for your nice words, I am glad to hear that our thesis has been 
helpful.

The issue you have encountered seems to be a bug. We actually encountered 
exactly the same problem with adhoc mode, where my G1 (htc hero) phone did not 
seem to receive any packages the day before we had to defend our thesis!

What puzzled us was that the udp layer had been working correctly while we did 
the test of our library earlier. We discovered (by enabling debugging through 
the adhoc.etc.Debug class) that the G1 phone did sent correct packages to the 
udp and that other phones or laptops running the library on a laptop didn't 
register receiving these packages. We had Wireshark sniffing for packages on 
the laptop which didn't receive anything too.
But this problem did not occur at all with the nexus one phone (it could 
communicate with the laptop and wireshark was receiving all packages), which 
suggest that this issue is phone-dependent.

Everything that you have written you have done is as it should be nothing wrong 
there. The problem occurred with my G1 after i flashed it with another rom that 
runs Android 2.1. The previous rom was MoDaCo (I do not remember much detail 
about version etc.) running Android 1.5.

As I see it, the issue maybe has to do with upgrading from 1.5 to 2.1 which may 
have changed the way of starting adhoc networks on G1 phones. It may be 
possible that "insmod" or some other crucial shell command is not available 
without e.g. busybox installed on them.

I would like to spend the time to try and fix this issue as I think it is 
important, but in the next week I am pretty busy, so it will be after that.

In the meantime if you have any questions or maybe even discover the reason, 
you are welcome to mail me on jradi88@gmail.com

Best Regards,
Rabie Jradi

Original comment by jrad...@gmail.com on 27 Oct 2010 at 5:56

GoogleCodeExporter commented 8 years ago

Original comment by jrad...@gmail.com on 21 Dec 2010 at 2:55

GoogleCodeExporter commented 8 years ago
The problem I found with the instructions was that the location of the 
tiwlan.ini file moved. When you run the wlan_loader command, it does not 
complain if you point it at the wrong location.

Original comment by fho...@gmail.com on 11 Oct 2011 at 2:33

GoogleCodeExporter commented 8 years ago
Actually the reason for this issue was discovered some time ago by Ralph (the 
one who started this issue). The emailed me with the following solution:

Ralph Morelli <ram8...@gmail.com>    10 November 2010 01:29
To: jradi88@gmail.com
Hi Rabie,

I'm happy to report that I've finally got adhoc networking working on the G1.  

We use the same configuration that you do for tiwlan.ini:
   *    WiFiAdhoc = 1

   *    dot11DesiredChannel = 6
   *    dot11DesiredSSID = G1Tether
   *    dot11DesiredBSSType = 0
Here is how the phone is put into adhoc mode (requires root access):
 *     insmod wlan.ko
 *     wlan_loader -f /system/etc/wifi/Fw1251r1c.bin -e /proc/calibration -i /data/data/org.hfoss.posit.android/conf/tiwlan.ini

 *     ifconfig tiwlan0 " + MY_IP + " netmask 255.255.255.0
 *     ifconfig tiwlan0 up
MY_IP is constructed from the 192.168.2 subnet plus the has of the phone's 
Unique ID.
We use either the phone's Mac Address or its IMEI.  And messages are broadcast 
to 192.168.2.255.

So it seems that the main differences between this and the commands described 
in your
startstopadhoc.c is the use of tiwlan0 as the interface rather than rmnet0.

Our use of tiwlan0 is based on the setup commands used by the Android WiFi 
Tether project
(http://code.google.com/p/android-wifi-tether/) and this project 
(http://www4.ncsu.edu/~dwgureck/csc714/)
which we were using in the previous version of our system.  However, in our 
previous version, we
were using a much more complicated setup routine.  This is nice and simple. 

You can see our code here:  
http://code.google.com/p/posit-mobile/wiki/SourceTab?tm=4

Would this work for you?  Any thoughts??

Regards,
-- ralph

Original comment by jrad...@gmail.com on 25 Oct 2011 at 7:41