9、中英文翻译(雷绍崇)

更新时间:2023-04-30 20:15:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

郑州大学西亚斯国际学院

中英文翻译

课题题目超声波测距避障系统的设计与实现指导教师曹晓丽职称助教

学生姓名雷绍崇学号20111521124 专业电子信息工程班级一班

院(系)电子信息工程学院

完成时间2015年4月3号

I

LyraNET: A Zero-Copy TCP/IP Protocol Stack for Embedded Operating Systems

Abstract

Embedded systems are usually resource limited in terms of processing power, memory, and power consumption, thus embedded TCP/IP should be designed to make the best use of limited resources. Applying zero-copy mechanism can reduce memory usage and CPU processing time for data transmission. Power consumption can be reduced as well.

In this paper, we present the design and implementation of zero-copy mechanism in the target embedded TCP/IP component, LyraNET, which is derived from Linux TCP/IP codes and remodeled as a reusable software component that is independent from operating systems and hardware. Performance evaluation shows that TCP/IP protocol processing overhead can be significantly decreased by 23-56.22%. Besides, object code size of this network component is only 78% of the size of the original Linux TCP/IP stack. The experience of this study can serve as the reference for embedding Linux TCP/IP stack into a target system and improving the transmission efficiency of Linux TCP/IP by zero-copy implementation.

1. Introduction

As the explosion of Internet, adding Internet connectivity is required for embedded systems [5]. TCP/IP protocol is the core technology for this connectivity. In order to suit for resource-limited embedded devices, some commercial products implemented TCP/IP protocol stack from scratch for embedded systems with the aims to reduce code size and CPU processing overhead. Their codes are not freely obtainable. Since Linux provides open source codes, besides, it is popular and has the advantages of stability, reliability, high performance, and well documentation, these advantages let making use of the existing open source codes and integrating Linux TCP/IP protocol stack [6] into a target operating system bec However, because Linux is a monolithic kernel,

2

Linux TCP/IP stack is not a separate component that has closely relationship and interaction with other Linux kernel functions such as file system, device driver, and kernel core. This adds the difficulties in reusing the Linux TCP/IP stack in a target system.

Besides, straight porting of the Linux TCP/IP protocol stack into a target operating system is also not the best implementation for the particular needs of an embedded system. Especially, embedded systems are usually resource limited in terms of processing power, memory, and power consumption. For example, data transmission of Linux TCP/IP protocol codes are suitable for general-purpose operating systems in the common resource-abundant desktop computers. Transmitted data is always copied from user buffer to kernel buffer, then sent from kernel buffer to network interface card (NIC). Received data is brought from NIC to kernel network buffer, then copied from kernel network buffer to user buffer. These data copy operations need CPU processing time and add to power consumption. Therefore, TCP/IP implementation for embedded systems should minimize the amount of data copying in order to reduce power consumption and provide efficient response.

Zero-copy [2] is a mechanism in which data from network card is directly received in the user buffer and data from user buffer is directly sent to network card. No data copying between user buffers and kernel buffers is needed. Zero-copy implementation requires virtual memory operations such as page remapping and hardware supported devices such as DMA controller. Data consistency of TCP/IP transmission must be ensured as well. Besides, because virtual memory operations and DMA are needed to implement zero-copy, memory buffers that are used to receive or send data via network must be constrained. For devices do not support DMA operations, data copying from/to network card to/from user buffers is still need.

For reusing Linux TCP/IP codes, we have extracted TCP/IP protocol stack from Linux in our previous study [4]. It is then implemented as a software ome a cost-effective way. component that is independent from operating systems and hardware, called LyraNET. Based on the component design principle [1], the advantages of modularity, reconfigurability, component replacement and reuse can be obtained. To implement the TCP/IP stack as a self-contained component requires modifying Linux TCP/IP codes to separate them from other kernel functions and implementing kernel support modules in the target operating

3

system for integrating Linux TCP/IP protocols.

For adapting LyraNET into embedded systems, in order to reduce protocol processing overhead, memory usage, and power consumption, in this paper, we focus on applying zero-copy mechanism to reduce the data copying operations in TCP/IP transmission by passing the address of user data buffer when sending data to network, and by page remapping when receiving data from network. Besides, NIC drivers need modifications to incorporate zero-copy mechanism. After integrating LyraNET with copy elimination into LyraOS [3,8], a component-based embedded operating system, performance evaluation shows that TCP/IP protocol processing overhead can be decreased by 23 -56.22%.

2. LyraOS and LyraNET

