Editing NatT protocol
From EMule Wiki
Warning: The database has been locked for maintenance, so you will not be able to save your edits right now. You may wish to cut-n-paste the text into a text file and save it for later.
The administrator who locked it offered this explanation: site maintenance
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 5: | Line 5: | ||
NAT (Network Address Translation) Traversal allows Low ID to Low ID connections. | NAT (Network Address Translation) Traversal allows Low ID to Low ID connections. | ||
There are different techniques to achieve this, like STUN (Simple Traversal of UDP through NATs), or TURN (Traversal Using Relay NAT). For obvious reasons TURN is not suitable for any kind of file sharing applications. | There are different techniques to achieve this, like STUN (Simple Traversal of UDP through NATs), or TURN (Traversal Using Relay NAT). For obvious reasons TURN is not suitable for any kind of file sharing applications. | ||
− | The NatT for eMule uses there for STUN, as well as a attempt to become a High ID by reusing the Listening port for outgoing connections, if the NAT device is a Full Cone this technique will make the client fully | + | The NatT for eMule uses there for STUN, as well as a attempt to become a High ID by reusing the Listening port for outgoing connections, if the NAT device is a Full Cone this technique will make the client fully connectable, but it works only in a few cases. |
The main implementation using STUN can connect even through hardware firewalls, it only fails on Symmetric NAT’s, there are as well methods to penetrate these but they require to much overhead and are there fore like TURN not suitable for file sharing. | The main implementation using STUN can connect even through hardware firewalls, it only fails on Symmetric NAT’s, there are as well methods to penetrate these but they require to much overhead and are there fore like TURN not suitable for file sharing. | ||
Line 13: | Line 13: | ||
== NAT Tunneling == | == NAT Tunneling == | ||
To establish a communication tunnel from Alice to Bob through a NAT or a firewall Alice (A) sends first an call-back request to Carlo (C) witch records Alice’s UDP port and IP and relays them together with the request to Bob (B). | To establish a communication tunnel from Alice to Bob through a NAT or a firewall Alice (A) sends first an call-back request to Carlo (C) witch records Alice’s UDP port and IP and relays them together with the request to Bob (B). | ||
− | At this point Bob knows all he needs but Alice does not know enough (she does not know his UDP port). Now Bob tries to contact Alice directly over UDP (now his NAT/FW is open for messages form Alice) if she is behind a Full Cone Nat, she will get the message and will be able to reply. If she don’t answers after a short time Bob sends an own call-back request to Carlo or Dave (this depends on the later described different call-back relay schemes), he does the same as before and tells Alice the UDP port and IP of Bob. Now she can send him messages and he will receive them (this fails only if one of the two have a symmetric NAT, see the appendix for explanation). | + | At this point Bob knows all he needs but Alice does not know enough (she does not know his UDP port). Now Bob tries to contact Alice directly over UDP (now his NAT/FW is open for messages form Alice) if she is behind a Full Cone Nat, she will get the message and will be able to reply. If she don’t answers after a short time Bob sends an own call-back request to Carlo or Dave (this depends on the later described different call-back relay schemes), he does the same as before and tells Alice the UDP port and IP of Bob. Now she can send him messages and he will receive them (this fails only if one of the two have a symmetric NAT, see the appendix for explanation). If everything works they now have a working tunnel, to not loose it they exchange ping messages every few seconds as long as they need the tunnel. |
− | If everything works they now have a working tunnel, to not loose it they exchange ping messages every few seconds as long as they need the tunnel. | + | |
− | + | ||
<pre> | <pre> | ||
Line 30: | Line 28: | ||
<pre> | <pre> | ||
[uint8] pOPS // bit Field | [uint8] pOPS // bit Field | ||
− | // | + | // 6 reserved |
− | // | + | // 3 IdKind |
// 1 req answer | // 1 req answer | ||
− | [ID] // variable length determined by the Ping Options above | + | [ID] // variable length determined by the Ping Options above |
[Obfiscation] // uint8 obfuSetings | [Obfiscation] // uint8 obfuSetings | ||
// hash128 userHash | // hash128 userHash | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
== Callback Methods == | == Callback Methods == | ||
+ | Text to be added | ||
− | === eServer ( | + | === eServer (Official) === |
− | + | Text to be added | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
=== Kad (*Unofficial*) === | === Kad (*Unofficial*) === | ||
− | + | Text to be added | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
=== XS (Neo & Co) === | === XS (Neo & Co) === | ||
− | + | Text to be added | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
== User Mode TCP == | == User Mode TCP == | ||
Line 149: | Line 52: | ||
This implementation is basically a kind of self coded TCP with small modifications, it is called User Mode TCP and have almost all relevant features of the real TCP included (like congestion control). | This implementation is basically a kind of self coded TCP with small modifications, it is called User Mode TCP and have almost all relevant features of the real TCP included (like congestion control). | ||
− | + | == Connection Begin == | |
To establish a connection Alice (A) sends an NAT_SYN packet to Bob (B) over UDP. Bob answers on this request with an NAT_SYN_ACK, on the moment the Packet is received the connection is considered Established. | To establish a connection Alice (A) sends an NAT_SYN packet to Bob (B) over UDP. Bob answers on this request with an NAT_SYN_ACK, on the moment the Packet is received the connection is considered Established. | ||
Line 162: | Line 65: | ||
Booth packets have the same content, like following: | Booth packets have the same content, like following: | ||
<pre> | <pre> | ||
− | [uint8 | + | [uint8] version |
− | [uint32 | + | [uint32] MAXFRAGSIZE (obtional) |
</pre> | </pre> | ||
=== Communication === | === Communication === | ||
− | All send data segments are equipped with a unique sequence number indicating their position in the data stream. When Bob (B) receives a NAT_DATA segment form Alice (A) he acknowledges it with an NAT_DATA_ACK, if Alice don’t get the | + | All send data segments are equipped with a unique sequence number indicating their position in the data stream. When Bob (B) receives a NAT_DATA segment form Alice (A) he acknowledges it with an NAT_DATA_ACK, if Alice don’t get the acknowledgment she will resend the segment, she will also resend it if she gets acknowledgments for 3 segments with an higher sequence Number when the, while the a acknowledgment for the older segment is still missing (Fast retransmission). |
− | + | ||
− | + | ||
− | + | ||
<pre> | <pre> | ||
A B | A B | ||
... | ... | ||
− | DATA ---> | + | DATA ---> OnRecived(0) |
OnSend(0) <--- DATA_ACK | OnSend(0) <--- DATA_ACK | ||
... | ... | ||
Line 182: | Line 82: | ||
The NAT_DATA packet have the following format: | The NAT_DATA packet have the following format: | ||
<pre> | <pre> | ||
− | [uint32 | + | [uint32] Sequence Nr. |
− | [Data | + | [Data] (obtional) |
</pre> | </pre> | ||
The NAT_DATA_ACK packet have the following format: | The NAT_DATA_ACK packet have the following format: | ||
<pre> | <pre> | ||
− | [uint32 | + | [uint32] Sequence Nr. |
− | [uint32 | + | [uint32] Receiving Window Size |
</pre> | </pre> | ||
Line 232: | Line 132: | ||
Booth Packets have no content. | Booth Packets have no content. | ||
− | To terminate an | + | To terminate an errorless connection Alice (A) Sends an NAT_RST, packet and considers the connection closed, Bob (B) don’t answers on this packet and as well considers the connection closed at this point. |
<pre> | <pre> | ||
Line 243: | Line 143: | ||
The packet may contain an uint32 error code that is parsed to the OnClose function. | The packet may contain an uint32 error code that is parsed to the OnClose function. | ||
<pre> | <pre> | ||
− | [uint32 | + | [uint32] ErrorCode |
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
= Appendix = | = Appendix = | ||
− | + | == NAT Types (from http://www.voip-info.org/wiki-STUN) == | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | == NAT Types | + | |
− | from http://www.voip-info.org/wiki-STUN | + | |
*Full Cone: A full cone NAT is one where all requests from the same internal IP address and port are mapped to the same external IP address and port. Furthermore, any external host can send a packet to the internal host, by sending a packet to the mapped external address. | *Full Cone: A full cone NAT is one where all requests from the same internal IP address and port are mapped to the same external IP address and port. Furthermore, any external host can send a packet to the internal host, by sending a packet to the mapped external address. | ||
Line 399: | Line 156: | ||
*Port Restricted Cone: A port restricted cone NAT is like a restricted cone NAT, but the restriction includes port numbers. Specifically, an external host can send a packet, with source IP address X and source port P, to the internal host only if the internal host had previously sent a packet to IP address X and port P. | *Port Restricted Cone: A port restricted cone NAT is like a restricted cone NAT, but the restriction includes port numbers. Specifically, an external host can send a packet, with source IP address X and source port P, to the internal host only if the internal host had previously sent a packet to IP address X and port P. | ||
− | *Symmetric: A symmetric NAT is one where all requests from the same internal IP address and port, to a specific destination IP address and port, are mapped to the same external IP address and port. If the same host sends a packet with the same source address and port, but to a different destination, a different mapping is used. Furthermore, only the external host that receives a packet can send a UDP packet back to the internal host. | + | *Symmetric: A symmetric NAT is one where all requests from the same internal IP address and port, to a specific destination IP address and port, are mapped to the same external IP address and port. If the same host sends a packet with the same source address and port, but to a different destination, a different mapping is used. Furthermore, only the external host that receives a packet can send a UDP packet back to the internal host. |
== OpCodes == | == OpCodes == | ||
Line 409: | Line 166: | ||
|- | |- | ||
|OP_NAT_PING | |OP_NAT_PING | ||
− | | ' | + | | '_' |
|- | |- | ||
| | | | ||
|- | |- | ||
|OP_NAT_SYN | |OP_NAT_SYN | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_NAT_SYN_ACK | |OP_NAT_SYN_ACK | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_NAT_DATA | |OP_NAT_DATA | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_NAT_DATA_ACK | |OP_NAT_DATA_ACK | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_NAT_FIN | |OP_NAT_FIN | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_NAT_FIN_ACK | |OP_NAT_FIN_ACK | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_NAT_RST | |OP_NAT_RST | ||
− | | ' | + | | '_' |
|- | |- | ||
| | | | ||
|- | |- | ||
− | | | + | |CT_EMULE_BUDDYID |
− | | ' | + | | '_' |
|- | |- | ||
− | | | + | |CT_XS_EMULE_BUDDYIP |
− | | ' | + | | '_' |
|- | |- | ||
− | | | + | |CT_XS_EMULE_BUDDYUDP |
− | | ' | + | | '_' |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| | | | ||
|- | |- | ||
|OP_NAT_CALLBACKREQUEST_KAD | |OP_NAT_CALLBACKREQUEST_KAD | ||
− | | ' | + | | '_' |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| | | | ||
|- | |- | ||
|OP_XS_BUDDY_REQ | |OP_XS_BUDDY_REQ | ||
− | | ' | + | | '_' |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|OP_XS_BUDDYPING | |OP_XS_BUDDYPING | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_XS_MULTICALLBACKUDP | |OP_XS_MULTICALLBACKUDP | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_XS_MULTICALLBACKTCP | |OP_XS_MULTICALLBACKTCP | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_CALLBACKREQUEST_XS | |OP_CALLBACKREQUEST_XS | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_NAT_CALLBACKREQUEST_XS | |OP_NAT_CALLBACKREQUEST_XS | ||
− | | ' | + | | '_' |
|- | |- | ||
| | | | ||
|- | |- | ||
|OP_PUBLICPORT_REQ | |OP_PUBLICPORT_REQ | ||
− | | ' | + | | '_' |
|- | |- | ||
|OP_PUBLICPORT_ANSWER | |OP_PUBLICPORT_ANSWER | ||
− | | ' | + | | '_' |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | + | == Spelling Note == | |
+ | All text I post here will be checked with M$ Word's spell checker, there for all spelling mistakes are the intellectual property of M$ ;) |