Multiplayer Computer Games Multiplayer Computer Games knowledge on - - PDF document

multiplayer computer games multiplayer computer games
SMART_READER_LITE
LIVE PREVIEW

Multiplayer Computer Games Multiplayer Computer Games knowledge on - - PDF document

Course Syllabus Course Syllabus credits: 4 cp (2 cu) credits: 4 cp (2 cu) prerequisites: prerequisites: Algorithms for Computer Games Algorithms for Computer Games Multiplayer Computer Games Multiplayer Computer


slide-1
SLIDE 1

1

Multiplayer Computer Games Multiplayer Computer Games

Jouni Smed Jouni Smed

Department of Information Technology, Department of Information Technology, University of Turku University of Turku 2005 2005

Course Syllabus Course Syllabus

  • credits: 4 cp (2 cu)

credits: 4 cp (2 cu)

  • prerequisites:

prerequisites:

  • Algorithms for Computer Games

Algorithms for Computer Games

  • knowledge on the basic concepts of computer networks

knowledge on the basic concepts of computer networks

  • teaching methods: lectures

teaching methods: lectures

  • Tuesdays 14

Tuesdays 14– –16 and Thursdays 12 16 and Thursdays 12– –14, Auditorium 14, Auditorium

  • from November 1 to December 15

from November 1 to December 15

  • assessment: examination only

assessment: examination only

  • course web page:

course web page: ht t p: / / st af f . ht t p: / / st af f . cs. ut u. f i / st a

  • cs. ut u. f i / st af f /

f f / ht t p: / / st af f . ht t p: / / st af f . cs. ut u. f i / st a

  • cs. ut u. f i / st af f /

f f / j ouni . sm ed/ m c j ouni . sm ed/ m cg/ g/ j ouni . sm ed/ m c j ouni . sm ed/ m cg/ g/

Examinations 1 (2) Examinations 1 (2)

  • examination dates

examination dates

1. 1.

January 16, 2006 January 16, 2006

2. 2.

February 13, 2006 February 13, 2006

3. 3.

March 2, 2006 March 2, 2006

  • check the exact times and places at

check the exact times and places at ht t p: / / www. i t ht t p: / / www. i t . ut u. f i / opet u . ut u. f i / opet us/ t ent i t / s/ t ent i t / ht t p: / / www. i t ht t p: / / www. i t . ut u. f i / opet u . ut u. f i / opet us/ t ent i t / s/ t ent i t /

  • if you are

if you are not not a student of University of Turku, you must a student of University of Turku, you must register to receive the credits register to receive the credits

  • further instructions are available at

further instructions are available at ht t ht t p: p: / / / / ht ht t p t p: / : / / w / www.

  • ww. t u

t ucs

  • cs. f

. f i / i / ed educ ucat i at i on

  • n/

ht t ht t p: p: / / / / ht ht t p t p: / : / / w / www.

  • ww. t u

t ucs

  • cs. f

. f i / i / ed educ ucat i at i on

  • n/

cou cour s r ses es/ p / par ar t i t i ci ci pat pat i n i ng_ g_co cour ur se ses.

  • s. php

php cou cour s r ses es/ p / par ar t i t i ci ci pat pat i n i ng_ g_co cour ur se ses.

  • s. php

php

Examinations 2 (2) Examinations 2 (2)

  • questions

questions

  • based on both lectures and lecture notes

based on both lectures and lecture notes

  • two questions, à 5 points

two questions, à 5 points

  • to pass the examination, at least 5 points (50%) are required

to pass the examination, at least 5 points (50%) are required

  • grade:

grade: g g = = ⎡ ⎡p p − 5 − 5⎤ ⎤

  • questions are in English, but you can answer in English or in Fi

questions are in English, but you can answer in English or in Finnish nnish

  • remember to enrol in time!

remember to enrol in time!

Outline of the Course Outline of the Course

8. 8. Communication layers Communication layers

  • physical platform

physical platform

  • logical platform

logical platform

  • networked application

networked application

9. 9. Compensating resourse Compensating resourse limitations limitations

  • aspects of compensation

