Networking in UE4 Joe Graf @EpicCog.

Slides:



Advertisements
Similar presentations
Epic’s Build Tools & Infrastructure
Advertisements

CPSC Network Layer4-1 IP addresses: how to get one? Q: How does a host get IP address? r hard-coded by system admin in a file m Windows: control-panel->network->configuration-
Umut Girit  One of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer.
Adobe’s Real Time Messaging Protocol
Game Framework & Sample Projects
CCNA – Network Fundamentals
Intermediate TCP/IP TCP Operation.
Extensibility in UE4 Customizing Your Games and the Editor Gerke Max Preussner
Concurrency & Parallelism in UE4
11 TROUBLESHOOTING Chapter 12. Chapter 12: TROUBLESHOOTING2 OVERVIEW  Determine whether a network communications problem is related to TCP/IP.  Understand.
Network synchronization of Online Games Li, Zetan.
Integrating a Cloud Service Joe Overview Example from our games Support in UE4 to achieve that.
Rheeve: A Plug-n-Play Peer- to-Peer Computing Platform Wang-kee Poon and Jiannong Cao Department of Computing, The Hong Kong Polytechnic University ICDCSW.
User Datagram Protocol. Introduction UDP is a connectionless transport protocol, i.e. it doesn't guarantee either packet delivery or that packets arrive.
Distributed Systems Fall 2009 Replication Fall 20095DV0203 Outline Group communication Fault-tolerant services –Passive and active replication Highly.
Network Architectures Week 3 Part 2. Comparing The Internet & OSI.
Hands-On Microsoft Windows Server 2003 Networking Chapter 7 Windows Internet Naming Service.
PPP (Point to Point protocol).  On WAN connection, the protocol depends on the WAN technology and communicating equipment:  Examples:  HDLC –  The.
EEC-484/584 Computer Networks Lecture 2 Wenbing Zhao
Design and Implementation of a Server Director Project for the LCCN Lab at the Technion.
Game Framework & Sample Projects
JokerStars: Online Card Playing William Sanville Milestone 4.
Data/Link Layer Issues Protocol & Services Topology Error Detection & Recovery.
Niklas Smedberg Senior Engine Programmer, Epic Games
DCP COMMAND …bringing two-way communications to your DCPs.
Process-to-Process Delivery:
1 Lab 3 Transport Layer T.A. Youngjoo Han. 2 Transport Layer  Providing logical communication b/w application processes running on different hosts 
TRANSPORT LAYER T.Najah Al-Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System NET331.
CSE 381 – Advanced Game Programming 3D Game Architecture.
ICMP (Internet Control Message Protocol) Computer Networks By: Saeedeh Zahmatkesh spring.
CISCO NETWORKING ACADEMY Chabot College ELEC IP Routing Protocol Highlights.
Configuring Routing and Remote Access(RRAS) and Wireless Networking
Page 19/13/2015 Chapter 8 Some conditions that must be met for host to host communication over an internetwork: a default gateway must be properly configured.
Section 4 : The OSI Network Layer CSIS 479R Fall 1999 “Network +” George D. Hickman, CNI, CNE.
Objectives Configure routing in Windows Server 2008 Configure Routing and Remote Access Services in Windows Server 2008 Network Address Translation 1.
6.1. Transport Control Protocol (TCP) It is the most widely used transport protocol in the world. Provides reliable end to end connection between two hosts.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
1 © 2003, Cisco Systems, Inc. All rights reserved. CCNA 2 Module 9 Basic Router Troubleshooting.
Multimedia Over IP: RTP, RTCP, RTSP “Computer Science” Department of Informatics Athens University of Economics and Business Λουκάς Ελευθέριος.
Dynamic Source Routing in ad hoc wireless networks Alexander Stojanovic IST Lisabon 1.
4BP1 Electronic & Computer Engineering Paul Gildea th Year Interim Project Presentation.
TCP/IP Honolulu Community College Cisco Academy Training Center Semester 2 Version 2.1.
Remote Shell CS230 Project #4 Assigned : Due date :
Types of Service. Types of service (1) A network architecture may have multiple protocols at the same layer in order to provide different types of service.
Transport Layer COM211 Communications and Networks CDA College Theodoros Christophides
Sega 500 An Introduction to Replication Jeff “Ezeikeil” Giles
Packet switching network Data is divided into packets. Transfer of information as payload in data packets Packets undergo random delays & possible loss.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 Connecting to the Network Introduction to Networking Concepts.
1 Requirements for Internet Routers (Gateways) and Hosts Relates to Lab 3. (Supplement) Covers the compliance requirements of Internet routers and hosts.
EC week Review. Rules of Engagement Teams selected by instructor Host will read the entire questions. Only after, a team may “buzz” by raise of.
Cisco 2 - Routers Perrine. J Page 112/19/2015 Chapter 8 TCP/IP Error Message Some of the conditions that must be met in order for host to host communication.
70-293: MCSE Guide to Planning a Microsoft Windows Server 2003 Network, Enhanced Chapter 4: Planning and Configuring Routing and Switching.
Today’s topic: UDP Reliable communication over UDP.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
ITI-510 Computer Networks ITI 510 – Computer Networks Meeting 3 Rutgers University Internet Institute Instructor: Chris Uriarte.
Network Architecture Protocol hierarchies Design Issues for the layers
Reliable Client-Server Communication. Reliable Communication So far: Concentrated on process resilience (by means of process groups). What about reliable.
5. The Transport Layer 5.1 Role of Transport Layer It bridge the gab between applications and the network layer. Provides reliable cost-effective data.
WebRTC Don McGregor Research Associate MOVES Institute
You there? Yes Network Health Monitoring Heartbeats are sent to monitor health status of network interfaces Are sent over all cluster.
LSNDI RMRA 1 Design and troubleshooting M Clements.
Network Replication Possibly the ugliest thing to learn this semester Many different states Simulated Functions Is it an Event or function? Roles.
Troubleshooting. Why Troubleshoot? What Can Go Wrong? –Misconfigured zone –Misconfigured server –Misconfigured host –Misconfigured network.
CCNA 2 Router and Routing Basics Module 8 TCP/IP Suite Error and Control Messages.
Data Transport for Online & Offline Processing
H.264/SVC Video Transmission Over P2P Networks
NAT , Device Discovery Chapter 9 , chapter 10.
Net 431 D: ADVANCED COMPUTER NETWORKS
Process-to-Process Delivery:
Process-to-Process Delivery: UDP, TCP
Presentation transcript:

Networking in UE4 Joe Graf @EpicCog

Introduction Network topology and NATs C++ Replication Blueprint Replication Low Level Networking Diagnostic Tools

Network Topologies Client / Server Peer to Peer

Network Address Translation (NAT) Three types to think about Open Can accept unsolicited connections Moderate Can sometimes accept unsolicited connections Strict Can only accept connections from known addresses

Gears of War 3 NAT Analytics

NAT Implications Client/Server Peer to Peer Server should have Open NAT Client can be any NAT type Peer to Peer All clients need Open NATs ~20% of players can’t play your game

Server Authoritative Clients only talk to Server Server replicates to Clients Data flow is Server->Clients RPCs are bidirectional Client / Server

C++ Replication

Basic Gameplay Classes Server Client GameMode GameState PlayerController One for each player PlayerState GameState PlayerController One for each local player PlayerState One for each player

Gameplay Classes GameMode GameState Rules for your game Replicated information about your GameMode

Gameplay Classes (cont) PlayerController Primary interaction with your GameMode PlayerState Replicated information about your player

Data Replication bReplicates UPROPERTY Macro Set as part of the Actor’s construction UPROPERTY Macro Replicated ReplicatedUsing GetLifetimeReplicatedProps Function Determines the set of properties for replication

bReplicates ACoolActor::ACoolActor(…) : Super( PCIP ) { {  bReplicates = true; }

Replicated Example /** number of kills */ UPROPERTY(Transient, Replicated) int32 NumKills;

ReplicatedUsing Example /** team number */ UPROPERTY(Transient, ReplicatedUsing=OnRep_TeamColor) int32 TeamNumber; void AShooterPlayerState::OnRep_TeamColor() { UpdateTeamColors(); }

GetLifetimeReplicatedProps Example void AShooterPlayerState::GetLifetimeReplicatedProps( TArray<FLifetimeProperty>& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); DOREPLIFETIME( AShooterPlayerState, TeamNumber ); DOREPLIFETIME( AShooterPlayerState, NumKills ); DOREPLIFETIME( AShooterPlayerState, NumDeaths ); }