LyraOS [3,8] is a component-based operating system which aims at serving as a research vehicle for operating systems and providing a set of well-designed and clear-interface system software components that are ready for Internet PC, hand-held PC, embedded systems, etc. It was implemented mostly in C++ and few assembly codes. It is designed to abstract the hardware resources of computer systems, such that low-level machine dependent layer is clear cut from higher-level system semantics. Thus, it can be easily ported to different hardware architectures [3].

Figure 1 shows LyraOS system architecture. Each system component is complete separate, self-contained, and highly modular. Besides being light-weight system software, it is a time-sharing multi-threaded microkernel. Threads can be dynamically created and deleted, and thread priorities can be dynamically changed. It provides a preemptive prioritized scheduling and supports various mechanisms for passing signals, semaphores, and messages between threads. On top of the microkernel, a micro window component with Windows OS look and feel is provided. Besides, the LyraFILE component, a light-weight VFAT-based file system, supports both RAM-based and disk-based storages. Especially, LyraOS provides the Linux device driver emulation environment to make use of Linux device drivers.Under this environment, Linux device driver codes can be integrated into LyraOS without modification.

4

Figure 1. LyraOS system architecture

The LyraNET [4] component is a TCP/IP protocol stack derived from Linux TCP/IP codes [6]. We made the most use of Linux open source codes mainly to reduce our development effort. We then remodeled it as a reusable software component that is independent from operating systems and hardware. Our work mainly includes remodeling Linux TCP/IP stack to separate it from file systems, implementing wrappers for kernel and device independence, and providing wrapper for compatible socket interfaces.

3. Performance evaluation

This section presents the performance evaluation of LyraNET with Copy Elimination after being integrated into LyraOS. we use to simulate an embedded system, in which two computers are connected in a private network to avoid the affection of external network traffic. The ttcp [7] benchmark is used and the processing times for protocol processing and network driver operations are measured.

3.1. Comparison of object code size

Table 2 shows that the object code size of LyraNET with Copy Elimination is 78% of the size of Linux TCP/IP Stack. Adding Copy Elimination mechanism in LyraNET only increases 1.1-1.7% of object code size.

5

6

We send data with the size several times of 1460 bytes. Figure 5 shows that protocol performance improvement is from 5 1.34-56.22% when Copy Elimination is applied in LyraNET. When DMA NIC is used, though driver processing time of Copy Elimination is increased, total processing time is

still decreased by 27.7-50%. This concludes that Copy Elimination is beneficial when data

copying dominates the total processing time. When PIO NIC is used, the driver processing time becomes an extremely large portion of total processing time due to the characteristic of PIO. Total processing time of Copy Elimination is still decreased slightly because protocol processing time is decreased.

(a) Sending data by DMA NIC

(b) Sending data by PIO NIC

Figure 2. Processing time for sending data

3.3. Performance of receiving data

We measure three parts of processing time: NIC driver operation (i.e. ei_interrupt() or boomerang_interrupt()), main protocol codes of receiving data (i.e. from net_bh() to tcp_rcv()), and the codes of system call processing (i.e. from sys_recv() to tcp_recvmsg()). In Linux source codes, incoming packets from

NIC are received in NIC interrupt service routine (ISR), then this ISR marks NET_BH to activate bottom half handling, i.e. net_bh(). Most of the receiving protocol processing is completed in the control flow from net_bh()to tcp_rcv(). Then tcp_rcv()

(a) Receiving data by DMA NIC

(b) Receiving data by PIO NIC

Figure3. Processing time for receiving data

Figure 3(a) shows the processing time when system receives data by DMA NIC. The ttcp is setup to send 1460-byte data 102,400 times to LyraNET. The results show that the processing time of data copying (i.e from sys_recv() to tcp_recvmsg()) in origin TCP/IP stack is the largest part of total processing time. With Copy Elimination, the processing time of data copying is decreased greatly. Though boomerang_interrupt()is not modified in Copy Elimination, however, page remapping would incur TLB flushing, which in turn would degrade performance of DMA driver. In protocol processing part, the difference of the processing time from netbh() to tcp_rcv() in LyraNET with and without Copy

7

Elimination is insignificant.

Figure 3(b) shows the processing time when system receives data by PIO NIC. The ttcp is setup to send 1460-byte data 8192 times to LyraNET. The results show that receiving data from NIC is the main bottleneck. Without support of fast device such as DMA controller, PIO NIC relies on CPU to receive data to host memory. Though we greatly reduce the processing time of data copying in Copy Elimination, however, driver processing dominates the total processing time, which causes performance improvement insignificant.

4.Conclusions

