Implementation of PPPoE under the VxWorks Embedded Operating System
2026-04-06 07:21:09··#1
Abstract : PPPoE is a commonly used dial-up protocol. This paper introduces the basic process and frame encapsulation format of the PPPoE Discovery phase, and also describes the relationship between the various protocol sublayers of PPP (Connection Control Protocol (LCP), Authentication Protocol (CHAP, PAP), and IP Control Protocol I (PCP), as well as the PPP data packet encapsulation format. The paper discusses the specific positions of PPPoE and PPP protocols within the TCP/IP protocol stack of the embedded operating system VxWorks, and the processing flow of PPP and PPPoE data packet transmission and reception. It also presents the specific software module design for PPPoE implementation under VxWorks, which has certain engineering application value. Keywords : PPPoE; PPP; VxWorks; Embedded Operating System 1 Introduction In the current communications market, broadband is gradually gaining popularity, and access methods are becoming increasingly diverse: LAN, ADSL, HFC Cable Modem, and WLAN each have a certain market share. ADSL is the mainstream broadband access method globally, providing bandwidth ranging from a minimum of 512 kHz to a maximum of 8 MHz. Users can enjoy dedicated bandwidth without experiencing a decrease in internet speed due to an increase in the number of users. More importantly, ADSL is inexpensive and affordable for ordinary consumers. Currently, major domestic operators and broadband access providers are vigorously carrying out a broadband revolution. China Telecom has launched "ADSL Network Express" and has already secured a large user base; China Netcom also has a similar market scale. On the other hand, VoIP voice services are also developing rapidly. Currently, most VoIP voice access terminals in China are LAN-based. The main user base is concentrated in smart communities, campuses, and internet cafes. Since most home users use ADSL broadband access, operators have to consider the demand for VoIP voice services from current ADSL users. Therefore, if the VoIP terminal device supports PP-PoE access, it can provide VoIP voice services simply by connecting the VoIP terminal device to an ADSL modem. The software of VoIP terminal devices is mostly based on embedded operating systems. VxWorks is an embedded real-time operating system launched by WRS (Wind River Systems Inc.). VxWorks holds a dominant position in the high-end communications market due to its unparalleled high efficiency, high reliability, efficient debugging tools, and stable, efficient network protocols. Most communication devices use VxWorks as their operating system. This article details the specific implementation of PPP and PPPoE protocols under VxWorks. 2. PPP and PPPoE Protocols IP access functions include dynamic IP address allocation, AAA, and dynamic ISP selection. Implementing these functions typically requires a well-known access protocol, PPP. PPP is a mature IP access protocol that supports multiple protocol encapsulations, is simple to implement, and easily integrates with existing ISPs. It has link layer and network layer configuration and negotiation functions, and can easily and automatically allocate TPs. PPP itself is also a data link layer protocol, which can use different transmission mechanisms. Commonly used ones include HDLC, ATM, and Ethernet. When carried over Ethernet, it is called PPPoE (PPP over Ethernet). 2.1 PPPoE Protocol RFC2516 defines a method for transmitting PPP over Ethernet, namely PPPoE. PPPoE consists of two phases: the Discovery phase and the PPP session phase. When a host wants to initiate a PPPoE session, it must first perform Discovery to determine the Ethernet MAC address of the other party and establish a PPPoE session identifier SESSION_ID. Although PPP defines an end-to-end peer-to-peer relationship, Discovery is inherently a client-server relationship. During Discovery, the host (as a client) discovers an Access Concentrator (as a server), and depending on the network topology, the host can communicate with more than one Access Concentrator. The Discovery phase allows the host to discover all Access Concentrators and select one from them. When the Discovery phase is successfully completed, both the host and the Access Concentrator have all the information needed to establish a point-to-point connection on Ethernet. (1) Frame format and types of PPPoE During the Discovery phase, the ETHER_TYPE field of all Ethernet frames is set to 0x8863. During the PPP session phase, the ETHER_TYPE field of Ethernet frames is set to 0x8864. The payload of PPPoE contains 0 or more TAGs. A TAG is a TLV (type-length-value) structure, and the TAG_TYPE field is a 16-bit value (network byte order). Appendix A of RFC2516 lists various TAG_TYPE and TAG_VALUE. The frame format of PPPoE is shown in Figure 1. There are 5 basic frames in the PPPoE discovery phase, namely PPPoE Active Discovery Initiation (PADI), PPPoE Active Discovery Offer (PADO), PPPoE Active Discovery Request (PADR), PPPoE Active Discovery Sessionconfirmation (PADS), and PPPoE Active Discovery Terminate (PADT). (2) PPPoE Workflow PPPoE includes two phases: the Discovery phase and the Session phase. The main steps of PPPoE Discovery are as follows: ● The host sends a PADO packet with its destination address as the broadcast address and session ID 0 (unassigned); ● When any access server receives a PADO packet and provides the required service, it sends back a PADO packet with session ID 0; ● The host may receive multiple PADO packets. Based on the service and the service it provides, it selects a server and sends a PADR packet to that server with its destination address as the server's unicast address. Session ID is 0 (unassigned); ● Upon receiving the PADR, the server generates a unique session ID and sends back a PADS packet to the host, preparing to initiate PPP. After the search phase is complete, the PPPoE host obtains a Session ID from the access server AC. After a successful search, the host and access server can establish an Ethernet PPP connection and enter the PPP session phase. 2.2 PPP Protocol (1) PPP Protocol Composition The PPP protocol is defined by IETF RFCI661 and mainly consists of four parts: ● Frame encapsulation method; ● Link Control Protocol (LCP), which completes the functions of line startup, testing, negotiation of optional parameters, and final line disconnection; ● Network Control Protocol (NCP), the most commonly used NCP protocol is IP Control Protocol (IPCP). One of its important functions is to dynamically allocate IP addresses; ● User authentication, which is mainly determined by LCP negotiation on which authentication protocol to use, but the authentication protocol itself is not within the scope of the PPP protocol. PPP can be divided into three phases: LCP negotiation, authentication, and NCP negotiation. From a protocol perspective, it can be divided into three sub-layers, each of which can send "Up" or "Down" events to adjacent sub-layers. "Up" indicates that the layer has been activated, and "Down" indicates that the layer has been terminated. In terms of the entire access process, it can also be considered that there is a physical layer below LCP and a network interface above each NCP. The activation (Up) of a sub-layer requires three events: the upper layer sends an "Open" request, the lower layer receives an "Up" event, and the negotiation of this layer is successful. The basic process of the protocol is as follows: the user requests to establish a link through a certain interface. At this time, the Open event is sent to the LCP sublayer of PPP. When the LCP starts, it requests to establish a physical link and starts PPPoE negotiation. When the PPPoE negotiation is successful, it sends an Up event to the LCP layer. Then the LCP sends a negotiation request to the other end. After both parties determine the configuration parameters of the link, the LCP sends an Up event to the authentication layer. After successful authentication, it sends an Up event to the NCP layer. If authentication is not required, the Up event can be sent directly to the NCP layer. The NCP protocol starts NCP processing after receiving the Up event. For example, the IPCP protocol will start negotiating the IP address, etc. The normal PPP termination process is that each NCP terminates separately, then the LCP terminates, and finally the physical layer terminates. However, the PPP implementation must be able to handle the abnormal situation where the physical link disconnects on its own and the LCP terminates before the NCP has terminated. (2) PPP encapsulation format The PPP encapsulation format is as follows: The sending order is from left to right. Protocol defines the protocol type of the encapsulated datagram. The most commonly used definitions are: 3. Implementation in VxWorks 3.1 PPP and PPPoE Packet Sending and Receiving Process To more clearly introduce the PPP and PPPoE packet sending and receiving process in VxWorks, we first introduce the structure of the VxWorks TCP/IP protocol stack. The positions of PPP and PPPoE in the VxWorks TCP/IP protocol stack are as follows: The biggest difference between the VxWorks TCP/IP protocol stack and the standard BSD TCP/IP protocol is the addition of the MUX layer. The role of the MUX layer is to manage the interaction between the protocol layer and the driver layer, making them transparent to each other. This allows a VxWorks operating system to support multiple protocols and drivers simultaneously. PPP and PPPoE are both link layer protocols, so they are located between the MUX and IP layers. The PPPoE layer mainly implements the PPPoE dialing process and encapsulates the upper-layer PPP packets into PPPoE layers. PPPoE sends data packets through the MUX layer interface using the Ethernet send function `etherOutput`. For receiving, it primarily calls the VxWorks-provided hook function `etherInputHookAdd` to add its own Ethernet hook function to process Ethernet frame types 0x8863 and 0x8864. If the frame type is 0x8863, it's a PPPoE Discovery packet; if it's 0x8864, it's a PPPoE Session packet that has been decapsulated and sent to the PPP layer for processing. The PPP layer software mainly implements functions such as LCP link establishment, PPP authentication, IPCP IP address negotiation, and PPP encapsulation of IP data packets. The interface between the PPP layer and the IP layer is mainly achieved by adding an `if_PPP` network interface. From the IP layer's perspective, the `if_PPP` interface is no different from a regular network interface device. As a network interface in the VxWorks TCP/IP protocol stack, `if_PPP` can encapsulate IP data packets and send and receive IP packets over the PPP link. The PPP and PPPoE layers also have corresponding interface functions. In the sending direction, PPP data packets (whether IP, LCP, or IPCP) are encapsulated by the PPPoE layer before being sent out. In the receiving direction, the PPPoE layer first judges the received packet; if it is a PPF packet, it is handed over to the PPP layer for processing. The PPP layer distributes the packet to the relevant modules such as LCP, IPCF, and IP for processing according to the protocol type. The entire PPP and PPPoE packet sending and receiving process is shown in Figure 2. 3.2 PPP and PPPoE Software Module Design The entire PPPoE and PPP software consists of PPP, PPP Adapter, PPP-PoE Discovery, PPPoE Session, PPPoE Timer, PPPoE Adapter, and PPPoE Config modules, as shown in Figure 3. 1) The PPP module mainly implements LCP, IPCP, and acceptance protocols (chap, pap), etc. PPP also implements a virtual ifnet interface to encapsulate and distribute upper-layer IP packets. 2) The PPP Adapter module mainly implements interface adaptation between the PPP and PPPoE modules. 3) The PPPoE Discovery module implements the processing of the Discovery phase of PPPoE. 4) The PPPoE Session module handles the PPPoE Session phase, primarily PPPoE encapsulation and decapsulation. 5) The PPPoE Timer module implements the timer function for the PPPoE module, used for state machine switching during the PPPoE Discovery phase. 6) The PPPoE Adapter module handles PPPoE packet transmission and reception. 7) The PPPoE Config module implements PPP and PPPoE configuration functions, such as configuring usernames and passwords. 4. Conclusion This paper introduces a method for implementing VoIP voice access using PPP and PPPoE protocols. It details the principles of PPP and PPPoE protocols and discusses their specific implementation under the VxWorks operating system, demonstrating its engineering application value.