aspects of compensation

  • protocol optimization

protocol optimization

  • dead reckoning

dead reckoning

  • local perception filters

local perception filters

  • synchronized simulation

synchronized simulation

  • area

area-

  • of
  • f-
  • interest filtering

interest filtering

10.

  • 10. Cheating prevention

Cheating prevention

  • attacking the hosts

attacking the hosts

  • tampering with network traffic

tampering with network traffic

  • look

look-

  • ahead cheating

ahead cheating

  • collusion

collusion

  • ffending other players
  • ffending other players

Guest Lecture Guest Lecture

  • Assoc. prof. Tomas Akenine
  • Assoc. prof. Tomas Akenine-
  • Möller (Dept. of CS, Lund

Möller (Dept. of CS, Lund University, Sweden): “Precomputed Local Radiance Transfer” University, Sweden): “Precomputed Local Radiance Transfer”

  • Auditorium, Thursday, November 3, 1 p.m.

Auditorium, Thursday, November 3, 1 p.m.

slide-2
SLIDE 2

2

§8 Communication Layers §8 Communication Layers

  • physical platform

physical platform

  • logical platform

logical platform

  • networked application

networked application

Classification Classification of

  • f

Shared Shared-

  • Space

Space Technologies 1 (2) Technologies 1 (2)

  • Physical reality

Physical reality

  • resides in the local, physical

resides in the local, physical world world

  • here and now

here and now

  • Telepresence

Telepresence

  • a real world location remote from

a real world location remote from the participant’s physical the participant’s physical location location

  • a

a remote remote-

  • controlled

controlled robot robot

Benford et al., 1998 Benford et al., 1998

Augmented Augmented Reality Reality Virtual Virtual Reality Reality Physical Physical Reality Reality Tele Tele-

  • presence

presence

Transportation Transportation Artificiality Artificiality local local remote remote synthetic synthetic physical physical

Classification of Classification of Shared Shared-

  • Space Technologies 2 (2)

Space Technologies 2 (2)

  • Augmented reality

Augmented reality

  • synthetic objects are overlaid on

synthetic objects are overlaid on the local environment the local environment

  • a head

a head-

  • up display (HUD)

up display (HUD)

  • Virtual reality

Virtual reality

  • the participants are immersed in

the participants are immersed in a remote, synthetic world a remote, synthetic world

  • multiplayer computer game

multiplayer computer game

Benford et al., 1998 Benford et al., 1998

Augmented Augmented Reality Reality Virtual Virtual Reality Reality Physical Physical Reality Reality Tele Tele-

  • presence

presence

Transportation Transportation Artificiality Artificiality local local remote remote synthetic synthetic physical physical

§8.1 Physical Platform §8.1 Physical Platform

  • resource limitations

resource limitations

  • bandwidth

bandwidth

  • latency

latency

  • processing power for handling the network traffic

processing power for handling the network traffic

  • transmission techniques and protocols

transmission techniques and protocols

  • unicasting, multicasting, broadcasting

unicasting, multicasting, broadcasting

  • Internet Protocol, TCP/IP, UDP/IP

Internet Protocol, TCP/IP, UDP/IP

Network Communication Network Communication

Bandwidth Bandwidth Protocol Protocol Latency Latency Reliability Reliability

Fundamentals of Data Transfer 1 (3) Fundamentals of Data Transfer 1 (3)

  • Network latency

Network latency

  • network delay

network delay

  • the amount of time required to transfer

the amount of time required to transfer a bit of data from one point to another a bit of data from one point to another

  • ne
  • ne of
  • f the biggest challenges:

the biggest challenges:

  • impacts directly the realism of the

impacts directly the realism of the game game experience experience

  • we

we cannot cannot much much to reduce it to reduce it

  • rigins
  • rigins
  • speed

speed-

  • of
  • f-
  • light delay

light delay

  • endpoint computers, network

endpoint computers, network hardware, operating systems hardware, operating systems

  • the network

the network itself, routers itself, routers

slide-3
SLIDE 3

3

Fundamentals of Data Transfer 2 (3) Fundamentals of Data Transfer 2 (3)

  • Network bandwidth