We have reused and remodeled Linux TCP/IP stack to be a software component called LyraNET that is independent from operating systems and hardware. For the adaptation into resource-limited environments, we develop Copy Elimination in LyraNET to reduce protocol processing overhead and reduce memory usage. Performance evaluation shows that protocol processing time can be reduced by 5 1.34-56.22% in sending data and by 23-46% in receiving data. Adding Copy Elimination mechanism only increases 1.1-1.7% of object code size. To sum up, the success and the experience of our work can serve as the reference for embedded Linux TCP/IP stack into a target system requiring network connectivity. Besides, our zero copy implementation can also help the work of enhancing the transmission efficiency of Linux TCP/IP stack.

5.References

[1]J. Bruno, J. Brustoloni, E. Grabber, A. Silberschatz, and C. Small, “Pebble: A

Component Based Operating System for Embedded Applications”, I n

Proceedings of 3rd Symposium on Operating Systems Design and Implementation, USENIX, February 1999.

[2]J. C. Brustoloni and P. Steenkiste, “Effects of Buffering Semantics on I/O

Performance”, Proceedings of 2nd Symposium on Operating Systems Design and Implementation, pages 277–291, USENIX, Oct. 1996.

[3]Z. Y. Cheng, M. L. Chiang, and R. C. Chang, “A component based operating

system for resource limited embedded devices”, IEEE International

Symposium on Consumer Electronics, HongKong, Dec. 5-7, 2000.

[4]J. W. Chuang, K. S. Sew, M. L. Chiang, and R. C. Chang, “Integration of Linux

Communication Stacks into Embedded Operating Systems”, International

Computer Symposium, December 6-8, 2000.

8

9 [5]

T.Herbert,“EmbeddingTCP/IP”99fbf7daa21614791611288b/2000/0001/0001ia1.htm. [6]

S. T. Satchell and H. B. J. Clifford, Linux IP Stacks Commentary , Coriolis Group Books, 2000. [7]

ttcp, 99fbf7daa21614791611288b/projects/itl/HOWTOS/PCATTCP-j nm-20011113.htm . [8] C. W. Yang, C. H. Lee, and R. C. Chang, “Lyra: A System Framework in

Supporting Multimedia Applications”, IEEE International Conference on Multimedia Computing and Systems'99, Florence, Italy, June 1999.

[9]

J. Bruno, J. Brustoloni, E. Grabber, A. Silberschatz, and C. Small, “Pebble: A Comp onent Based Operating System for Embedded Applications”, In Proceedings of 3r d Symposium on Operating Systems Design and Implementation, USENIX, Februa ry 1999. [10] J. C. Brustoloni and P . Steenkiste, “Effects of Buffering Semantics on I/O Performa

nce”, Proceedings of 2nd Symposium on Operating Systems Design and Impleme ntation, pages 277–291, USENIX, Oct. 1996.

[11] Z. Y. Cheng, M. L. Chiang, and R. C. Chang, “A component based operating system

for resource limited embedded devices”, IEEE International Symposium on Cons umer Electronics, HongKong, Dec. 5-7, 2000

[12] J. W. Chuang, K. S. Sew, M. L. Chiang, and R. C. Chang, “Integration of Linux Com

munication Stacks into Embedded Operating Sys tems”, International Computer S ymposium, December 6-8, 2000.

[13]

[14] S. T. Satchell and H. B. J. Clifford, Linux IP Stacks Commentary, Coriolis Group Book

s, 2000. [15][16] C. W. Yang, C. H. Lee, and R. C. Chang, “Lyra: A System Framework in Supporting

Multimedia Applications ”, IEEE International Conference on Multimedia Computi ng and Systems'99, Florence, Italy, June 1999.

lyranet :嵌入式操作系统系统的一种零拷贝

TCP / IP协议栈

摘要在嵌入式系统中处理能力,内存,以及功率消耗这些资源总是有限,因此,嵌入式TCP / IP应设计成充分利用有限的资源。申请零拷贝机制,可以减少内存的使用以及CPU传输数据的处理时间,功率消耗也可减少。在本文中,我们提出零拷贝机制的设计和实施方案的目标是嵌入式TCP / IP的组成部分lyranet (来自Linux的TCP / IP的代码并被改造成一个可重用的软件)从操作系统和硬件中独立出来。性能评价表明, TCP / IP协议的处理开资可明显降低23-56.22 %。此外,这个网络组件的对象代码的大小只有原始的Linux的TCP / IP协议栈的78 %。这项研究的经验,可以作为嵌入Linux的TCP / IP协议栈成为一个指标体系的参考,并且提高零拷贝Linux TCP / IP协议传输效率。

1.导言

