RakNet framework

来源:互联网 发布:手机办公必备软件 编辑:程序博客网 时间:2024/05/21 09:48
1. network communication, plugins that use network communication, and general game functionality.
    1) Network communication
        + RakPeerInterface
            - based on UDP, The primary class
            - connections, connection management
            - congestion control, remote server detection
            - out of band messaging
            - connection statistics
            - latency and packetloss simulation
            - secure connectivity        
        + TCPInterface
            - a wrapper for TCP
            - communicate with external systems based on the TCP.
            
    2) Plugins
            + an instance of RakPeer or PacketizedTCP
            + uses chain of responsibility design pattern
            + host determination
            + file transfers
            + NAT traversal
            + voice communication
            + remote procedure calls
            + game object replication
    
    3) RakPeer
        + the base functionality for UDP communication
        + two threads
            - wait for incoming datagrams
            - perform periodic updates, such as determing lost connections, pings
            - a Remote System structure
                - contains a class to manage congestion control
            - Connections are identified by SystemAddress or RakNetGuid
            - established through UDP messages, (a connection request payload & an 'offline message' identifier)
        + a connection requests arrives
            - RakPeer transmits internal state data
            - checks this connection
            - repeat connection list, security measures
            - ID_CONNECTION_REQUEST_ACCEPTED, or ID_NEW_INCOMING_CONNECTION
        + Outgoing messages
            - larger than the MTU, fragmented internally
            - Messages are sent in order of priority.
            - resends taking priority over new sends
        + incoming datagrams
            - using a blocking recvfrom thread
            - recorded timestamp
            - pushed a thread-safe queue
            - processed through the ReliabilityLayer class
                - congestion control
                - ACKS, NAKS, resends, encryption, reassembly of large messages
        + Connected messages are first processed
        + Calling RakPeer::Receive() to process one message
            - Message returned to the user are returned from RakPeer::Receive()
            - to call Receive() in a loop to get all messages
    4) NetworkIDObject
        + remote function calls
        + the ability for systems to refer to common objects
        + a 64 bit random number assigned
            - be used to lookup pointers through a hash
    5) SystemAddress struct
        + to represent remote systems
        + encoding of the IP address along with the port
    6) BitStream class
        + write single bits to a stream
        + automatic endian swapping
        + be enabled by commenting out  __BITSTREAM_NATIVE_END in RakNetDefines.h

    7) the architecture UML
        + file:///home/xxxx/devdir/raknet/RakNet-master/Help/RakNetUML.jpg
2. how to start

    1) Get one instance
            RakNet::RakPeerInterface* peer = RakNet::RakPeerInterface::GetInstance();
    2) Connect as client 
            peer->Startup(1, &SocketDescriptor(), 1)
            peer->Connect(serverIP, serverPort, 0, 0);
    
     
(not finish, will continue...)

    




















            
0 0
原创粉丝点击