Conditional Replication Property is only replicated when a condition is met Can reduce bandwidth consumed Done via a similar macro

Conditional Replication Example void AMyPlayerState::GetLifetimeReplicatedProps( TArray<FLifetimeProperty>& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); DOREPLIFETIME_CONDITION(AMyPlayerState, SomeOwnerOnlyVal, COND_OwnerOnly); }

Common Replication Conditions COND_InitialOnly This property will only attempt to send on the initial replication COND_OwnerOnly This property will only send to the actor's owner COND_SkipOwner This property send to every connection EXCEPT the owner COND_SimulatedOnly This property will only send to simulated actors COND_AutonomousOnly This property will only send to autonomous actors

Function Replication UFUNCTION Macro Reliable Unreliable Client Server NetMulticast WithValidation BlueprintAuthorityOnly BlueprintCosmetic

Reliable Function is guaranteed to be called Resent when an error is present Delayed when bandwidth is saturated

Reliable Example /** notify player about started match */ UFUNCTION(Reliable, Client) void ClientGameStarted(); void AShooterPlayerController::ClientGameStarted_Implementation() { bAllowGameActions = true; // Enable controls and disable cinematic mode now the game has started SetCinematicMode(false, false, true, true, true); AShooterHUD* ShooterHUD = GetShooterHUD(); if (ShooterHUD) ShooterHUD->SetMatchState(EShooterMatchState::Playing); ShooterHUD->ShowScoreboard(false); } …

Unreliable Function is attempted to be sent Not sent again when an error is present Skipped when bandwidth is saturated

Unreliable Example /** Replicated function sent by client to server - contains client movement and view info. */ UFUNCTION(Unreliable, Server, WithValidation) virtual void ServerMove(float TimeStamp, …); void UCharacterMovementComponent::ServerMove_Implementation( float TimeStamp, …) { … }

NetMulticast Sends to all clients Reliable or Unreliable applies here too

NetMulticast Example /** broadcast death to local clients */ UFUNCTION(Reliable, NetMulticast) void BroadcastDeath(…); void AShooterPlayerState::BroadcastDeath_Implementation(…) { for (auto It = GetWorld()->GetPlayerControllerIterator(); It; ++It) // all local players get death messages so they can update their huds. AShooterPlayerController* TestPC = Cast<AShooterPlayerController>(*It); if (TestPC && TestPC->IsLocalController()) TestPC->OnDeathMessage(KillerPlayerState, this, KillerDamageType); }

WithValidation Called before the target function Used to validate parameters of a function Meant to detect cheating/hacking Return value affects whether function is called false skips the call and kills the connection

WithValidation Example bool UCharacterMovementComponent::ServerMove_Validate( float TimeStamp, …) { bool bIsValidMove = false; // Perform move validation here return bIsValidMove; }

BlueprintAuthorityOnly UE4 all are functions are Simulated This is the opposite of UE3 Opt out via BlueprintAuthorityOnly

BlueprintAuthorityOnly Example UFUNCTION(BlueprintImplementableEvent, BlueprintAuthorityOnly, meta=(FriendlyName = "AnyDamage"), Category="Damage") virtual void ReceiveAnyDamage(float Damage, const UDamageType* DamageType, AController* InstigatedBy, AActor* DamageCauser);

Opposite of BlueprintAuthorityOnly BlueprintCosmetic Opposite of BlueprintAuthorityOnly Runs on the client not server An optimization to skip execution of slow cosmetic code on the server

Actor Relevancy Trades CPU time for network bandwidth Distance based Are these actors close enough Default implementation right now Line of sight Can these actors see each other UE3 default implementation Always relevant is an option Trades bandwidth for CPU time

Blueprint Replication

Actor Replication

Property Replication

Property Replication Notify

Function Replication

Low Level Details

Low Level Implementation UNetDriver UNetConnection UChannel UControlChannel UVoiceChannel UActorChannel

UNetDriver Contains a list of connections to Tick On client, one connection On Server, N connections

UNetConnection Contains a list of channels to replicate UChildConnection Used as an optimization for split-screen games

UChannel Objects Logical construct Accessed by ChannelID Routes data to the proper object Accessed by ChannelID Some channels have predefined IDs

UControlChannel Handles connection handshaking Processes object loading requests Deals with misc. non-gameplay communication

UVoiceChannel Sends and receives voice data Voice channel routes data to platform handler Voice data is platform dependent Voice data is sent as speaker ID and payload

UActorChannel Handles actor replication Includes any replicated components One actor channel for each replicated actor Actors are replicated by channel ID Dynamically assigned based upon array position

Voice Considerations Game can choose to support or not Platform can mute other players Player muted another outside of the game Players can mute other players Gameplay can mute players Team based, distance based, push to talk

Voice Functions UFUNCTION(Server, Reliable, WithValidation) virtual void ServerMutePlayer(FUniqueNetIdRepl PlayerId); UFUNCTION(Server, Reliable, WithValidation ) virtual void ServerUnmutePlayer(FUniqueNetIdRepl PlayerId); UFUNCTION(Reliable, Client) virtual void ClientMutePlayer(FUniqueNetIdRepl PlayerId); virtual void ClientUnmutePlayer(FUniqueNetIdRepl PlayerId); /** * Mutes a remote player on the server and then tells the client to mute * * @param PlayerNetId the remote player to mute */ void GameplayMutePlayer(const FUniqueNetIdRepl& PlayerNetId); * Unmutes a remote player on the server and then tells the client to unmute * @param PlayerNetId the remote player to unmute void GameplayUnmutePlayer(const FUniqueNetIdRepl& PlayerNetId);

Diagnostic Tools

Network Logging LogNet LogNetPlayerMovement LogNetTraffic Verbose information about the state of channels and connections LogNetPlayerMovement Detailed information about movement from clients and corrections from server LogNetTraffic Verbose information about data sent on a connection

Network Statistics Stat Net Stat Game Lists ping, channel count, in/out bytes, etc. Stat Game List of network processing information

Stat Net Example

Stat Game Example

Network Simulation Options PktLag Delays the sending of a packet by a N ms PktLagVariance Provides some randomness to the PktLag option PktLoss A percentage chance of not sending a packet

Network Simulation Options (cont) PktDup A percentage chance of sending duplicate packets PktOrder Sends packets out of order when enabled

Setting the Simulation Options Console Net PktLag=100 INI File [PacketSimulationSettings] PktLag=50 PktLagVariance=10 PktLoss=3 PktOrder=0 PktDup=10

Questions? Documentation, Tutorials, and Help at: AnswerHub: Engine Documentation: Official Forums: Community Wiki: YouTube Videos: Community IRC: Unreal Engine 4 Roadmap lmgtfy.com/?q=Unreal+engine+Trello+ http://answers.unrealengine.com http://docs.unrealengine.com http://forums.unrealengine.com http://wiki.unrealengine.com http://www.youtube.com/user/UnrealDevelopmentKit #unrealengine on FreeNode