android系统中wifi省电模式下的四个基本概念:TIM、DTIM、Beacon-Interval、Listen-Interval

来源:互联网 发布:无线网卡更改mac地址 编辑:程序博客网 时间:2024/05/20 05:58

1、TIM(traffic indication message)

    每一个Beacon的帧中都有一个TIM信息 ,它主要用来由AP通告它管辖下的哪个STA有信息现在缓存在AP 中,而在TIM中包含一个Bitmap control 字段,它最大是251个字节,每一位映射一个STA,当为1时表示该位对应的STA在AP的缓存中有信息。

 

2、DTIM(Delivery Traffic Indication Message )

       DTIM用于AP传统节电模式中,多点的应用,即由AP通过设置DTIM的间隔(缺省是一个beacon时间,100ms),根据这个间隔发送组播流量。
    这个值不会影响单播的流量传递,如果没有开启PS的用户使用组播也不会收到影响,但是会影响开启了PS的用户接收多播数据的传递,如果设置的太小,起不到节电作用,太大又可能会影响组播通讯的质量,这个过程是一个trial-error的调整过程,只能一个一个测试调整,以达到最佳,即既可以达到最佳节电效果又不影响应用。

    调整方法如下:
               1.设置DTIM1,然后记录应用效果,作为基线
               2.然后提高间隔,使应用效果可以接受为止。

               DTIM=1表示每个beacon中都包含DTIM DTIM=2表示每两个beacon中包含一个DTIM,以此类推。
        设置一个合适的DTIM间隔有点麻烦。

 

3、Beacon-Interval(信标间隔)

    这个值变大,有助于client端省电。

    这个值变小,有助于提高client端连接速度。降低了基地台的buffer frame负载。

    一般预设为100mS

    以Beacons 封包发送SSID的速率是1Mbit/S.

 

4、Listen-Interval, (STA即Client接收Beacon 的周期)

    AP 广播Beacon 的周期为Beacon-Interval,STA 可以自由选择Beacon-Interval的整数倍作为自己的Listen-Interval,比如10。

    STA 每隔Listen-Interval 接收Beacon并解码其中的TIM,如果TIM 指示没有数据缓存,STA 就可以立刻转入Doze 状态,如果TIM 指示其有数据缓存,STA 就要向AP 发一个竞选控制包Poll,AP 在收到Poll 后就可以向该Poll 的源STA 发送一个为它缓存的数据包。

 

5、wifi电源模块源码(STATION)

        对应驱动中的pm.c文件,可以自行分析,不是很复杂;

    设置应该是在early_suspend阶段进行的,即驱动注册的early_suspend.suspend指向的函数里面。

    部分源码如下:

    

    #ifdef CONFIG_HAS_EARLYSUSPEND
       static void ath6kl_early_suspend(struct early_suspend *handler)
       {
            struct ath6kl *ar = container_of(handler, struct ath6kl, early_suspend);

            if (ar)
                ar->screen_off = true;
       }

       static void ath6kl_late_resume(struct early_suspend *handler)
      {
            struct ath6kl *ar = container_of(handler, struct ath6kl, early_suspend);

            if (ar)
                ar->screen_off = false;
      }
    #endif

 

void ath6kl_setup_android_resource(struct ath6kl *ar)
{
#ifdef CONFIG_HAS_EARLYSUSPEND
 ar->screen_off = false;
 ar->early_suspend.suspend = ath6kl_early_suspend;
 ar->early_suspend.resume = ath6kl_late_resume;
 ar->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN;
 register_early_suspend(&ar->early_suspend);
#endif
#ifdef CONFIG_HAS_WAKELOCK
 wake_lock_init(&ar->wake_lock, WAKE_LOCK_SUSPEND, "ath6kl_suspend_wl");
 wake_lock_init(&ar->p2p_wake_lock,
   WAKE_LOCK_SUSPEND,
   "ath6kl_p2p_suspend_wl");
#endif
}

 

void ath6kl_cleanup_android_resource(struct ath6kl *ar)
{
#ifdef CONFIG_HAS_EARLYSUSPEND
 unregister_early_suspend(&ar->early_suspend);
#endif
#ifdef CONFIG_HAS_WAKELOCK
 wake_lock_destroy(&ar->wake_lock);
 wake_lock_destroy(&ar->p2p_wake_lock);
#endif
}


原创粉丝点击