Author Login Editor-in-Chief Peer Review Editor Work Office Work

Computer Engineering ›› 2015, Vol. 41 ›› Issue (1): 256-260. doi: 10.3969/j.issn.1000-3428.2015.01.048

Previous Articles     Next Articles

HTTP Chunked Stream Concurrence Analysis Based on State Machine

LI Mingzhe1,2,CHEN Jun1,WANG Jinlin1,CHEN Xiao1   

  1. 1.National Network New Media Engineering Research Center,Institute of Acoustics,Chinese Academy of
    Sciences,Beijing 100190,China;2.University of Chinese Academy of Sciences,Beijing 100190,China
  • Received:2013-11-01 Revised:2013-12-22 Online:2015-01-15 Published:2015-01-16

基于状态机的HTTP Chunked流并发解析

李明哲1,2,陈君1,王劲林1,陈晓1   

  1. 1.中国科学院声学研究所国家网络新媒体工程技术研究中心,北京 100190; 2.中国科学院大学,北京 100190
  • 作者简介:李明哲(1988-),男,博士研究生,主研方向:流媒体技术,网络处理器应用;陈 君(通讯作者),副研究员、博士;王劲林,研究员、博士生导师;陈 晓,研究员。
  • 基金资助:
    国家“863”计划基金资助项目(2011AA01A102);中国科学院战略性先导科技专项课题基金资助项目(XDA06010302)

Abstract: In some streaming media applications,a server needs to parse HTTP Chunked encoding messages concurrently.The naive static parsing algorithm does not fit in the efficient event-driven concurrency paradigm,and incurs long delay and several memory copies,leads to high memory and computing overhead.To tackle this problem,a finite state machine based parsing algorithm is presented.One receiving and its following parsing operations are combined into a task slice so that the event-driven model can be applied.Data packets are parsed immediately without caching the whole HTTP message,and therefore one memory copy is reduced.Parsing status is saved into state machines to that the context can be restored after the task slice is over,which solves the broken-field problem.Test results show that this method can significantly reduce memory and computation overhead compared with static parsing.

Key words: streaming media, HTTP Chunked encoding, concurrence analysis, event-driven model, finite state machine, memory copy

摘要: 某些流媒体服务器需要对HTTP Chunked编码数据流进行并发解析,朴素静态解析算法难以应用于高效灵活的事件驱动并发模型,且会造成长延迟和多次数据拷贝,导致内存和计算资源开销都较高。针对上述问题,提出一种基于有限状态机的解析策略。将一次接收和一次解析操作构成一个任务片,从而适应事件驱动模型,对收到的数据包进行即时处理和释放,不需要缓存整个HTTP报文,减少一次内存拷贝开销。在数据处理过程中,通过有限状态机保存解析状态,能够在任务片退出后恢复之前的解析状态,从而解决事件驱动模型下的字段断裂问题。实验结果表明,相比于静态解析算法,该策略能够明显地降低解析过程的处理时间和占用的内存。

关键词: 流媒体, HTTP Chunked编码, 并发解析, 事件驱动模型, 有限状态机, 内存拷贝

CLC Number: