# Add 802.11 IBSS mode on wtap(4) [TOC] ## Definitions - time unit (TU): A measurement of time equal to 1024 μs, which is approximately 1 ms. - timeing synchronization function (TSF): A TSF keeps the timers for all STAs in a BSS to fulfill synchronization among STAs. Each STA in BSS maintains a local TSF timer, and periodically exchanging timing information through beacon frame. - target beacon transmission time (TBTT): the time for sending beacon. Beacon interval is the time between two adjacent TBTTs. ## What I have done in concept ### TSF and beacon generation Each STA have to start its local TSF timer when it has reach the state `IEEE80211_S_RUN`, and beacon frames is sended by the STA has larest TSF timer (oldest STA) in an IBSS. TSF timer is keeped in HAL of wtap, it's wroking by continuously updating its value on timer interupt which is simulated via `callout_reset()`. ### IBSS merge Each STA in IBSS mode creates its own IBSS with a randomly-generated BSSID when reaching state `IEEE80211_S_RUN` If we have two WLAN device running in IBSS mode with the same SSID, then there will be two independant IBSSs with two different BSSID. By doing IBSS merge, the STA with smaller TSF timer (younger STA) will be merged into the IBSS which is owned by a STA with larger TSF timer (older STA). After merging process, the younger STA will be in the IBSS created by older STA, and have the BSSID of the this IBSS. After being merged into other IBSS, the STA stops sending beacon frames. ## Affected function ### `wtap_beacon_config()` ```c ``` ### `wtap_newstate()` ```c ```