We know the host needs to be within the same subnet as its gateway for the routing. However in PPPoE, the public IP has a 255.255.255.255 subnet mask, it means that the IP is not in the same subnet as the gateway. I wonder how the host passes the packet to the gateway in this case? Many thanks!
PPP generally establishes a point-to-point link (or session), with exactly two link partners. Everything one of them sends the other receives, no matter what addresses are used on top of the PPP level.
Since Ethernet requires valid MAC addressing (on the data link layer), PPPoE establishes a PPP session over Ethernet, ie. between two link partners. That PPPoE session is entirely independent from anything else that might be running on the Ethernet network - especially 'normal' IPv4 over Ethernet using ARP.
As to routing, the default route can simply point to the PPP interface, indicating that all packets are simply sent out of that interface. The default gateway is 'the next hop beyond'.
On Ethernet, the distinction (or multiplexing) is done using dedicated EtherType values for PPPoE (
0x8864) instead of IPv4's
0x0800. That way, the network stack doesn't pass the frames to the IP stack but to the PPPoE driver (which in turn may or may not pass extracted PPP frames to the IP stack or any other supported L3 stack).
Because it's POINT-TO-POINT. Traffic only has one place to go... the other side of the link. /32 routes are added to the route table indicating what is on the other side. One could also just use an interface route. (But a lot of host OSes have trouble with those. And it leads to confusion when people don't understand this.)
I'm not sure if I understand your question.
255.255.255.255 translates to "This device, and only this device". Or maybe "this interface" is a better expression. It's not part of any network, so it has no gateway. The IP isn't "public" either in the sense that you could reach it from the inertnets, it's exclusively used in a closed peer-to-peer circuit like DSL.
Let's say your ISP:s "public" address is 18.104.22.168/32 (255.255.255.255). They don't provide you an address range, they provide you a single IP address, let's say 192.0.2.25. I don't have a PPPoE line, so I can't check, but logic says this is also a /32 address - there's really no reason for it not to be. That address would be assigned to the modem's PPPoE interface.
Your modem provides internal IP addressing in the range of 192.168.0.0/24 and reserves 192.168.0.1 for itself to be provided as a default gateway. Any traffic your PC wants to send to the internyet it will send to the modem. The modem NATs the traffic, so the ISP only receives traffic originating from a single host, 192.0.2.25.
Whether your modem has a default route to 22.214.171.124 or if 126.96.36.199 is assigned as a default gateway doesn't change how it forwards the traffic. Anything destined outside of 192.168.0.0/24 will be sent to 188.8.131.52. The ISPs router likely does have a routing table entry; "send all traffic to 192.0.2.25 directly to it" - it knows the host is reachable through the PPPoE link.
So the only place where "gateway" enters the picture in any meaningful sense is your home network.
I hope this helps a bit. I admit I'm not an expert on PPPoE, so I can only try to explain this on conceptual level as I understand it. I'm sure more knowledgeable members of the community will point out my mistakes :-)