Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
The Design and Implementation of Network Data Link Layer Based on Embedded
TCP/IP Protocol Stack
YanHongwei PanHongxia
College of Mechanical Engineering & Automatization, College of Mechanical Engineering & Automatization,
North University of China North University of China
Taiyuan, China Taiyuan, China
e-mail: yaweigeh@sohu.com e-mail: panhxlOI5@163.com
Abstract-With the development of computer technology, TCP/IP protocol used for embedded system networking is
embedded TCPIIP protocol stack has become an important called embedded TCPIIP protocol. Embedded TCP/IP
part of the network information intelligence. Considering the protocol is different from the conventional TCPIIP, it has
structure features of the embedded TCPIIP protocol stack, this portability, configurable and can be cut, the main
paper discusses the specific implementation procedure of the characteristic is a real-time, simplicity and flexibility.
protocol stack network interface layer. The datagram module
The link layer of the TCPIIP protocol stack, Network
of RTL8019AS controller and the Ethernet data sending
Interface Layer, is refered to the Ethernet physics interface
module are designed to achieve the network communication. It
and the Ethernet interface. The link layer is to drive the
is shown that the system design was accomplished and it can be
Ethernet interface circuit, programming network card driver
introduced to the practical usage in the real life.
and Ethernet interface according to interface circuit, so as to
realize the system connectes network[4][9][10][1l][16].
Keywords-TCPIIP Protocol Stack; Embedded Systems;
Ethernet; Network Interface Layer; ARP What network interface layer realizes is system and ethernet
network, structure of system network interface layer is
shown in figure 1
I. INTRODUCTION
CB
TCPIIP is a set of protocol used for computer EMBEDDED
communication, usually called TCPIIP protocol family, it is RAM
PROCESSOR
network architecture and the protocol standard developed by
United States Department of Defense for the Arpanet wan in
mid 1970s, Internet based on it is the largest international
computer network currently. Because of the extensive use of
the Internet, TCPIIP became the defacto standard. It RTL8019AS
represents a protocol stack,which is composed of a series of
small and special protocol, including IP, TCP and UDP,
ICMP(lnternet control message protocol), FTP(file transfer
protocol), SMTP (simple mail transfer protocol), an ARP
(Address Resoloution Protocol) and many other protocol,
referred to as the TCPIIP protocol. From the ayering model
of protocols, TCP/IP composed by four levels, the four
layers is the network interface layer, network layer, the
transport layer and network. The OSI reference model, Open Figure 1. Schematic Diagram of the Network Interface Layer
Systems Interconnection is the network architecture open
system interconnection reference model presented by ISO in
1981. The OSI network is divided into seven levels, namely: II. REALIZE NETWORK CONTROLLER DRIVER BASED ON
the physical layer, data link layer and network layer, the THE BOTTOM LAYER DRIVING
transport layer, session layer, presentation layer, application To realize the network interface layer, at first to realize
layer[I][2]. network controller RTL8019AS bottom driving, then prepare
In order to adapt to the application of the embedded the driver. As the physical foundation of achieving TCPIIP
system online demand, embedded system facing the 21st protocol stack, RTL8019AS driver mainly completed work
century requires to allocate standard one or more network includes: Nic initialization, sending and receiving data
communication interface[3].Embedded equipment for upper message.
network protocol stack usually choose to use the TCPIIP
protocol, through the TCP/IP protocol it can make internal A. RTL8019AS Initialization Program Design
network or networks communicate and exchange of In RTL8019AS initialization procedures, completing the
information with the Internet and worldwide networking,the resetting of network card , setting all the internal register of
RTL8019AS and the physical address of Ethernet,Specific as Design program that make RTL8019AS sends data to the
follows: Ethernet, as Ethernet bottom driver, all the data sent should
Before the initialization function setting internal get through the program. First calculate total length of
register, first reset RTL8019AS, Reset pin RSTDRV packets sent, then send the data to send buffer, and set the
is high level effective. To make chips reset, length of starting address of the chip (i.e. starting address of send
time of high level should be more than 800ns, buffer). If data is less than 60 bytes, need to fill 60 bytes with
usually 100ms after RSTDRV from high level to low padding bit, then start sending. If failure to send, send
level,then read-write RTL8019AS, to ensure the again ,the number of times of sending defind for six times.
completely reset. The design code is in the critical areas of operating system
Setting all internal working registers of RTL8019AS. task , the process is shown in figure 2.
By the Ethernet interface circuit we can know
C. The Design Program Module of Receiving Datagram
ethercard map in the Bank3 of system, so the
addresses starte from Ox83400000 , the program are The function of received processing program is to
defined as follows: process packets received and is direct called by receive tasks.
#define RTL8019AS_Base Ox83400000 II Bank3 Before writing receiving and processing process ,defind the
Offset relatived to it being 00 is register CR, assign circular chain of receive buffer, and determine the length of
to CR to make RTL8019AS Stop mode, delay !Oms the chain according to the length of maximum frame of data
ensure chips get into stop mode. Select page 0,
clean RBCRO,RBCRI . Assign to registers RCR,
make Ethernet controller get into monitoring
mode,stop receive packets, Assign to registers TCR,
make Ethernet get ino loop back mode. Choose page
1, the current page registers CURR=Ox4D; Clear
Multicast addresses register MARO-MAR7. Write
Ox22 to registers CR, chip began to work. Then
obtain the physical address of the Ethernet, and
writte it to MAR registers[5][6].
Obtaining physical address of ethernet. Storage
physical address of network card in OxOOOO-Ox001F
RAM of RTL8019AS , program read the data to
MAR register. After obtaining n physical address of
network, setting chip into normal mode, connect
with external network. Write Ox22 to CR registers,
start chip began to work, ISR = OxFF, remove all
interrupt the flag. Ethernet controller RTL8019AS
initialization completes.
228
2010 International Conference on Networking and Information Technology
whether receiving data, if not, then exit, If the check to B. The Design Program Module ofSending Datagram
receive data, then check whether the it is correct data and the
According to data information and target address of
length is too long, etc. If all operations are correct, then read
pointing to a layer protocol,Ethernet layer sending module
and do the corresponding processing. After treatment, check
judge relationship betwing the destination address and local
again until the data report without receiving. If the check and
address, determine whether belong to the same subnet. If
length of data is error, empty receive buffer of network
not, set the target MAC addresses as the default gateway
interface chip RTL8019AS, then exit operation. Due to the
MAC address, Otherwise, in an ARP list inquires whether
use of Ethernet communication system, call Ethernet layer
receiving program in program, thus Ethernet obtaine data there is corresponding MAC address. If checked, writte the
[6][12][13][14][20].The program flow is shown in figure 3. target MAC address to ethernet layer send buffer zone, Then
according to the parameter of PROTOCOL set agreement
III. DESIGN ETHERNET INTERFACE LAYER PROGRAM fields of ethernet layer, finally called the send data program
The realization of the Ethernet interface is to write the of driver to sends data. If not, then send address, Otherwise,
Ethernet interface, through the Ethernet interface program, inquires in an ARP list whether there is corresponding MAC
network controller RTL8019AS can obtaine from the address. If there is, then sending an ARP request frame ,
network and transmit data. Therefore, the Ethernet interface request the IP address corresponding the MAC address,
program is the agreement of connection hardware and return to send failure marks[15][17][19][21]. Program
software. Program the ethernet interface include flowchart as shown in figure 5.
programming receiving of ethernet layer data and
programming sending of ethernet layer data [7][8][11].
NO
229
2010 International Conference on Networking and Information Technology
the network communication and the upper layer protocol. It [14] WuXiaorong, "Internet technology in embedded system," the
realization of computer engineering, 2004, pp.I-4.
also played a role on connecting the protocol stack layers.
The presented work provided a promising basis for further [IS] Thomas F, "An introduction to TCPIIP for Embedded Engineers,"
Embedded System Conference, San Francisco 2002, pp.126-370.
improving the efficiency and shortening the design cycles.
[16] GeYongming and LinJiBao; "Ethernet interface design of embedded
system,"Electronic technology applications, Mar.2002, pp.2S-27.
ACKNOWLEDGMENT
[17] Jean J.L abrosse, "Embedded real-time operating system of IlC/OS- II
The work described in this paper has been supported by maximum tire-road friction coefficient beibei model," Beijing
National Natural Science Foundation of China under the aviation aerospace big university press, 2003,pp.I-S.
grant No.50575214. The authors would like to express their [IS] LiZheYing, "ARM kernel embedded system developing platform,"
gratitude for the support of this study. semiconductor technology; ADS In Vo1.2, pp.12-14, Feb.2002.
230