Git Product home page Git Product logo

vwifi's Introduction

vwifi: A Simple Virtual Wireless Driver for Linux

vwifi implements a minimal interface to achieve basic functionalities, such as scanning dummy Wi-Fi network, connecting, and disconnecting from it. vwifi is based on cfg80211 subsystem, which works together with FullMAC drivers. At present, it only supports station mode (STA).

Prerequisite

The following packages must be installed before building vwifi.

In order to compile the kernel driver successfully, package versions of currently used kernel, kernel-devel and kernel-headers need to be matched.

$ sudo apt install linux-headers-$(uname -r)

Since vwifi relies on the Linux wireless (IEEE-802.11) subsystem, iw is necessary for retrieving more information and configuring:

sudo apt install iw

Build and Run

Run make to build the kernel module:

make

Load cfg80211 kernel module:

sudo modprobe cfg80211

Insert vwifi driver:

sudo insmod vwifi.ko ssid_list='[MyHomeWiFi][MyWifi_1][MyWifi_2]'

Check network interfaces:

ip link

There should be an entry starting with owl0, which is exactly the interface created by vwifi.

Bring up the network interface:

sudo ip link set owl0 up

Show available wireless interfaces:

sudo iw dev

You should get something as following:

phy#0
	Interface owl0
		ifindex 3
		wdev 0x1
		addr 00:00:00:00:00:00
		type managed

Dump wireless information:

sudo iw list

Reference output:

Wiphy owl
	max # scan SSIDs: 69
	max scan IEs length: 0 bytes
	max # sched scan SSIDs: 0
	max # match sets: 0
	max # scan plans: 1
	max scan plan interval: -1
	max scan plan iterations: 0
	Retry short limit: 7
	Retry long limit: 4
	Coverage class: 0 (up to 0m)
	Available Antennas: TX 0 RX 0
	Supported interface modes:
		 * managed

Then, perform scanning:

sudo iw dev owl0 scan

You should get the following:

BSS ca:9c:00:c6:c2:eb(on owl0)
	TSF: 47065806941 usec (0d, 13:04:25)
	freq: 2437
	beacon interval: 100 TUs
	capability: ESS (0x0001)
	signal: -59.00 dBm
	last seen: 0 ms ago
	SSID: MyHomeWifi
	SSID: MyHomeWiFi

Finally, we can connect to the dummy SSID MyHomeWiFi:

sudo iw dev owl0 connect MyHomeWiFi

Validate the connection:

sudo iw dev owl0 link

Reference output:

Connected to 26:05:d1:60:34:c8 (on owl0)
	SSID: MyHomeWiFi
	freq: 2437

Change wifi list:

echo -n "[MyHomeWiFi][MyWifi_1][MyWifi_2]" | sudo tee /sys/module/vwifi/parameters/ssid_list

SSID Naming Convention:

Don't put [ or ] in your SSID. Also, the length of each SSID should be restricted between 0 and 32. The default value of ssid_list is [MyHomeWiFi] if it's not specified explicitly by user.

Optional, you can use wireless device monitoring applications such as wavemon to watch signal and noise levels, packet statistics, device configuration and network parameters of vwifi.

sudo apt install wavemon

logo image

Redirect Packet to Kernel Network Stack:

On the host ingress side, if the incoming packet source IP or source MAC is same as the host, the the packet will be ignored by kernel. In order to handle the protocol packets via kernel, we create two network namespaces (netns) to isolate the host network environment and viwifi network counterpart. A network namespace is a logical copy of the network stack from the host system. Network namespaces are useful for setting up containers or virtual environments. Each namespace has its IP addresses, network interfaces, routing tables, and so forth.

On the other hand, a netns need an interface to communicate with host network with L2 ability, and MACVLAN Bridge mode matches the requirement. The MACVLAN provides two essential functionalities for testing scenario.

  1. Create L2 virtual network interface for netns.
  2. Binding L2 virtual network with vwifi network interface.

Hence, when owl0 received the packet, it will send to the namespace and allow kernel network stack manipulating the protocol packets.

logo image

License

vwifi is released under the MIT license. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Reference

vwifi's People

Contributors

jserv avatar dungru avatar rickywu0421 avatar benfzc avatar lekoowo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.