Preparation of Papers in 2-Column Format
Total Page:16
File Type:pdf, Size:1020Kb
INTEGRATION OF LINUX COMMUNICATION STACKS INTO EMBEDDED OPERATING SYSTEMS Jer-Wei Chuangξ, Kim-Seng Sewξ, Mei-Ling Chiang+, and Ruei-Chuan Changξ Department of Information Management+ National Chi-Nan University, Puli, Taiwan, R.O.C. Email: [email protected] Department of Computer and Information Scienceξ National Chiao-Tung University, Hsinchu, Taiwan, R.O.C. Email: [email protected], [email protected] Thus, various operating systems design dedicated for embedded systems are thus created, such as PalmOS ABSTRACT [22], EPOC [12], Windows CE [25], GEOS [16], As the explosion of Internet, Internet connectivity is QNX [23], Pebble [2,17], MicroC/OS [21], eCos [11], required for versatile computing systems. TCP/IP LyraOS [3-7,18,19,26], etc. protocol is the core technology for this connectivity. As the explosion of Internet, adding Internet However, to implement TCP/IP protocol stacks for a connectivity is required for embedded systems. target operating system from the scratch is a TCP/IP protocol [8,9,24] is the core technology for time-consuming and error-prone task. Because of the this connectivity. However, to implement the TCP/IP spirit of GNU GPL and open source codes, Linux protocol stacks for a target operating system from the gains its popularity and has the advantages of stability, scratch is a time-consuming and error-prone task. reliability, high performance, and well documentation. Because of the spirit of GNU General Public License These advantages let making use of the existing open (GPL) [15] and open source codes, Linux [1] gains its source codes and integrating Linux TCP/IP protocol popularity and has the advantages of stability, reli- stacks into a target operating system become a ability, high performance, and well documentation. feasible and cost-effective way. These advantages let making use of the existing open In this paper, we describe how to integrate Linux source codes and integrating Linux TCP/IP protocol communication stacks into LyraOS, a compo- stacks into a target operating system become a feasi- nent-based operating system for embedded systems. ble and cost-effective way. Under the component design principle, the commu- This paper describes how to integrate Linux nication stack should also be implemented as a sepa- communication stacks into LyraOS [3-7,18,19,26]. rate and self-contained component. So the integration LyraOS is a component-based operating system de- work should deal with the difference of system design signed for embedded systems. Under the component principles and kernel architectures. This work in- design principle [2,14,17,20], the communication cludes modifying Linux communication stack codes stack should also be implemented as a separate com- and implementing LyraOS kernel support modules. ponent, such that the advantages of modularity, re- Performance evaluation shows that for TCP transmis- configurability, component replacement and reuse can sion, LyraOS performed better than Linux by 7.39%. be maintained. However, there are many difficulties The experience of this integration study can be of to deal with for this integration work. For example, practical value to serve as the reference for embed- being a monolithic kernel, Linux communication ding TCP/IP stacks into a target system. stack is not a separate component that has closely re- lationship and interaction with other kernel functions 1. INTRODUCTION such as file system, device driver, and kernel core. Embedded applications are versatile and the hardware Therefore, the integration work should solve the devices range from simple controllers to more difficulties from different system design principles complex systems. For the versatile hardware devices and different kernel architectures. Our work focuses and different application requirements, a on two parts. First, implementing the communication reconfigurable embedded operating system is needed. stacks as a self-contained component, which requires 1 modifying the Linux TCP/IP codes to separate them different socket address families [1], so the main task from other kernel functions. Second, implementing of socket layer is to call the service functions of the kernel support modules in LyraOS for integrating requested address family (e.g. INET sockets). The Linux TCP/IP protocols. INET layer will call the service functions of underly- ing TCP or UDP layers, which in turn will call the The rest of this paper is organized as follows. service functions of IP layer. The IP layer deals with Section 2 briefly describes the difference between the packets sent/received to/from network interfaces. LyraOS and Linux, which affects the integration work. The difficulties that should be dealt with for this inte- gration are also discussed and presented. Section 3 presents the integration work including modifying Linux communication codes and adding kernel sup- Network port modules. Section 4 shows primitive performance Applications User evaluation results, and Section 5 concludes this paper. Kernel BSD Socket Sockets Interface 2. INTEGRATION ISSUES UNIX, AX25, INET IPX, APPLETALK, In this section, we first briefly describe the Linux Sockets X25 ... communication stack architecture and the LyraOS Protocol TCP UDP architecture. Then the difficulties and problems Layers encountered in the integration work are discussed and IP presented. ARP Network Devices Ethernet 2.1 Linux Communication Stack Architecture The basic Linux I/O system architecture is illustrated Figure 2: The Layer Architecture of Linux Network in Figure 1, which includes network subsystem and Subsystem. file system. The network subsystem includes socket layer, network protocol layer, and network device layer, as shown in Figure 2. int socket(int domain, int type, int protocol); int bind(int sockfd, struct sockaddr *my_addr, int addrlen); System Call Interface int listen(int s, int backlog); int connect(int sockfd, struct sockaddr *serv_addr, int addrlen ); Socket int accept(int s, struct sockaddr *addr, int *addrlen); int send(int s, void *msg, int len, unsigned int flags); File Systems Network Protocol int sendto(int s,void *msg,int len,unsigned int flags, struct sockaddr *to, int tolen); int sendmsg(int s, struct msghdr *msg, unsigned int flags); Network Device Driver int recv(int s, void *buf, int len, unsigned int flags); int recvfrom(int s,void *buf,int len,unsigned int flags, Hardware struct sockaddr *from,int *fromlen); int recvmsg(int s, struct msghdr *msg, unsigned int flags); int getsockopt(int s, int level, int optname, void *optval, int *optlen); Figure 1: Linux I/O System Architecture. int setsockopt(int s, int level, int optname, void *optval, int optlen); Table 1: The Related C Library Functions. Programmers make use of the socket interfaces to access network services. The invocation is made through system call interface in C library to enter into kernel’s socket layer. The exported C library func- Linux network subsystem shares some data tions are listed in Table 1. Since Linux supports many structures and operations with file systems, which adds the difficulties in the integration work for im- 2 plementing the network system as a separate compo- ChaiVM Embedded Browser /Desktop nent. As shown in Figure 3, when BSD sockets are used, kernel will create inode (consists of socket) and Lyra Framework - POSIX 1003.4 subset API sock data structures and then make the corresponding Multimedia Supports links in the invoking process’s file descriptor table API and open file table [1]. File System TCP/UDP Kernel Core IP files_struct Components count close_on_exec open_fs BSD Socket Device Driver File Operations fd[0] file fd[1] f_mode lseek f_pos read Hardware Abstraction Layer write f_flags select f_count ioctl f_owner close Hardware (ARM / AMD Elan SC400 / PC) fd[255] inode fasync f_op File Description f_inode Table f_version socket Open File Table Figure 4: LyraOS System Architecture. type SOCK_STREAM ops Address Family data socket operations sock type SOCK_STREAM protocol 2.3 Integration Issues and Difficulties socket Since LyraOS and Linux are different in system architecture, Linux communication stacks must be modified for being integrated into LyraOS. LyraOS Figure 3: Linux BSD Socket Data Structures. should also provide some kernel support functions for this integration. Currently, LyraOS supports single address space [4,10] with static binding of applications and kernel. 2.2 LyraOS No system call invocation is needed for applications LyraOS [3-7,18,19,26] is a component-based to use the kernel’s exported services. To provide the operating system which aims at serving as a research compatible system call interface with Linux, LyraOS vehicle for operating system and providing a set of should provide the same socket interfaces for applica- well-designed and clear-interface system software tions’ use as Linux C library functions listed in Table components that are ready for Internet PC, hand-held 1. PC, embedded systems, etc. Aside from the different OS architecture, under It was implemented most in C++ and some as- the component design principle, each LyraOS system sembly codes. It is designed to abstract the hardware component is complete separate, self-contained, and resources of computer systems, so low-level machine highly modular. Each component has clean exported dependent layer is clear cut from higher-level system and imported interfaces for components to communi- semantics. Therefore, it can be easily ported to dif- cate with. So, the communication stack should also be ferent hardware architectures