Introduction to PPPoE Protocol (part)

Source: Internet
Author: User
Tags session id

PPPOE (PPP over Ethernet)
PPPoE adds the Ethernet header to the front of the standard PPP message.

1.PPPOE frame Format
Destination_addr source_addr ether_type PAYLOAD CHECKSUM
6 6 2 1

PAYLOAD:
VER TYPE CODE session_id LENGTH PLAYLOAD1
0001 0001 8BIT 2 2

PLAYLOAD1:
Tag_type tag_length Tag_value ...


Ether_type:
0x8863 Discovery Stage
0x8864 PPP Session Stage
CODE:
0x00 PPP Session Stage
0x09 PPPOE Active Discovery Initiation (PADI) packet
0x07 PPPOE Active Discovery offer (pado) packet
0x19 PPPOE Active Discovery Request (PADR) packet
0x65 PPPOE Active Discovery session-confirmation (PADS) PACKET
0xa7 PPPOE Active Discovery Terminate (PADT) packet
Tag_types:
0x0000 end_of_list
0x0101 Service-name
0x0102 Ac-name
0x0103 Host_uniq
0x0104 Ac-cookie
0x0105 vendor-specific
0x0110 Relau-session-id
0x0201 Service-name-error
0x0202 Ac-system-error
0x0203 Generic-error

The working principle of PPPoE Protocol
Two stages: Discovery phase, session stage.

The discovery phase is divided into 4 steps, with the primary purpose of establishing a unique PPPoE SessionID.
1. Client broadcast packet (PADI): Purpose: Client looking for server. Implementation: The client sends the CODE:0X09,SESSION-ID=0X0000, the label Type field value is 0x0101, the address 0xffffffffffff;
2. Server collection (PADI) (PAD0): Purpose: Server feedback client. Implementation: The service side sends the code:0x07,session-id=0x0000, the label Type field value is 0x0102 (as well as one or more servers), address client;
3. Client Select Server (PADR): purpose; multi-server preference. Implementation: The client sends the CODE:0X19,SESSION-ID=0X0000, the client does not receive the PAD0, sends the PAD1 again, and adds the long wait time. Address client;
4. Service-side Session confirmation (PADS): Purpose: To start a PPP session. Implementation: Service-side send code:0x65,session-id= unique. After the client receives pads confirmation, start the session phase.

User Terminal ADSL
Hair---------PADI-------->
Present <--------PAD0---------
Step---------Padr-------->
Segment <--------PADS---------
<------PPP Data------> Session Phase
<--------Padt--------> Session Release
Session phase:
PPDT can be sent at any time after the session is established, terminating the PPPoE session. Code:0xa7,session-id.


Code Analysis:
typedef struct PPPOECONNECTIONSTRUCT {
int discoverystate; /* Where We are in discovery * *
int discoverysocket; /* RAW socket for Discovery frames * *
int sessionsocket; /* Raw socket for session frames * *
unsigned char Myeth[eth_alen]; /* My MAC address * *
unsigned char Peereth[eth_alen]; /* Peer ' s MAC address * *
uint16_t session; /* Session ID * *
Char *ifname; /* Interface Name * *
Char *servicename; /* Desired service name, if any/*
Char *acname; /* Desired AC name, if any *
int synchronous; /* Use synchronous PPP * *
int Usehostuniq; /* Use host-uniq Tag * *
int printacnames; /* Just Print AC names * *
int skipdiscovery; /* SKIP Discovery * *
int nodiscoverysocket; /* Don ' t even open discovery socket * *
int killsession; /* Kill Session and Exit * *
FILE *debugfile; /* Debug file for dumping packets * *
int Numpados; /* Number of Pado packets received * *
Pppoetag cookies; /* We have to send this if we get it * *
Pppoetag Relayid; * Ditto * *
int padshaderror; /* If PADS had an error tag * *
int discoverytimeout; /* Timeout for Discovery Packets * *
} pppoeconnection;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.