由于互联网的爆炸,嵌入式系统要求加入互联网。 TCP / IP协议是这个连接的核心技术。在为了适应有限的资源的嵌入式设备,一些商业产品实施TCP / IP协议栈以减少代码大小和CPU处理开销为目标的嵌入式系统。他们的代码不是自由索取。自从Linux开放源代码,此外,它很普遍的还具有稳定性,可靠性,高性能,以及很好的文件,这些优势让利用现有的开放的源代码和整合的Linux TCP / IP协议栈[ 6 ]变成一个目标作业系统成为一个符合成本效益的方法。

不过,由于Linux是一块铁板内核, Linux的TCP / IP协议栈不是一个单独的组件它和其他Linux内核的功能,如档案系统,装置驱动程序和内核的核心有着密切的关系并且相互作用。这增加在指标体系中重用Linux的TCP / IP协议栈的困难。

此外,对于嵌入式系统的特别需要,直接移植Linux的TCP / IP 协议栈成为一个目标操作系统也不是最好的执行情况。特别是,在嵌入式系统中处理能力,内存,以及功率消耗这些资源总是有限。举例来说,Linux TCP / IP协议代码

10

的数据传输适合一般用途、共同资源丰富的台式电脑的操作系统。传输数据总是从用户缓冲区复制到内核缓冲区,然后从内核缓冲区发送到网络接口卡( NIC )。收到的数据从NIC带到内核网的缓冲区,然后从内核网络缓冲区复制到用户缓冲区。这些数据复制操作需要CPU的处理时间也增加了开销。因此,对于嵌入式系统 TCP / IP协议的执行,应尽量减少数据量复制,以减少能量消耗和提供高回应的效率。

零拷贝[ 2 ]是一个网卡中的数据直接接收到用户缓冲区而用户缓冲区的数据直接发送到网卡的机制。在用户缓冲器和内核缓冲区之间没有数据需要被复制。零拷贝的执行需要虚拟内存的操作,如页面重映和硬件设备支持,如DMA控制器。必须保证TCP / IP数据传输的一致性。此外,由于虚拟内存操作和DMA需要实施零拷贝,通过网络接收或发送数据的内存缓冲器须受到限制。因为设备不支持DMA操作,从网卡到用户的缓冲区或从用户的缓冲到网卡的数据复制仍是需要的。因为重用Linux的TCP / IP代码,我们已我们以前的的研究中提取

TCP / IP协议栈。这是当时作为一个独立于作业系统和硬件的软件组件所实施的,叫做lyranet 。在组件的设计原则的基础上,[ 1 ] ,可以得到模块化,可重构,构件更换和再利用的优势。作为一个自成一体的组成部分来实施的TCP / IP 协议栈,需要修改Linux的TCP / IP的代码,将它们从其他核心职能和整合Linux的TCP / IP协议目标操作系统的执行内核支持模块分开。

为了使lyranet适应嵌入式系统,要求减少协议处理开销,内存使用,功率消耗。在本文中,我们的重点提出零拷贝机制,当将数据发送到网络时通过传送用户数据缓冲区的地址,和从网络中接收数据时逐页重,来减少TCP / IP传输的数据复制操作。此外, NIC的操作者需要修改融入零拷贝机制。在用消除复制到lyraos (基于组件的嵌入式操作系统)整合lyranet后,性能评价表明TCP / IP协议处理开销可降低23-56.22 %。

2.lyraos和lyranet

lyraos是一个基于组件的操作系统,它的目的是作为一个研究工具操作系统服务,并提供了一套为互联网的个人电脑,手提式电脑,嵌入式系统等精心设计的明确界面的系统软件组件。它主要是在C + +和少数集中代码中实施。它设计来概括电脑系统的硬件资源,如低层次机的依赖层明显是从高层次机系统的语义剪

11

切的。因此,它可以很容易地移植到不同的硬件体系结构[ 3 ] 。如图1所示lyraos系统的体系结构。每个系统组件是完全独立的,自我控制,和高度模块化的。它除了是一个重量轻的系统软件,还是一个时间共享多线程微内核。线程可以被动态地创建和删除,线程的优先次序可以被动态改变。它提供了一个有先买权的优先时间安排并支持信号,信号量,和信息之间的线程的各种机制。再加上提供微内核(有着Windows操作系统的外观和感觉微型窗口)。此外, lyrafile 组件(一个重量轻,基于vfat文件系统)既支持基于RAM也支持基于磁盘的货仓。特别是, lyraos提供Linux设备驱动仿真环境来使用Linux的设备驱动程序。在这种环境下, Linux设备驱动代码可以未作修改的融入lyraos。

图1 lyranet操作系统结构

