Shadowrun: Awakened 29 September 2011 - Build 871
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
RakNet::NatTypeDetectionServer Class Reference

Server code for NatTypeDetection. More...

#include <NatTypeDetectionServer.h>

Inheritance diagram for RakNet::NatTypeDetectionServer:

List of all members.

Classes

struct  NATDetectionAttempt

Public Types

enum  NATDetectionState {
  STATE_NONE, STATE_TESTING_NONE_1, STATE_TESTING_NONE_2, STATE_TESTING_FULL_CONE_1,
  STATE_TESTING_FULL_CONE_2, STATE_TESTING_ADDRESS_RESTRICTED_1, STATE_TESTING_ADDRESS_RESTRICTED_2, STATE_TESTING_PORT_RESTRICTED_1,
  STATE_TESTING_PORT_RESTRICTED_2, STATE_DONE
}

Public Member Functions

 NatTypeDetectionServer ()
virtual void OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual PluginReceiveResult OnReceive (Packet *packet)
void Shutdown (void)
void Startup (const char *nonRakNetIP2, const char *nonRakNetIP3, const char *nonRakNetIP4)
virtual void Update (void)
 Update is called every time a packet is checked for .
virtual ~NatTypeDetectionServer ()

Static Public Member Functions

static void DestroyInstance (NatTypeDetectionServer *i)
static NatTypeDetectionServerGetInstance (void)

Protected Member Functions

unsigned int GetDetectionAttemptIndex (const SystemAddress &sa)
unsigned int GetDetectionAttemptIndex (RakNetGUID guid)
void OnDetectionRequest (Packet *packet)

Protected Attributes

DataStructures::List
< NATDetectionAttempt
natDetectionAttempts
SOCKET s1p2
unsigned short s1p2Port
SOCKET s2p3
unsigned short s2p3Port
SOCKET s3p4
char s3p4Address [64]
unsigned short s3p4Port
SOCKET s4p5
unsigned short s4p5Port

Detailed Description

Sends to a remote system on certain ports and addresses to determine what type of router, if any, that client is behind Requires that the server have 4 external IP addresses

  1. Server has 1 instance of RakNet. Server has four external ip addresses S1 to S4. Five ports are used in total P1 to P5. RakNet is bound to S1P1. Sockets are bound to S1P2, S2P3, S3P4, S4P5
  2. Client with one port using RakNet (C1). Another port not using anything (C2).
  3. C1 connects to S1P1 for normal communication.
  4. S4P5 sends to C2. If arrived, no NAT. Done. (If didn't arrive, S4P5 potentially banned, do not use again).
  5. S2P3 sends to C1 (Different address, different port, to previously used port on client). If received, Full-cone nat. Done. (If didn't arrive, S2P3 potentially banned, do not use again).
  6. S1P2 sends to C1 (Same address, different port, to previously used port on client). If received, address-restricted cone nat. Done.
  7. Server via RakNet connection tells C1 to send to to S3P4. If address of C1 as seen by S3P4 is the same as the address of C1 as seen by S1P1 (RakNet connection), then port-restricted cone nat. Done
  8. Else symmetric nat. Done.

See also http://www.jenkinssoftware.com/raknet/manual/natpunchthrough.html

See also:
NatPunchthroughServer
NatTypeDetectionClient

Definition at line 48 of file NatTypeDetectionServer.h.


Member Enumeration Documentation

Enumerator:
STATE_NONE 
STATE_TESTING_NONE_1 
STATE_TESTING_NONE_2 
STATE_TESTING_FULL_CONE_1 
STATE_TESTING_FULL_CONE_2 
STATE_TESTING_ADDRESS_RESTRICTED_1 
STATE_TESTING_ADDRESS_RESTRICTED_2 
STATE_TESTING_PORT_RESTRICTED_1 
STATE_TESTING_PORT_RESTRICTED_2 
STATE_DONE 

Definition at line 80 of file NatTypeDetectionServer.h.


Constructor & Destructor Documentation

RakNet::NatTypeDetectionServer::NatTypeDetectionServer ( )
virtual RakNet::NatTypeDetectionServer::~NatTypeDetectionServer ( ) [virtual]

Member Function Documentation

static void RakNet::NatTypeDetectionServer::DestroyInstance ( NatTypeDetectionServer i) [static]
unsigned int RakNet::NatTypeDetectionServer::GetDetectionAttemptIndex ( const SystemAddress sa) [protected]
unsigned int RakNet::NatTypeDetectionServer::GetDetectionAttemptIndex ( RakNetGUID  guid) [protected]
static NatTypeDetectionServer* RakNet::NatTypeDetectionServer::GetInstance ( void  ) [static]
virtual void RakNet::NatTypeDetectionServer::OnClosedConnection ( const SystemAddress systemAddress,
RakNetGUID  rakNetGUID,
PI2_LostConnectionReason  lostConnectionReason 
) [virtual]

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

Parameters:
[in]systemAddressThe system whose connection was closed
[in]rakNetGuidThe guid of the specified system
[in]lostConnectionReasonHow the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from RakNet::PluginInterface2.

void RakNet::NatTypeDetectionServer::OnDetectionRequest ( Packet packet) [protected]
virtual PluginReceiveResult RakNet::NatTypeDetectionServer::OnReceive ( Packet packet) [virtual]

OnReceive is called for every packet.

Parameters:
[in]packetthe packet that is being returned to the user
Returns:
True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from RakNet::PluginInterface2.

void RakNet::NatTypeDetectionServer::Shutdown ( void  )
void RakNet::NatTypeDetectionServer::Startup ( const char *  nonRakNetIP2,
const char *  nonRakNetIP3,
const char *  nonRakNetIP4 
)

Start the system, binding to 3 external IPs not already in useS

Parameters:
[in]nonRakNetIP2First unused external IP
[in]nonRakNetIP3Second unused external IP
[in]nonRakNetIP4Third unused external IP
virtual void RakNet::NatTypeDetectionServer::Update ( void  ) [virtual]

Reimplemented from RakNet::PluginInterface2.


Member Data Documentation

Definition at line 106 of file NatTypeDetectionServer.h.

Definition at line 111 of file NatTypeDetectionServer.h.

unsigned short RakNet::NatTypeDetectionServer::s1p2Port [protected]

Definition at line 112 of file NatTypeDetectionServer.h.

Definition at line 111 of file NatTypeDetectionServer.h.

unsigned short RakNet::NatTypeDetectionServer::s2p3Port [protected]

Definition at line 112 of file NatTypeDetectionServer.h.

Definition at line 111 of file NatTypeDetectionServer.h.

Definition at line 113 of file NatTypeDetectionServer.h.

unsigned short RakNet::NatTypeDetectionServer::s3p4Port [protected]

Definition at line 112 of file NatTypeDetectionServer.h.

Definition at line 111 of file NatTypeDetectionServer.h.

unsigned short RakNet::NatTypeDetectionServer::s4p5Port [protected]

Definition at line 112 of file NatTypeDetectionServer.h.


The documentation for this class was generated from the following file:

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net