移动应用网络优化

基础
字节序
小端:将低序字节存储在低地址   (0x01020304, 04存在低地址)
大端:将高序字节存储在低地址    (0x01020304, 01存在低地址)
网络字节序是大端字节序


dns优化
    cache, multiple IPs


tcp优化

Delay-ack(200ms), ack with data send or timeout, TCP_QUICKACK(每次recv之后需要重设) 关闭之,
Nagle, collect and send on ack or timeout, TCP_NODELAY 关闭之
当TCP_CORK选项被设置时,TCP链接不会发送任何的小包,即只有当数据量达到MSS时,才会被发送。
tcp_defer_accept, 接收到SYN马上accept连接

tcp fast open, 第一次三次握手,后续直接在syn/syn-ack中带应用数据,为防止DOS,通过tcp-cookie进行验证。


SSL
   tcp/ssl连接优化:重用连接,近距离代理



http优化
http2
  http1.0 to http1.1


http1.0/http1.1/SPDY/http2.0 (http2.0基于SPDY开发)


http1.0, one request
http 1.1, pipeline,  head-of-line blocking??

http2.0





wifi


运营商网络



2G to 3G







full power/low power/standby
Returning to full power from the low state takes around 1.5 seconds, while moving from idle to full can take over 2 seconds.
So for a typical 3G device, every data transfer session will cause the radio to draw energy for almost 20 seconds.

When connected over a wireless radio, higher bandwidth generally comes at the price of higher battery cost. Meaning that LTE typically consumes more energy than 3G, which is in turn more expensive than 2G.

LTE architecture














The Radio State Machine


另外一个概念是tcp连接时间
运营商网关保持internal-ip, 国内5/10min


application
     Use urlconnection to support gzip by default.
    image resize



GCM

port:5228,5229
 /*
  * packet(from server) format:
  * header + playload
  *
  * header format:
  * cmd + payload_len
  *
  * payload format:
  * protobuf packet
  *
  * attention:
  * the first byte from server doesn't belong to the first packet, need to remove it
  * this byte could be the version or sth. else
  */

gcm heartbeat interval:
  28mins  -- mobile
  15mins  -- wifi
  dynamic 


WeChat
heartbeats every 4 ~ 5 minutes with 16 bytes




工具:
DDMS - Network Traffic Tool
tcpdump
ss
netstat
    
traceroute
    
MobiPerf

Application Resource Optimizer by AT&T


参考:
<High Performance Browser Networking.pdf>
<Profiling Resource Usage for Mobile Application>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值