Sender: gdtyy (gdtyy), email area: embedded
Title: Implementation of pppoe on easyarm2200 and smartarm2200
Mailing station: shuimu community (Mon Jun 25 23:23:10 2007), within the station
**************************************** ****
* Implementation of pppoe on easyarm2200 and smartarm2200 *
**************************************** ****
------ Discuss the overall network solution of "ECOs value-added package"
Asdjf@163.com www.armecos.com
Pppoe is short for PPP over Ethernet. It can be simply understood as the PPP protocol running on Ethernet, while PPP is a point
Point-to-Point Protocol for point-to-point communication. Today, IP grouping networks are widely integrated across the world, with various business applications
Such as voice, video, data, and control information tend to be integrated into an IP network, that is, anything over IP. While
IP networks can also be based on various media, namely, IP over anything. So that we can implement anything over
Anything.
However, broadband access has been plagued by the development of IP networks, the last kilometer that people often say. Now,
There are various broadband access methods in the Communication Market: Lan, ADSL, hfcable modem, WLAN, etc.
According to a certain market share. Because ADSL uses existing widely deployed telephone copper wires, the cost advantage is obvious.
It has become a mainstream broadband access method. It provides a minimum bandwidth of 512 kHz and a maximum bandwidth of 8 MHz. Exclusive to users.
This reduces the Internet access rate as the number of Internet users increases. The price of ADSL is low and can be accepted by the majority of ordinary consumers. Use
Generally, the user connects to the broadband access server of the service provider through the ADSL modem to access the network. As an ECOs value-added package
As part of the product line, ecosnet pppoe allows PPP sessions to be carried over Ethernet, which simplifies the broadband Internet in two ways
Difficulty in developing access solutions. First, pppoe service providers can use existing telephone networks and billing methods. Second
The pppoe service provider allows customers to install and access the service in a user-friendly dial-up method similar to the one currently popular.
Network.
Although Ethernet is a broadcast method, it is still necessary to implement point-to-point protocols, mainly because a large number of practical applications are full
Meet the needs of user authentication. For example:
1. Billing --- currently, there are two main billing methods for Service Providers: pay-as-you-go and long-term (unlimited monthly subscription and limited monthly subscription)
, Timing, time-based); paybytraffic. Each billing method is not necessarily perfect, and is generally flexible according to the actual situation
Promotions, such as package, holiday discounts, midnight price reduction, which leads to changing billing formulas and requires Databases
Records transactions. Therefore, user recognition must be provided. In addition, traffic management is also a special billing method, although
You do not need to pay for it, but you can simulate it as a billing method.
2. hierarchical user management-for example, you can use pppoe to implement user authentication on VOD in a hotel.
========================
| Pppoe protocol analysis |
========================
How does pppoe work?
Pppoe protocols are divided into discovery and session phases. In the discovery phase, the Access Concentrator is selected to determine the session tag.
Id recognition; standard PPP process executed in the session phase.
Discovery phase:
Step 1 the host broadcasts to all the AC (Access Concentrator) on the network and requires one of them to provide services;
In step 2, all the ACSS that meet the conditions return a response. The source address of the response frame is the MAC address of the server;
Step 3 the host selects an appropriate one based on the concentrator name and the available service tag from the received responses
Access the concentrator and confirm the response to it.
Step 4 The Access Concentrator receives the confirmation and then returns a confirmation to the host. After the host receives the confirmation, both parties enter the session level.
.
In the session phase, either party can terminate the session.
The normal PPP frame is transmitted in the session phase. The LCP, PAP/chap, and NCP are completed, and the IP transmission phase is entered.
.
====================
| Pppoe frame format |
====================
Pppoe frames are directly carried over Ethernet. For this reason, 802.3 and 8863 are specified as the ppppoe
Type identification code. The frame structure of 802.3 is as follows:
--------------------------------------------------------------------------------
----------------------------------
| Leading position PR | frame start position SD | destination MAC address da | source MAC address sa | type/length Len |
Data Field Data | fill pad | check FCS |
--------------------------------------------------------------------------------
----------------------------------
64 bit 2 bit 48 bit 48 bit 16 Bit
<= 1500 bytes of data smaller than 46 bytes complement 0 32 bit
Type Description: 0800 IP packets; 0806 ARP packets; 814c SNMP Packets; 8137 IPX/SPX; 8863 pppoe packets
Current Stage; 8864 pppoe session stage
The value less than 0600h is used for IEEE802 frames, indicating the length of the data packet.
Data Description: Da + SA + type = 14 bytes + Data = 1514 bytes, that is, the maximum length of the transfer package <= 1514
Bytes.
Pad Description: The minimum package length is no less than 60 bytes, and the minimum data length is 46 bytes. If not, add 0.
It can be seen from the above that the network protocol stack can identify IP, ARP, pppoe and other frames at the Ethernet frame level. More Ethernet frames
For details about the data structure, see ne2000 Nic chip driver.
The data domain of the pppoe frame carries the pppoe data packet. The message format is as follows:
-------------------------------------------------------
| Version 0x1 | Type 0x1 | encoding | session ID | length | load |
-------------------------------------------------------
4 bit 4 bit 1 byte 2 byte 2 byte 0-1500 byte
The meanings of each field are as follows:
(1) version field indicates the Protocol version information. Currently, the value is 1;
(2) The type field must be set to 1;
(3) encoding fields have different values at different stages;
(4) session ID field. The value in the discovery phase is 0x0000.
The obtained unique value allocated by the AC (Access Concentrator access concentration;
(5) The length field can be 0-bytes;
(6) The net load field stores the data carried by the pppoe protocol frame. Zero or multiple tag structures are carried in the discovery phase,
The PPP protocol data is carried during the session phase. Note that it is not a simple PPP packet because it does not need the start position in the PPP protocol.
The mark, address bit, control bit, and end sign do not require the Data Translation and CRC verification specified in the PPP protocol.
Tag tag structure:
-----------------------------
| Tag type | Tag Length | tag value |
-----------------------------
2 bytes 2 bytes
======================================
| Ecosnet network solution |
======================================
How can we enable easyarm2200 and smartarm2200 to support multiple types of network interconnection? Overall network solution provided by ecosnet
The solution can easily achieve this.
The ecosnet network architecture provides interface API functions and hook api functions, allowing you to flexibly and conveniently add various functions and
Various Network Media are required.
API functions
Netif_add (netif, & ipaddr, netmask, & GW, state, init, input );
--------------------------------------------------------------------------------
-
Struct netif *
Netif_add (struct netif * netif, struct ip_addr * ipaddr, struct ip_addr
* Netmask,
Struct ip_addr * GW,
Void * state,
Err_t (* init) (struct netif * netif ),
Err_t (* input) (struct pbuf * P, struct netif * netif ))
--------------------------------------------------------------------------------
-
Network Interface data structure pre-allocated by netif
IP address of the new ipaddr Network Interface
Subnet Mask of netmask's new Network Interface
Default gateway IP address of GW New Network Interface
The opaque data transmitted by the State to the new network interface.
Callback Function of the init initialization Interface
Callback Function called by input Transmission
Transfer the entry package to the upper-layer protocol stack
Returns the netif structure. If the structure fails, null is returned.
Example: netif_add (n2k_netif, & ipaddr, & netmask, & GW, null, n2k_init,
Tcpip_input );
The interface API function netif_add adds the network device driver to the IP Route queue.
Select the sending Interface Based on the routing protocol. This function parameter includes the network interface data structure, IP address, subnet mask, and gateway location.
Address, transfer data, initialize callback, and transfer callback. You can use this function to add various network interface devices to the IP path.
Queue, such as loop back, slip, Ethernet, and PPP.
Multi-interface driver. In this way, various network devices can be easily connected to the system.
Hook api functions
Etherinputhookadd (myhook );
Myhook's own Ethernet hook processing function.
Pppoe sends data packets through the Ethernet transmission function etheroutput. The receiving direction is mainly to call ecosnet
Added the hook function etherinputhookadd to add your own Ethernet hook function for the Ethernet frame type
0x8863 and 0x8864 packets are intercepted.
IP, ARP, pppoe, and other frames are transmitted simultaneously in an Ethernet frame. The hook function is used to intercept different types of frames for corresponding processing.
Portal. For example, IP frames are directly sent to IP Route queues, ARP is distributed to ARP, and pppoe is intercepted to pppoe.
. The hook function mainly performs filtering. There are three processing methods:
1. passthrough --- directly passthrough without changing the data of the original package. For example, a serial port listener records the received data
For simultaneous passthrough;
2. Intercept-intercept specific data and change the transfer path;
3. Tampering-Modify the data and pass it up.
Pppoe uses the interception method to change the transmission path of an Ethernet frame to the pppoe processing part.
The hook function can be stacked in series, so there is a stacking order problem. For example:
------------
| Pppoe |
------------
| Firewall |
------------
| VPN |
------------
The bottom-layer hook is connected to the VPN, the firewall is mounted on it, and the pppoe interception is mounted on it. The order can be adjusted, and the closer it is to the bottom layer.
, The stronger the function, but the more CPU resources are consumed.
VPN can achieve private network effect on the public network, the main work is encryption and decryption, requires the commercial and confidential encryption chip (is
EEPROM, very expensive), and the Internet access certificate.
The firewall filters IP packets to complete a series of control rules.
The pppoe frame is intercepted to the pppoe processing part.
The simple method to implement pppoe on easyarm2200 and smartarm2200 is to use the interfaces provided by ecosnet.
API and hook api. The pseudo program is as follows:
// Added the hook function for pppoe interception.
Etherinputhookadd (pppoe_hook );
// Create a PPP thread
Sys_create_new (pppmain, para, ppp_thread_prio );
// Register the PPP Network Interface
Netif_add (ppp_netif, & ipaddr, & netmask, & GW, null, ppp_init, tcpip_input );
In this way, the pppoe frame transmitted over the Ethernet is intercepted to the pppoe processing program and then sent to the PPP protocol. If
If the PPP negotiation succeeds, IP data packets are transmitted to the upper-layer protocol stack. Pppoe sender directly calls the Ethernet sending Function
Etheroutput: sends encapsulated pppoe frames.
--
※Source: · Shui Mu community http://newsmth.net · [from: 61.149.56. *]