该lyranet [ 4 ]组件是一个来自Linux的TCP / IP代码的 [6]TCP / IP协议栈。我们充分的使用Linux开放的源代码,主要是为减少我们发展的难度。然后,我们把它作为一个可重用的,独立于操作系统和硬的件软件组件来改造它。我们的工作主要包括:重塑Linux的TCP / IP协议栈,把它从档案系统分裂出来,实施对内核和设备的包装独立开来,并提供兼容插座接口的包装。

3.性能评价

本节介绍安装了lyra操作系统的应用复制消去技术的lyranet的性能评价。表1给出了我们的实验平台,我们使用模拟的嵌入式系统,在其中的两台电脑连接在一个专用网络,以避免影响外部网络的通信。应用ttcp [ 7 ]基准,并且协议处理和网络驱动器运行的处理时间是有限制的。

3.1 比较对象的代码大小

从表2可以看出,应用复制消除技术的lyranet的基础代码的规模是Linux的TCP /

12

13 IP 协议栈的78 %。加入复制消除机制之后,只增加lyranet1.1到1.7%的目标代码。

Table 2. Code size comparison

3.2发送数据性能

我们发送数据的大小为1460字节的整数倍。图5给出了lyranet 应用复制消除级之后,该协议的性能的改善

5 1.34-56.22 %。当应用DMA 的网卡时,虽然加入复制消除机制的驱动程序的处理时间增加,但是总处理时间仍是下跌27.7-50 % 。由于快速的DMA 控制器,驱动程序处理是高效的,不是总处理时间的主要部分时, DMA 的网卡是适用的。此得出结论认为,当数据复制占总处理时间的主要部分时,复制消除是有利的。当使用PIO 网卡时,由于PIO 的特性,驱动处理时间成为总处理时间非常大的部份 。因为协议的处理时间减少了,复制消除的总的处理时间仍是略有下降。

(a )由DMA 网卡发送数据

(b )由PIO 网卡发送数据

图2 发送数据处理时间

我们把处理时间分为三个部分:NIC的驱动程序的执行时间(例如ei_interrupt()或boomerang_interrupt() ),接收数据主要协议的代码,(例如from net_bh()tcp_rcv () ),和系统调用处理代码(例如from sys_recv() tcp_recvmsg() )。在Linux的源代码中,从网卡收到的传入的数据包在NIC 在中断服务程序中进行(ISR),那么ISR给net_bh做标记来激活底部的一半处理,例如net_bh()。大部分接受协议的处理是在从net_bh ()tcp_rcv()控制流中完成的。然后tcp_rcv()调用tcp_data()唤醒数据的线程等待。

(a) 由DMA网卡接收数据

(b) 由PIO网卡接收数据

图2 接收数据处理时间

图6(a)显示,当系统由DMA的网卡接收数据的处理时间。该ttcp是被设定来发送

1460字节的数据102400次到lyranet 。结果表明,在原始TCP / IP协议栈复制数

据的时间是总处理时间最大的一部分。(即从sys_recv ()tcp_recvmsg ())。应

用了复制消除,数据复制的处理时间是大大降低了。虽然boomerang_interrupt ()

在复制消除中不会修改,不过,网页重映会导致TLB的浪费,这反过来会改善DMA

驱动程序的性能。在协议处理部分,在有无复制消除机制的lyranet从netbh

()tcp_rcv()的处理时间的不同是微不足道的。

14

图6(b)表明,系统由PIO的NIC接收数据的处理的时间。该ttcp是安装来发送1460字节的数据8192次到 lyranet 。结果表明,从NIC接收数据是主要瓶颈。没有快速设备的支持,如DMA控制器,网卡的PIO依赖于CPU通过主存接收数据。虽然我们应用复制消除大大降低了数据复制处理时间,但是,驱动处理占大部分总处理时间,从而导致性能的改善微不足道。

4 .结论

我们已经重载和改造Linux的TCP / IP协议栈为一个软件组件,称为lyranet,这是独立于操作系统和硬件的。为适应纳入资源有限的环境下,我们在lyranet中发展的复制消除,以减少协议处理时间的开销和减少内存的开销。性能评价表明,协议的处理时间在发送数据时可减少5 1.34-56.22 %和在接收数据时23-46 %。加入复制消除机制,仅仅增加了1.1-1.7%的目标代码的大小。总之,成功的经验和我们的工作可以作为嵌入式Linux TCP / IP协议栈成为一个指标体系要求的网络连接的参考。此外,我们的零复制的执行情况还可以帮助工作,提高Linux TCP / IP协议栈传输效率。

15

本文来源:https://www.bwwdw.com/article/xpce.html

Top