Closed jychen0611 closed 2 months ago
Have you tried vwifi with WPA/RSN support in IBSS mode?
Have you tried vwifi with WPA/RSN support in IBSS mode?
I tried using the following file, and it worked.
network={
ssid="ibss1"
mode=1
frequency=2412
key_mgmt=WPA-PSK
proto=RSN
pairwise=CCMP
group=CCMP
psk="12345678"
}
Using the command wpa_supplicant, configure vw3 and vw4 to join ibss1:
$ wpa_supplicant -i vw3 -B -c scripts/wpa_supplicant_ibss.conf
Successfully initialized wpa_supplicant
$ wpa_supplicant -i vw4 -B -c scripts/wpa_supplicant_ibss.conf
Successfully initialized wpa_supplicant
Observing the interface information confirms both successfully joined ibss1:
Interface vw3
ifindex 12
wdev 0x900000001
addr 00:76:77:33:00:00
ssid ibss1
type IBSS
wiphy 9
txpower 14.00 dBm
Interface vw4
ifindex 13
wdev 0xa00000001
addr 00:76:77:34:00:00
ssid ibss1
type IBSS
wiphy 10
txpower 15.00 dBm
The kernel messages shows that initially ibss1 did not exist, so vw3 created it. vw4, through scanning, discovered the existence of ibss1 and joined it:
[ 205.578356] vwifi : vw3 start acting in IBSS mode.
[ 205.578720] vwifi : vw3 join ibss1.
[ 205.639498] vwifi: vw4 performs scan, found vw3 (SSID: ibss1, BSSID: 00:00:00:00:00:00)
[ 205.639506] cap = 18, beacon_ie_len = 35
[ 205.640141] vwifi : vw4 start acting in IBSS mode.
[ 205.640475] vwifi : vw4 join ibss1.
It's noteworthy that when creating an IBSS network with WPA, the BSSID is automatically generated by the system. This ensures each IBSS network is unique.
Attempting to ping from vw3 to vw4 results in successful packet delivery:
$ sudo ip netns exec ns3 ping -c 1 10.0.0.5
================================================================================
Ping Test: IBSS vw3 (10.0.0.4) (in ibss1) <--> IBSS vw4 (10.0.0.5) (in ibss1)
(should success)
(be patient, it will take some time to route...)
================================================================================
PING 10.0.0.5 (10.0.0.5) 56(84) bytes of data.
64 bytes from 10.0.0.5: icmp_seq=1 ttl=64 time=1031 ms
--- 10.0.0.5 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1031.052/1031.052/1031.052/0.000 ms
vw5 manually creates and joins ibss2, while vw3 and vw4 join ibss1 using WPA:
sudo ip netns exec ns5 iw dev vw5 set type ibss
$ sudo ip netns exec ns5 iw dev vw5 ibss join ibss2 2412 NOHT fixed-freq 00:76:77:35:00:00 beacon-interval 300
$ sudo ip netns exec ns3 ip addr add 10.0.0.4/24 dev vw3
$ sudo ip netns exec ns4 ip addr add 10.0.0.5/24 dev vw4
$ sudo ip netns exec ns5 ip addr add 10.0.0.6/24 dev vw5
$ sudo ip netns exec ns3 wpa_supplicant -i vw3 -B -c scripts/wpa_supplicant_ibss.conf
$ sudo ip netns exec ns4 wpa_supplicant -i vw4 -B -c scripts/wpa_supplicant_ibss.conf
Observing kernel messages shows that vw5 initially creates ibss2, so when vw3 attempts to join using WPA, it scans and finds ibss2 but creates ibss1 instead. vw4, upon scanning, discovers both ibss1 and ibss2, and chooses to join ibss1:
[ 961.600176] vwifi : vw5 start acting in IBSS mode.
[ 961.613599] vwifi : vw5 join ibss2.
[ 962.020891] vwifi: vw3 performs scan, found vw5 (SSID: ibss2, BSSID: 00:76:77:35:00:00)
[ 962.020897] cap = 2, beacon_ie_len = 0
[ 962.021099] vwifi : vw3 start acting in IBSS mode.
[ 962.021256] vwifi : vw3 join ibss1.
[ 962.159989] vwifi: vw4 performs scan, found vw5 (SSID: ibss2, BSSID: 00:76:77:35:00:00)
[ 962.159998] cap = 2, beacon_ie_len = 0
[ 962.160004] vwifi: vw4 performs scan, found vw3 (SSID: ibss1, BSSID: 00:00:00:00:00:00)
[ 962.160006] cap = 18, beacon_ie_len = 35
[ 962.160645] vwifi : vw4 start acting in IBSS mode.
[ 962.160989] vwifi : vw4 join ibss1.
Attempting to ping from vw3 to vw5 fails to deliver packets:
$ sudo ip netns exec ns3 ping -c 1 10.0.0.6
================================================================================
Ping Test: IBSS vw3 (10.0.0.4) (in ibss1) <--> IBSS vw5 (10.0.0.6) (in ibss2)
(should fail)
(be patient, it will take some time to route...)
================================================================================
PING 10.0.0.6 (10.0.0.6) 56(84) bytes of data.
From 10.0.0.4 icmp_seq=1 Destination Host Unreachable
--- 10.0.0.6 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
I suggest that the commit message should contain what you have done (e.g. implement
cfg80211_ops->join_ibss()
) rather than the tutorial on how to setup the environment. However, the tutorial can be moved toREADME.md
.
The adjustments have been completed.
The WPA-related tests and explanations have been updated. @rickywu0421
I defer to @rickywu0421 for confirmation.
Thank @jychen0611 for contributing!
In this update, an ad-hoc (IBSS) mode has been added. Users can switch their device to IBSS mode using the following command : iw dev [interface] set type ibss
To join a specific IBSS cell and configure other settings, users can use the command :
iw dev [interface] ibss join [SSID] [freq in MHz] [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [fixed-freq] [] [beacon-interval ]
[basic-rates <rate in Mbps,rate2,…>] [mcast-rate ] [key d:0:abcde]
eg. iw dev vw3 ibss join Elian 2412 NOHT fixed-freq 00:76:77:33:00:00 beacon-interval 200 This command signifies that the device vw3 will either join an existing Ad-Hoc network named Elian or create one if it doesn't exist. The device will use the 2412 MHz frequency, not utilize High Throughput mode (802.11n), and maintain a fixed frequency without changes due to other devices. The BSSID (Basic Service Set Identifier) for the IBSS will be set as 00:76:77:33:00:00, and the beacon interval, which is the time between two consecutive beacons, will be set to 200 Time Units (TUs).
To leave the current Ad-Hoc network, users can use command : iw dev [interface] ibss leave
Additionally, ad-hoc related test items have been added, and the IBSS devices are scannable.
ping test
scan result
kernel messages