Raspberry Pi临时网络 [英] Raspberry Pi ad-hoc networking
问题描述
我想用Raspberry Pis尝试一些网络项目,我只需要在一对Pis之间发送数据包.作为第一步,我很高兴能够以临时模式在Raspberry Pi之间进行ping操作.尽管在网上查看了一些教程和示例,但我仍未成功完成此操作.
I want to try some networking projects with Raspberry Pis, and I need to just send packets between a pair of pis. I would be happy as a first step just being able to ping between to Raspberry Pis in ad-hoc mode. I have not successfully done this despite looking at several tutorials and examples online.
我有2台安装了Debian Wheezy OS的Raspberry Pi.我正在使用以下USB适配器,我在两个pi上均安装了固件,并通过以托管模式将它们连接到路由器来测试它们是否工作: 总线001设备004:ID 050d:945a Belkin组件F7D1101 v1基本无线适配器[Realtek RTL8188SU]
I have 2x Raspberry Pis with the Debian Wheezy OS installed. I am using the following USB adapter which I installed firmware for on both pis and tested that they work by connected them in managed mode to a router: Bus 001 Device 004: ID 050d:945a Belkin Components F7D1101 v1 Basic Wireless Adapter [Realtek RTL8188SU]
以下是有关网络信息的一些打印输出:
Here are is some printouts about the networking information:
/etc/network/interfaces:
/etc/network/interfaces at each pi:
pi1@raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet manual
address 192.168.2.1
netmask 255.255.255.0
wireless-channel 4
wireless-essid pi-ad-hoc
wireless-mode ad-hoc
pi2@raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet manual
address 192.168.2.2
netmask 255.255.255.0
wireless-channel 4
wireless-essid pi-ad-hoc
wireless-mode ad-hoc
每个pi上的ifconfig:
ifconfig at each pi:
pi1@raspberrypi ~ $ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr ec:1a:59:46:8e:5a
inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:26 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
pi2@raspberrypi ~ $ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr ec:1a:59:46:59:0a
inet addr:192.168.2.2 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:6 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
每个pi上的iwconfig:
iwconfig at each pi:
pi1@raspberrypi ~ $ iwconfig wlan0
wlan0 IEEE 802.11bg ESSID:"pi-ad-hoc" Nickname:"rtl_wifi"
Mode:Ad-Hoc Cell: 02:11:87:FA:4A:02 Bit Rate:54 Mb/s
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
pi2@raspberrypi ~ $ iwconfig wlan0
wlan0 IEEE 802.11bg ESSID:"pi-ad-hoc" Nickname:"rtl_wifi"
Mode:Ad-Hoc Cell: 02:11:87:C4:F2:01 Bit Rate:54 Mb/s
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
在一个pi路线(与其他pi相同):
route at one pi (identical on other pi):
pi1@raspberrypi ~ $ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.2.0 * 255.255.255.0 U 0 0 0 wlan0
每个pi的iwlist扫描:
iwlist scan at each pi:
pi1@raspberrypi ~ $ sudo iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: 02:11:87:FA:4A:02
ESSID:"pi-ad-hoc"
Protocol:IEEE 802.11bg
Mode:Ad-Hoc
Frequency:2.427 GHz (Channel 4)
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Quality:0 Signal level:0 Noise level:0
Cell 04 - Address: 02:11:87:C4:F2:01
ESSID:"pi-ad-hoc"
Protocol:IEEE 802.11bg
Mode:Ad-Hoc
Frequency:2.427 GHz (Channel 4)
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Signal level=100/100
pi2@raspberrypi ~ $ sudo iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: 02:11:87:C4:F2:01
ESSID:"pi-ad-hoc"
Protocol:IEEE 802.11bg
Mode:Ad-Hoc
Frequency:2.427 GHz (Channel 4)
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Quality:0 Signal level:0 Noise level:0
Cell 02 - Address: 02:11:87:FA:4A:02
ESSID:"pi-ad-hoc"
Protocol:IEEE 802.11bg
Mode:Ad-Hoc
Frequency:2.427 GHz (Channel 4)
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Signal level=100/100
Ping不起作用,并且它们之间似乎没有任何网络连接.从iwconfig中,您可以看到它们每个都有一个不同的小区"地址(与iwlist扫描中的小区不同),这是用于定义临时网络的伪基站ID(我的最佳理解是我读过的内容).同样,从iwlist中,每个pi都可以看到他们自己的以及另一个pi的临时网络.我假设他们需要选择相同的Cell ID进行通信,而且我不确定如何让他们自动执行此操作.我尝试在每个pi处使用以下命令静态地将它们强制相同,这不会更改单元格ID,因此无法正常工作:
Ping does not work, and no networking seems to work between them. From iwconfig, you can see that they each have a different "Cell" address (not the same Cell as in the iwlist scan) which is the pseudo-base station ID that is used to define an ad-hoc network (my best understanding from what I've read). Also, from the iwlist, each pi can see their own plus the other pi's ad-hoc network. I assume they need to select the same Cell id to communicate, and I'm unsure how to get them to do this automatically. I tried statically forcing these to be the same with the following command at each pi which did not change the cell id and therefore did not work:
sudo iwconfig wlan0 ap (some address)
我还尝试了一种在wpa_supplicant配置中使用ap_scan = 2的解决方案,该解决方案似乎无济于事.
I also tried a solution which uses ap_scan=2 in the wpa_supplicant config which did not seem to help.
有人知道我做错了什么吗?
Anyone have any idea what I've done wrong?
谢谢, 安迪.
推荐答案
经过一番搜索,我发现我使用的Belkin USB适配器显然不具有Linux驱动程序的即席模式支持.我购买了其他一些效果很好的"Edimax EW-7811Un 150 Mbps无线11n纳米大小USB适配器"无线USB适配器.它们更便宜,更小,并且在临时模式下工作,甚至无需担心驱动程序.如果您还想进行临时的树莓派PI项目,则我用于故障排除的详细信息可以用作指导.
After some searching I found that the Belkin USB adapter I was using apparently didn't have ad-hoc mode support with the linux drivers. I bought some other wireless USB adapaters that worked great "Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter". They are cheaper, smaller, and they worked in ad-hoc mode without even needing to worry drivers. The details I put for troubleshooting can be used as a guide if you are also wanting to do ad-hoc raspberry PI projects.
这篇关于Raspberry Pi临时网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!