# 2025q1 Homework1 (ideas) contributed by < timsong1 > ## [Linux 核心專題: 虛擬無線網路裝置驅動程式](https://hackmd.io/@sysprog/rJ-LF4nNC) [vwifi](https://github.com/sysprog21/vwifi) 是個程式碼約~三千行,具體而微的 WiFi 裝置驅動程式,採用 cfg80211 框架。目前 vwifi 支援 scan, connect, disconnect 等 cfg80211 的介面操作,並得以正確處理 Tx/Rx 封包。 --- ### FullMAC vs. SoftMAC 主要就是差在 [MLME](https://blog.csdn.net/lixiaofeng0/article/details/139775690) (MAC layer management entity) 是在硬體還是軟體上實現  **FullMAC** : 1. MLME 透過硬體實現,所有 WIFI 協議的部分都交由韌體處理 2. 執行快、不占用 CPU **SoftMAC** : 1. MLME 透過軟體實現 2. 硬體成本低 3. 驅動如果要更新,可以直接透過更新軟體來實現 不管是 FullMAC SoftMAC 設備都需要透過 cfg80211 來讓 linux 核心知道他們的存在 --- ### cfg80211, mac80211, nl80211 [cfg80211](https://docs.kernel.org/driver-api/80211/cfg80211.html) subsystem 提供了一個統一的 API,使得驅動可以對 WIFI 設備進行配置管理 - 不直接處理 WIFI 數據資料,而是負責設備配置與管理 - 通常會與 FullMAC, Mac80211, nl80211 一起工作,即便不使用 mac80211,仍可用於 FullMAC 設備驅動 - 提供與 user space 溝通的介面 (搭配 nl80211) [mac80211]() subsystem 是專門寫 SoftMAC 驅動的框架,意思就是只適用於 SoftMAC 設備,負責處理 [IEEE 802.11](https://hackmd.io/@jychen0611/IEEE_802_11) 協議的部分 - 不會直接與 user space 溝通,而是透過 cfg80211 來處理來自 user space 的請求 簡單來說,cfg80211 負責解析 user space 請求,透過 [callback](https://learnlinuxconcepts.blogspot.com/2014/11/explain-callback-functions.html) 函數來呼叫 mac80211 來執行 WIFI 操作 (如掃描、連接等等) [nl80211]() 是 linux 核心的 user space API for [IEEE 802.11](https://hackmd.io/@jychen0611/IEEE_802_11),像是 `iw`、`wpa_supplicant` 來與 cfg80211 和 mac80211 subsystem 溝通 - cfg80211 是在 linux 核心裡對 WIFI 設備進行配置管理,而 nl80211 則是在 user space 對 WIFI 設備進行配置管理  ``` +------------------------+ +-------------------+ | User-space tools | | Kernel (vwifi) | | (iw, hostapd, etc) | | | +-----------+------------+ +----------+--------+ | | | Netlink / cfg80211 call | v | +------------------+ | | cfg80211_ops | | | (scan/connect/...) | +------------------+ | | v | +-----------------+ | | vwifi_vif | | | (STA / AP / IBSS) | +--------+--------+ | | | Packet RX/TX logic | | |<--------------------------------+ | | v v 驗證連線成功 驗證封包是否可收 ``` --- ### ideas: 支援實體網卡 vwifi 是透過創建虛擬網卡(支援 station、access point、ibss 等模式),透過實作 `cfg80211_ops` 、 Tx/Rx 來模擬整個網卡以及傳輸行為,但從頭到尾沒有與實體網卡交互。 因此我好奇能不能在原本的架構上擴充,支援特定型號的實體網卡 以下是需要探討的問題 1. 網卡要 FullMAC 還是 SoftMAC ? vwifi 只有實作 `cfg80211`,而根據 [cfg80211 說明](https://wireless.docs.kernel.org/en/latest/en/developers/documentation/cfg80211.html) >All new Linux wireless drivers should be written targeting either cfg80211 for fullmac devices or mac80211 for softmac devices. 對於 vwifi 來說,是屬於 FullMAC 驅動,如果要先擴充成支援 FullMAC 實體網卡的話,驅動也是透過 `cfg80211` 2. 要使用哪個品牌、型號的網卡? 3. 支援兩個實體網卡互相通訊,還是跟 vwifi 一樣自己模擬通訊 ?
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up