Network bandwidth

  • the rate

the rate at which at which the network can the network can deliver data to the destination host deliver data to the destination host (bits per second, (bits per second, bps) bps)

  • Network reliability

Network reliability

  • a measure of how much data is lost by

a measure of how much data is lost by the network during the journey from the network during the journey from source to destination host source to destination host

  • types of data loss:

types of data loss:

  • dropping: the

dropping: the data does not arrive data does not arrive

  • corruption: the

corruption: the content has been content has been changed changed

Fundamentals of Data Transfer 3 (3) Fundamentals of Data Transfer 3 (3)

  • Network protocol

Network protocol

  • a

a set of rules that two set of rules that two applications use to communicate applications use to communicate with each with each other

  • ther
  • packet formats

packet formats

  • understanding what the other

understanding what the other endpoint is saying endpoint is saying

  • packet semantics

packet semantics

  • what the recipient can

what the recipient can assume assume when it receives a packet when it receives a packet

  • error

error behaviour behaviour

  • what to do

what to do if (when) if (when) something something goes wrong goes wrong

Internet Protocol (IP) Internet Protocol (IP)

  • Low

Low-

  • level protocols used by hosts and routers

level protocols used by hosts and routers

  • Guides the packets from source to destination host

Guides the packets from source to destination host

  • Hides the transmission path

Hides the transmission path

  • phone lines, LANs, WANs, wireless radios, satellite links, carri

phone lines, LANs, WANs, wireless radios, satellite links, carrier er pigeons,… pigeons,…

  • Applications rarely use the IP directly but the protocols that a

Applications rarely use the IP directly but the protocols that are re written on top of IP written on top of IP

  • Transmission Control Protocol (TCP/IP)

Transmission Control Protocol (TCP/IP)

  • User Datagram Protocol (UDP/IP)

User Datagram Protocol (UDP/IP)

TCP versus UDP TCP versus UDP

Transmission Control Protocol Transmission Control Protocol (TCP/IP) (TCP/IP)

  • Point

Point-

  • to

to-

  • point connection

point connection

  • Reliable transmission using

Reliable transmission using acknowledgement and acknowledgement and retransmission retransmission

  • Stream

Stream-

  • based data semantics

based data semantics

  • Big

Big overhead

  • verhead
  • data checksums

data checksums

  • Hard to

Hard to ‘skip ‘skip ahead’ ahead’

User User Datagram Datagram Protocol Protocol (UDP/IP) (UDP/IP)

  • Lightweight data transmission

Lightweight data transmission

  • Differs from TCP

Differs from TCP

  • connectionless transmission

connectionless transmission

  • ‘best

‘best-

  • efforts’

efforts’ delivery delivery

  • packet

packet-

  • based data semantics

based data semantics

  • Packets are easy to process

Packets are easy to process

  • Transmission and receiving

Transmission and receiving immediate immediate

  • No connection information for

No connection information for each host in the operating system each host in the operating system

  • Packet loss can be

Packet loss can be handled handled

The BSD Sockets Architecture The BSD Sockets Architecture

  • A

A socket is a software socket is a software representation of the endpoint to a representation of the endpoint to a communication channel communication channel

  • Reliable/unreliable

Reliable/unreliable communication, single/multiple communication, single/multiple destinations, etc. destinations, etc.

  • Includes several pieces of

Includes several pieces of information, information, such as such as

  • protocol

protocol

  • destination host and port

destination host and port

  • source host and port

source host and port BSD = Berkeley Software Distribution BSD = Berkeley Software Distribution Ports Ports Sockets Sockets

Application 2 Application 2 Application 1 Application 1 TCP TCP UDP UDP

Other Other protocols protocols

Internet Protocol Internet Protocol

Application B Application B Application A Application A TCP TCP UDP UDP

Other Other protocols protocols

Internet Protocol Internet Protocol

Sockets in Java Sockets in Java

  • Networking related classes are in the package

Networking related classes are in the package j ava. net j ava. net

  • IP addresses are handled with the

IP addresses are handled with the I net Addr ess I net Addr ess class class

  • Creation (note: no constructor):

