chapter 5.6 network and multiplayer edited by jeffery

Download Chapter 5.6 Network and Multiplayer edited by Jeffery

Post on 16-Jan-2016

218 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • Chapter 5.6Network and Multiplayeredited by Jeffery

  • *Multiplayer Modes:Event TimingTurn-BasedEasy to implementAny connection typeReal-TimeDifficult to implementLatency sensitiveInternet adds Lots o Latency

  • *Multiplayer Modes:Shared I/O, Single EngineInput DevicesShared keyboard layoutMultiple devices (e.g. trackballs)DisplayFull Screen, varying modesSplit ScreenFor this class: network instead!

  • *Protocols:Protocol DesignPacket Format and LengthAcknowledgement MethodologyError Checking / CorrectingCompressionEncryptionPacket Control

  • *Protocols:PacketsPacketsHeader = Protocol ManifestPayloadGotchasPointersLarge/Variable Size ArraysADTsInteger AlignmentEndian OrderProcessor dependant Intrinsic Types (int and long)Unicode vs. ASCII Strings

  • *Protocol Stack: Open System Interconnect

  • *Protocol Stack:Physical LayerBandwidthCapacity of data pipeMeasured in bps = bits per secondLatencyTravel time from point A to BMeasured in Milliseconds The MediumFiber, FireWire, IrD , CDMA, Table: Max Bandwidth Specifications

    SerialDSLCableLAN10/100/1GBaseTWireless802.11b/g/nT1Speed(bps)20K1.5M down896K up3M down256K up10M100M1Gb=11Mg=54Mn=70-150M1.5M

  • *Protocol Stack:Data Link LayerSerializes data to/from physical layerNetwork Interface CardEthernetMAC Address

  • *Protocol Stack:Network LayerPacket RoutingHopsRouters, Hubs, SwitchesInternet Protocol (IP)Contains Source & Destination IP AddressIPv4Widespread InfrastructureIPv6Larger IP address

  • *Protocol Stack:Network Layer: IP AddressUnicastStaticDHCPMulticastRequires multicast capable routerBroadcastLocalDirectedLoop BackSend to selfAddrAny0 = address before receiving an address

  • *Protocol Stack:Network Layer: DNSDomain Name ServiceConverts text name to IP addressMust contact one or more DNS servers to resolveLocal cache resolution possibleGame TipsStore local game cache to use when DNS out of order.DNS resolution often slow, use cache for same day resolution.

  • *Protocol Stack:Transport LayerManage data delivery, src to destError recoveryData flowTCP and UDP used with IPContains Source and Destination PortPort + IP = Net AddressPort Range = 0-64kWell known Ports 0-1k

  • *Protocol Stack:Transport Layer: TCPGuaranteed Correct In Order DeliveryAcknowledgement system Ack, Nack, ResendChecksumOut of BandConnection RequiredPacket WindowPacket CoalescenceKeep AliveStreamed DataUser must serialize data

  • *Protocol Stack:Transport Layer: UDPNon Guaranteed DeliveryNo Acknowledgement system May arrive out of orderChecksumNot ConnectedSource not verifiedHop Count Limit = TTL (time to live)Required for BroadcastingDatagramSent in packets exactly as user sends them

  • *Protocol Stack:Session LayerManages Connections between AppsConnectTerminateData ExchangeSocket API live at this layerCross platformCross language

  • *Protocol Stack:Session Layer: SocketsBased on File I/OFile DescriptorsOpen/CloseRead/WriteWinsockProvides standard specification implementation plus moreExtension to spec prefixed with WSARequires call to WSAStartup() before useCleanup with WSAShutdown()

  • *Protocol Stack:Session Layer: Socket DesignModesBlockingNon-BlockingStandard ModelsStandardSelectExtended ModelsWindowsWSAEventSelectI/O Completion PortsUnixPollKernel Queues

  • *Protocol Stack:Presentation LayerPrepares App Data for TransmissionCompressionPascal StringsString TablesFloat to FixedMatrix to QuaternionEncryptionEndean OrderWhen used cross platform or cross languageSerializePointersVariable Length Arrays

  • *Protocol Stack:Presentation Layer: BufferingPacket Coalescence

    Induced Latency

    Dead Data

    Large Packets

  • *Protocol Stack:Application LayerHandles Game LogicUpdate ModelsInput ReflectionState ReflectionSynchronizationDead ReckoningAI AssistArbitration

  • *Real-Time Communications:Connection ModelsBroadcastGood for player discovery on LANsPeer to PeerGood for 2 player gamesMade difficult by NATClient / ServerGood for 2+ player gamesDedicated lobby server for player discovery

  • *Real-Time Communications:Peer to Peer vs. Client/Server

    N = Number of players

    BroadcastPeer/PeerClient/ServerConnections0Client = 1Server = N

    BroadcastPeer/PeerClient/ServerSend1N-1Client = 1 Server = NReceiveN-1N-1Client = 1Server = N

  • *Real-Time Communications:Asynchronous EnvironmentsThreadPrioritySuspensionPoolingCritical Section & MutexSignal & EventData Sharingvolatile keywordInterlocked Inc/Dec

  • *Security:Encryption Goals

    Authentication

    Privacy

    Integrity

  • *Security:FirewallsPacket Filter

    Proxies

    Circuit Gateways

  • *Security:Firewalls: Network Address Translation

  • *Security:Firewalls: NAT TraversalPort Forwarding

    Port Triggering

    DMZ

    Determining WAN IP

  • *Summary:Topic Coverage

    Multiplayer ModesProtocolsProtocol StackReal-Time CommunicationsSecurity

  • *Summary:Further StudySocket ProgrammingSerial CommunicationServer DesignNetwork Gear & InfrastructureVOIPTools of the TradeUnit & Public Beta TestingMiddlewareDatabasesWeb DevelopmentAsynchronous Programming