You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this update, an ad hoc (IBSS) mode has been added.
Add the 'NL80211_IFTYPE_ADHOC' interface type to wiphy, enabling
it to switch to ad hoc (IBSS) mode through the 'vwifi_change_iface'
operation.
Implement 'vwifi_join_ibss' and 'vwifi_leave_ibss' based on the
'cfg80211_ops' structure to enable IBSS devices to join a specific
IBSS cell and frequency band.
In the global structure 'vwifi_context', add 'ibss_list' to
facilitate finding IBSS devices. When a device joins, it will be
added to the 'ibss_list', and when a device leaves, it will be
removed.
Implement the IBSS mode packet forwarding mechanism.
Additionally, ad-hoc related test items have been added, and the
IBSS devices are scannable.
Update the README file to include information about IBSS mode.
Additionally, WPA support for IBSS mode has been added.
The 'wpa_supplicant_ibss.conf' is used to configure the IBSS
network. Since using WPA to construct an IBSS network results
in the BSSID being automatically generated by the system, the
'vwifi_join_ibss' function does not receive the BSSID parameter.
Thus, adopt the following method to assign its BSSID:
Search the IBSS list for a network with matching WPA settings
(compare the SSID and the frequency band). If found, use its
BSSID. If not, use the device's MAC address as the BSSID.
Check the lengths of the two SSIDs first before using 'memcmp'.
Otherwise, unexpected results might occur.
> In C99 standard : "The 'memcmp' function compares the first n
characters of the object pointed to by s1 to the first n
characters of the object pointed to by s2."
To test the network environment effectively, we utilize **Linux network namespaces**. These namespaces isolate network environments from the host system, providing distinct instances of network stacks with independent routes, firewall rules, and network devices.
40
+
41
+
Without network namespaces, virtual interfaces created within the same namespace use the loopback device for packet transmission between them, as the kernel recognizes them as residing on the same host.
42
+
43
+
In our testing setup, all interfaces created by `vwifi` are placed within an isolated network namespace. This approach ensures that each virtual interface operates independently, facilitating comprehensive testing of networking functionalities without interference from the host's network configuration.
44
+
45
+
Below, we will conduct two separate tests: Infrastructure BSS and Independent BSS.
The testing environment consists of **one AP and two STAs**.
@@ -48,15 +56,12 @@ The AP then performs the following actions based on the packet type:
48
56
2. Broadcast: The AP forwards the packet to all other STAs in the network, except for the source STA, and then passes it to the protocol stack.
49
57
3. Multicast: The AP treats multicast packets the same way as broadcast packets.
50
58
51
-
To test the network environment, we can utilize the **Linux network namespace**.
52
-
Linux network namespace allows us to isolate a network environment from the host system, providing its own routes, firewall rules, and network devices.
53
-
Essentially, it creates a separate instance of the network stack.
Without network namespace, when virtual interfaces are created that share the same network namespace and start transmitting/receiving packets between them,
56
-
the kernel will use the loopback device for packet transmission/reception. This behavior occurs because the kernel identifies that the sender and receiver are on the same host.
57
-
58
-
In conclusion, all the interfaces created by `vwifi` in the testing environment will be added to an isolated network namespace.
62
+
The testing environment consists of **two IBSS devices**.
59
63
64
+
The testing environment operates in IEEE 802.11 independent BSS. IBSS devices can communicate with any device in the same IBSS network **without the need to establish a connection beforehand**. However, devices in different IBSS networks cannot communicate with each other.
60
65
## Build and Run (non-virtio)
61
66
62
67
To build the kernel module, execute the following command:
@@ -72,7 +77,7 @@ $ sudo modprobe cfg80211
72
77
Insert the `vwifi` driver.
73
78
This will create three interfaces (the "station" parameter can be modified according to preference):
74
79
```shell
75
-
$ sudo insmod vwifi.ko station=3
80
+
$ sudo insmod vwifi.ko station=5
76
81
```
77
82
78
83
Please note that interfaces can only be created in station mode during the initialization phase.
@@ -85,7 +90,7 @@ To check the network interfaces, run the following command:
85
90
$ ip link
86
91
```
87
92
88
-
There should be entries starting with `vw0`, `vw1`, and `vw2`, which correspond to the interfaces created by `vwifi`.
93
+
There should be entries starting with `vw0`, `vw1`, `vw2`, `vw3`, and `vw4`, which correspond to the interfaces created by `vwifi`.
89
94
90
95
To view the available wireless interfaces, execute the following command:
91
96
```shell
@@ -94,24 +99,41 @@ $ sudo iw dev
94
99
95
100
You should see something similar to the following output:
96
101
```
97
-
phy#2
102
+
phy#5
103
+
Interface vw4
104
+
ifindex 7
105
+
wdev 0x500000001
106
+
addr 00:76:77:34:00:00
107
+
type managed
108
+
txpower 0.00 dBm
109
+
phy#4
110
+
Interface vw3
111
+
ifindex 6
112
+
wdev 0x400000001
113
+
addr 00:76:77:33:00:00
114
+
type managed
115
+
txpower 0.00 dBm
116
+
phy#3
98
117
Interface vw2
99
118
ifindex 5
100
-
wdev 0x200000001
101
-
addr 00:6f:77:6c:32:00
119
+
wdev 0x300000001
120
+
addr 00:76:77:32:00:00
102
121
type managed
103
-
phy#1
122
+
txpower 0.00 dBm
123
+
phy#2
104
124
Interface vw1
105
125
ifindex 4
106
-
wdev 0x100000001
107
-
addr 00:6f:77:6c:31:00
126
+
wdev 0x200000001
127
+
addr 00:76:77:31:00:00
108
128
type managed
109
-
phy#0
129
+
txpower 0.00 dBm
130
+
phy#1
110
131
Interface vw0
111
132
ifindex 3
112
-
wdev 0x1
113
-
addr 00:6f:77:6c:30:00
133
+
wdev 0x100000001
134
+
addr 00:76:77:30:00:00
114
135
type managed
136
+
txpower 0.00 dBm
115
137
```
116
138
117
139
As observed, each interface has its own phy (`struct wiphy`), allowing them to be placed into separate network namespaces.
Check whether the name of each `wiphy` is the same as the name listing under the command `sudo iw list`
413
+
```shell
414
+
$ echo$vw3_phy
415
+
vw_phy3
416
+
$ echo$vw4_phy
417
+
vw_phy4
418
+
```
419
+
Assign the two interfaces to separate network namespaces.
420
+
Please note that the `wiphy` is placed within the network namespace, and the interface associated with that wiphy will be contained within it.
421
+
```shell
422
+
$ sudo iw phy vw_phy3 set netns name ns3
423
+
$ sudo iw phy vw_phy4 set netns name ns4
424
+
```
425
+
#### Assigning IP Addresses to Each Interface
426
+
427
+
Now, assign an IP address to both interfaces using the following commands:
428
+
```shell
429
+
$ sudo ip netns exec ns3 ip addr add 10.0.0.4/24 dev vw3
430
+
$ sudo ip netns exec ns4 ip addr add 10.0.0.5/24 dev vw4
431
+
```
432
+
There are two methods to configure an IBSS network: manual configuration or using WPA.
433
+
#### Option1 : Manual configuration
434
+
##### Switch to IBSS mode
435
+
Switch device to IBSS mode using the following command :
436
+
437
+
***iw dev [interface] set type ibss***
438
+
439
+
The following commands switch `vw3` and `vw4` to IBSS mode.
440
+
```shell
441
+
$ sudo ip netns exec ns3 iw dev vw3 settype ibss
442
+
$ sudo ip netns exec ns4 iw dev vw4 settype ibss
443
+
```
444
+
Check the information of `vw3`.
445
+
```shell
446
+
$ sudo ip netns exec ns3 iw dev vw3 info
447
+
```
448
+
You should see output similar to the following:
449
+
```
450
+
Interface vw3
451
+
ifindex 6
452
+
wdev 0x400000001
453
+
addr 00:76:77:33:00:00
454
+
type IBSS
455
+
wiphy 4
456
+
txpower 0.00 dBm
457
+
```
458
+
##### Join IBSS network
459
+
```shell
460
+
$ sudo ip netns exec ns3 ip link set vw3 up
461
+
$ sudo ip netns exec ns4 ip link set vw4 up
462
+
```
463
+
Users can join a specific IBSS cell and configure additional settings using the command :
464
+
465
+
***iw dev [interface] ibss join [SSID][freq in MHz][NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz][fixed-freq][fixed-bssid][beacon-interval <TU>][basic-rates <rate in Mbps,rate2,…>][mcast-rate <rateinMbps>][key d:0:abcde]***
466
+
467
+
If the IBSS cell does not already exist, it will be created.
468
+
469
+
The following command makes `vw3` and `vw4` join the same IBSS cell with the SSID `ibss1` and specifies the frequency as 2412 MHz:
470
+
```shell
471
+
$ sudo ip netns exec ns3 iw dev vw3 ibss join ibss1 2412 NOHT fixed-freq 00:76:77:33:00:00 beacon-interval 200
472
+
$ sudo ip netns exec ns4 iw dev vw4 ibss join ibss1 2412 NOHT fixed-freq 00:76:77:33:00:00 beacon-interval 200
473
+
```
474
+
Check the information of `vw3`.
475
+
```shell
476
+
$ sudo ip netns exec ns3 iw dev vw3 info
477
+
```
478
+
You should see output similar to the following:
479
+
```
480
+
Interface vw3
481
+
ifindex 6
482
+
wdev 0x400000001
483
+
addr 00:76:77:33:00:00
484
+
ssid ibss1
485
+
type IBSS
486
+
wiphy 4
487
+
txpower 0.00 dBm
488
+
```
489
+
#### Option2 : Using WPA
490
+
```shell
491
+
$ sudo ip netns exec ns3 ip link set vw3 up
492
+
$ sudo ip netns exec ns4 ip link set vw4 up
493
+
```
494
+
Prepare the following script `wpa_supplicant_ibss.conf` (you can modify the script based on your needs):
495
+
```shell
496
+
network={
497
+
ssid="ibss1"
498
+
mode=1
499
+
frequency=2412
500
+
key_mgmt=WPA-PSK
501
+
proto=RSN
502
+
pairwise=CCMP
503
+
group=CCMP
504
+
psk="12345678"
505
+
}
506
+
```
507
+
Using the command **wpa_supplicant**, configure `vw3` and `vw4` to join `ibss1`.
0 commit comments