Creation (note: no constructor): I net Addr ess I net Addr ess addr ess addr ess = = I net Addr ess I net Addr ess. get ByNam e( . get ByNam e( address address) ; ) ;

  • Parameter

Parameter address address

  • in DNS format

in DNS format ( (" st af f . cs. ut u. f i " " st af f . cs. ut u. f i " ) )

  • as an IP number

as an IP number ( (" 139. 232. 75. 8" " 139. 232. 75. 8" ) )

  • nul l

nul l nul l nul l (= (= " l ocal host " " l ocal host " = = " " 127. 0. 0. 1"

  • 127. 0. 0. 1" )

)

  • Port numbers 1

Port numbers 1– –1024 are reserved 1024 are reserved

  • Socket types:

Socket types:

  • Ser ver Socket

Ser ver Socket : handles connection requests directed to a given port : handles connection requests directed to a given port

  • Socket

Socket : actual socket which handles the communication : actual socket which handles the communication

slide-4
SLIDE 4

4

Socket Example: The Code Socket Example: The Code

Server Server

Ser ver Socket Ser ver Socket s = s = ne new ne new Ser ver Socket Ser ver Socket ( PO RT) ; ( PO RT) ; t r y t r y t r y t r y { { Socket Socket socket socket = s. accept ( ) ; = s. accept ( ) ; t r y t r y t r y t r y { { / / / / Use t he socket . Use t he socket . } } cat ch cat ch cat ch cat ch ( ( I O Except i on I O Except i on e) { e) { / / Tr ansf er f ai l ed. / / Tr ansf er f ai l ed. } } f i nal l y f i nal l y f i nal l y f i nal l y { { socket . cl ose( ) ; socket . cl ose( ) ; } } } } cat ch cat ch cat ch cat ch ( ( I O Except i on I O Except i on e) { e) { / / Connect i on f ai l ed. / / Connect i on f ai l ed. } } f i nal l y f i nal l y f i nal l y f i nal l y { {

  • s. cl ose( ) ;
  • s. cl ose( ) ;

} }

Client Client

t r y t r y t r y t r y { { Socket Socket socket = socket = new new new new Socket Socket ( addr ess, PO RT) ; ( addr ess, PO RT) ; t r t r y t r t r y { { / / Use t he socket . / / Use t he socket . } } cat ch cat ch cat ch cat ch ( ( I O Except i on I O Except i on e) { e) { / / Tr ansf er f ai l ed. / / Tr ansf er f ai l ed. } } f i nal l y f i nal l y f i nal l y f i nal l y { { socket . cl ose( ) ; socket . cl ose( ) ; } } } } cat ch cat ch cat ch cat ch ( ( I O Except i on I O Except i on e) { e) { / / Connect i on f ai l ed. / / Connect i on f ai l ed. } }

Socket Example: What Happens Socket Example: What Happens

  • Server creates

Server creates Ser ver Socket Ser ver Socket which begins to listen to the given which begins to listen to the given port port

  • The execution halts in the

The execution halts in the accept accept method call, until there is a method call, until there is a connection request connection request

  • Client creates

Client creates Socket Socket with the with the server’s address and the port number server’s address and the port number

  • f the server socket
  • f the server socket
  • Client’s socket sends a connection

Client’s socket sends a connection request request

  • Server socket answers the reqest by

Server socket answers the reqest by creating creating Socket Socket to to any any available port available port

  • Server socket sends the port number

Server socket sends the port number

  • f the new socket to the client
  • f the new socket to the client
  • Client’s socket connects to the new

Client’s socket connects to the new socket socket

  • In the client, the socket’s constructor

In the client, the socket’s constructor finishes finishes

  • In the server, the

In the server, the accept accept method method returns the new socket. returns the new socket.

server server

port port

client client

connection connection request request

server server

port port

client client

connection connection port port port port

Using Streams with Sockets Using Streams with Sockets

  • Input stream:

Input stream: Buf f er edReader Buf f er edReader i n = i n = new new new new Buf f er edReader Buf f er edReader ( ( new new new new I nput St r eam Reader I nput St r eam Reader ( ( socket . socket . get I nput St r ea get I nput St r eam ( ) m ( ) socket . socket . get I nput St r ea get I nput St r eam ( ) m ( ) ) ) ; ) ) ;

  • Output stream:

Output stream: Pr i nt W r i t er Pr i nt W r i t er

  • ut =
  • ut =

new new new new Pr i nt W r i t er Pr i nt W r i t er ( ( new new new new Buf f er edW r i t er Buf f er edW r i t er ( ( new new new new O ut put St r eam W r i t er O ut put St r eam W r i t er ( ( socket . socket . get O ut put St r e get O ut put St r eam ( ) am ( ) socket . socket . get O ut put St r e get O ut put St r eam ( ) am ( ) ) ) , ) ) , t r ue t r ue t r ue t r ue) ; ) ;

  • Reading and writing as normal:

Reading and writing as normal:

  • ut . pr i nt l n( " f oo" ) ;
  • ut . pr i nt l n( " f oo" ) ;
  • St r i ng

St r i ng s = i n. r eadLi ne( ) ; s = i n. r eadLi ne( ) ;

  • Streams use TCP, which is reliable but slow

Streams use TCP, which is reliable but slow

UDP and Datagrams in Java UDP and Datagrams in Java

  • Dat agr am

Socket Dat agr am Socket can both send and receive packets can both send and receive packets

  • no server sockets because there is no need to establish a connec

no server sockets because there is no need to establish a connection tion

  • Dat agr am

Packet Dat agr am Packet includes all the data to be sent/received includes all the data to be sent/received

  • maximum size 64 kB

maximum size 64 kB

  • Constructing a receiving packet:

Constructing a receiving packet: by byt e t e by byt e t e[ ] buf f er = [ ] buf f er = ne new ne new by byt e t e by byt e t e[ CAPACI TY] ; [ CAPACI TY] ; Dat agr am Packet Dat agr am Packet dp1 = dp1 = new new new new Dat agr am Packet Dat agr am Packet ( buf f er , CAPACI TY) ; ( buf f er , CAPACI TY) ;

  • Constructing a packet to send:

Constructing a packet to send: by byt e t e by byt e t e[ ] m essage; [ ] m essage; / / The byt es t o send. / / The byt es t o send. Dat agr am Packet Dat agr am Packet dp2 = dp2 = new new new new Dat agr am Packet Dat agr am Packet ( m essage, m

  • essage. l engt h,

( m essage, m

  • essage. l engt h,

addr ess, por t ) ; addr ess, por t ) ;

Datagram Example Datagram Example

t r y t r y t r y t r y { { socket = socket = new new new new Dat agr am Socket Dat agr am Socket ( PO RT) ; ( PO RT) ; socket . r ecei ve( dp1) ; socket . r ecei ve( dp1) ; socket . send( dp2) ; socket . send( dp2) ; } } cat ch cat ch cat ch cat ch ( ( Socket Except i on Socket Except i on e) { e) { / / Coul d not open t he socket . / / Coul d not open t he socket . } } cat ch cat ch cat ch cat ch ( ( I O Except i on I O Except i on e) { e) { / / Pr obl em s wi t h com m uni cat i on. / / Pr obl em s wi t h com m uni cat i on. } } f i nal l y f i nal l y f i nal l y f i nal l y { { socket . cl ose( ) ; socket . cl ose( ) ; } }

Datagram Contents Datagram Contents

  • Sender’s address:

Sender’s address: I net Addr ess I net Addr ess addr = dp. get Addr ess( ) ; addr = dp. get Addr ess( ) ;

  • Sender’s port:

Sender’s port: i nt i nt i nt i nt por t = dp. get Por t ( ) ; por t = dp. get Por t ( ) ;

  • Packet payload size:

Packet payload size: i nt i nt i nt i nt si ze si ze = dp. get Lengt h( ) ; = dp. get Lengt h( ) ;

  • Packet payload data:

Packet payload data: byt e byt e byt e byt e[ ] [ ] dat a dat a = = dp. get Dat a( ) ;

  • dp. get Dat a( ) ;