Wifiアドホックモード

そもそもWIFIアドホックモードとは?

WIFIのモードには大きく分けて3つあります。
1、インフラストラクチャーモード(Master)
2、アドホック(Ad-hoc)
3、クライアント(Managed)

インフラストラクチャーモードは、APとして振る舞うモードです。
アドホックモードは、端末と端末同士で通信するモードです。
クライアントモードは、インフラストラクチャーモードとして振る舞っているAPに接続するモードです。

通常、クライアントモードになれる端末は基本的にはアドホックモードにも対応しています。
しかし、AndroidではWifiアドホックモードがあえてできないようになっています。

それを出来るようにしようというのが今回の話です。
その前に、これができるとどんないいことがあるのか?

率直に申しますと、アドホックモードだからいいことはそんなありません。普段スマホを使う上でAPを介さずに通信したいなんてことはほとんどありませんからね。
じゃあなぜ、わざわざアドホックモードをONにするのか?

それは、
例えば震災が起きてAPが使えなくなったとき、アドホックモードを使って端末同士をつなぎ他の人と通信をすることができるというメリットがあるためです。これらについて研究されてるのがDTNと呼ばれる遅延耐性ネットワークです。詳しくはググってください。

ではアドホック通信の話に移りましょう。

アドホックモードで通信をするには、二通りあります。

  1. Androidの設定画面にアドホックネットワークを表示させ、つなぎに行く方法
  2. Wireless Tetherアプリでアドホックネットワークを作り、接続を待つ方法

Android アドホック」でググルとほとんど1個目の情報が出てきます、しかしWireless Tetherというアプリでもアドホックモードに対応させることができます。

一応私が試した中だと、どちらかが対応している場合は二つともできるはずです。
今回は、1個目の「Androidの設定画面にアドホックネットワークを表示させ、つなぎに行く方法」
を紹介します。

まぁそんな難しいことではありません。
Linuxになれた人(Linuxを触ったことがある人)向けに言えば。

無線LANクライアントツールである、「wpa_supplicant」という実行ファイルをアドホック対応のもの置き換えるだけです。

ただその際に、SystemeディレクトリはRead-OnlyファイルシステムなのでRWでRemoutしたりして書き込みできるようにしないといけません。
こんな感じで。
#mount -o remount,rw /system /system

まぁハマるところはそれぐらいですかね。

アドホックに対応した、wpa_supplicantは対応したものを探してください。
ただ、最新の機種だとなかなか見つかりづらいです。
Galaxy NexusとNexus7は見つかりませんでした。。。

今回言いたいことは、アドホック対応化というと1個目の情報しか出てこないんですが2個目の方法もあるよということですね。

Ps, Iphoneは標準でアドホック通信に対応しているようですね。




First of all describe the outline of wifi Ad-hoc mode.

Wifi Ad-hoc was roughly Classified into 3 types like the bellow:

  1. Infrastructure Mode
  1. Ad-hoc Mode
  1. Client Mode

the function of "Infrastructure Mode" is to behave as Access point.
the case of "Ad-hoc Mode" is to behave so that it support It can connect each device without Access point.
the last one is "Client Mode" which support to connect the device behaving with Infrastructure Mode.

Normally the device which can become Client Mode is supported to Ad-hoc Mode as well.
But in the case of Android device Ad-hoc Mode is got disable by google on purpose.
I don't know the reason why Google does such a thing.

Then the article of this time is that I enable this function to be allowed on Android.
But before I talk about the way I think I wanna talk about the benefit of Ad-hoc

the benefit is following :
For example, when we can't use Access point because of the disaster like earthquake , if
you can use adhoc-mode , you can pass the data to nearby person and the person can pass the data to other nearby person as well and that is repeated and repeated …
So the data you wanna send to can be reached.
which is called "DTN(Delay Tolerant Networking)" . if you wanna know it, you can search with google.

Then the article is moved to Ad-hoc Mode on Android.
In order to realize Ad-hoc communication, there are two way as long as I know.

・make default setting view to show existing Ad-hoc network and connect to one
・Using the App named "Wireless Tether" I made the Ad-hoc network and wait the connection ( this expression may be inappropriate )

If you searched the information with like this " Android Ad-hoc" , you can perhaps see the way I introduced at the first. But you should know there is other way.
Generally as long as I tried , if the device correspond to the way , correspond to the other way as well.