Network Games Part II. Architecture of Network Game

Similar documents
COMP/ELEC 429/556 Introduction to Computer Networks

I/O Models. Kartik Gopalan

Assignment 2 Group 5 Simon Gerber Systems Group Dept. Computer Science ETH Zurich - Switzerland

Any of the descriptors in the set {1, 4} have an exception condition pending

CSC209H Lecture 10. Dan Zingaro. March 18, 2015

I/O Multiplexing. Dec 2009

CONCURRENCY MODEL. UNIX Programming 2014 Fall by Euiseong Seo

Today: VM wrap-up Select (if time) Course wrap-up Final Evaluations

CSE 333 Lecture non-blocking I/O and select

CS118 Discussion 1A, Week 3. Zengwen Yuan Dodd Hall 78, Friday 10:00 11:50 a.m.

CS118 Discussion Week 2. Taqi

10. I/O System Library

December 8, epoll: asynchronous I/O on Linux. Pierre-Marie de Rodat. Synchronous/asynch. epoll vs select and poll

ECE 650 Systems Programming & Engineering. Spring 2018

Windows Socket I/O Multiplexing. Prof. Lin Weiguo Copyleft 2009~2017 School of Computing, CUC

Introduction to Socket Programming

Concurrent Programming. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ISA 563: Fundamentals of Systems Programming

Architecture and Design of Distributed Dependable Systems TI-ARDI. POSA2: Reactor Architectural Pattern

Group-A Assignment No. 6

CSE 333 Lecture fork, pthread_create, select

CISC2200 Threads Spring 2015

Global Employee Location Server

PROCESSES AND THREADS THREADING MODELS. CS124 Operating Systems Winter , Lecture 8

Topics for this Week

Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar

NETWORK AND SYSTEM PROGRAMMING. I/O Multiplexing: select and poll function

CPS 214: Computer Networks. Slides by Adolfo Rodriguez

CONCURRENT PROGRAMMING. Lecture 5

Εργαστήριο 9 I/O Multiplexing

Project 1: A Web Server Called Liso

SOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles

CS 431 Introduction to Computer Systems Solutions Mid semester exam 2005

We start by looking at what s known as event-based programming: we write code that responds to events coming from a number of sources.

Project 3. Reliable Data Transfer over UDP. NTU CSIE Computer Networks 2011 Spring

Network Programming TDC 561

Advcan QNX Driver User Manual V1.02

CSE 43: Computer Networks Structure, Threading, and Blocking. Kevin Webb Swarthmore College September 14, 2017

Concurrent Server Design Multiple- vs. Single-Thread

UNIT III - APPLICATION DEVELOPMENT. TCP Echo Server

The User Datagram Protocol

Network programming(ii) Lenuta Alboaie

COMP 2355 Introduction to Systems Programming

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

1. BACKGROUND AND RATIONALE Background Rationale Previous Work 2 2. NARRATIVE 4

Socket Programming. What is a socket? Using sockets. Types (Protocols) Associated functions Styles

Problem Set: Processes

UDP CONNECT TO A SERVER

Redes de Computadores (RCOMP)

Lecture 8: Other IPC Mechanisms. CSC 469H1F Fall 2006 Angela Demke Brown

Topics. Lecture 8: Other IPC Mechanisms. Socket IPC. Unix Communication

Version Control with Git and What is there in Project 1 PALLABI GHOSH COMPUTER NETWORKS RECITATION 1

Lecture 5 Overview! Last Lecture! This Lecture! Next Lecture! I/O multiplexing! Source: Chapter 6 of Stevens book!

CS631 - Advanced Programming in the UNIX Environment Interprocess Communication II

CS 33. More Network Programming. CS33 Intro to Computer Systems XXXI 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

A Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University

Asynchronous Events on Linux

Communication Networks ( ) / Spring 2011 The Blavatnik School of Computer Science, Tel-Aviv University. Allon Wagner

Communication Networks ( ) / Fall 2013 The Blavatnik School of Computer Science, Tel-Aviv University

G Honors Operating Systems

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

Concurrent Servers Dec 2, 2009"

"#' %#& Lecture 7: Organizing Game Clients and Servers. Socket: Network communication endpoints. IP address: IP-level name of a machine

Multiprogramming. Evolution of OS. Today. Comp 104: Operating Systems Concepts 28/01/2013. Processes Management Scheduling & Resource Allocation

Problem Set: Processes

9/13/2007. Motivations for Sockets What s in a Socket? Working g with Sockets Concurrent Network Applications Software Engineering for Project 1

CS307 Operating Systems Processes

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State

Redesde Computadores(RCOMP)

COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 3: Process. Zhi Wang Florida State University

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

Lecture 7: Organizing Game Clients and Servers

Processes and Threads

The Big Picture So Far. Chapter 4: Processes

Chapter 3: Process Concept

Chapter 3: Process Concept

33. Event-based Concurrency

Section 3: File I/O, JSON, Generics. Meghan Cowan

Appendix B: NET_CON Source Code

Simple network applications using sockets (BSD and WinSock) Revision 1 Copyright Clifford Slocombe

call connect call read call connect ret connect call fgets Client 2 blocks waiting to complete its connection request until after lunch!

Chapter 3: Process Concept

CSC209 Review. Yeah! We made it!

Processes COMPSCI 386

Chapter 3: Processes. Operating System Concepts 9 th Edition

Chapter 3: Process-Concept. Operating System Concepts 8 th Edition,

Chapter 3: Processes. Operating System Concepts Essentials 8 th Edition

Introduction to Berkeley Sockets

Ports under 1024 are often considered special, and usually require special OS privileges to use.

Introduction to Berkeley Sockets

What s an API? Do we need standardization?

Introduction to Berkeley Sockets

CS 31: Intro to Systems Threading & Parallel Applications. Kevin Webb Swarthmore College November 27, 2018

More Network Programming

Lecture 16/17: Distributed Shared Memory. CSC 469H1F Fall 2006 Angela Demke Brown

Contents. PA1 review and introduction to PA2. IPC (Inter-Process Communication) Exercise. I/O redirection Pipes FIFOs

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 3: Process. Zhi Wang Florida State University

The Big Picture So Far. Chapter 4: Processes

First Midterm Exam September 28, 2017 CS162 Operating Systems

Transcription:

Network Games Part II Doron Nussbaum Network Games Part II COMP 5900 1 Architecture of Network Game Client Server Peer to Peer Player 1 Player 2 Player 1 Player 2 Server Player 5 Player 3 Player 5 Player 3 Player 4 Player 4 Doron Nussbaum Network Games Part II COMP 5900 2

Network Games Design Key issue is the communication and its side effect Latency Accuracy Synchronization Race conditions Other issues Difference in HW Heterogeneous systems What are the characteristics of the communication? Doron Nussbaum Network Games Part II COMP 5900 3 Network Games Design Key issue is the communication and its side effect Latency Accuracy Synchronization Race conditions Other issues Difference in HW Heterogeneous systems What are the characteristics of the communication? Doron Nussbaum Network Games Part II COMP 5900 4

Comm. Behaviour of Architecture Peer to Peer O(n 2 ) messages Client Server O(n)-O(n 2 ) messages depending on the implementation O(n) implementation imposes tradeoffs Doron Nussbaum Network Games Part II COMP 5900 5 Comm. Behaviour of Architecture Peer to Peer O(n 2 ) messages Client Server O(n)-O(n 2 ) messages depending on the implementation O(n) implementation imposes tradeoffs Which one is better? Which one would have more latency? Doron Nussbaum Network Games Part II COMP 5900 6

What Can the Network Support? d f n - number of of connections C - message size (packet size) - frequency (in Hz) - network capacity d -1500B= 12,000b f -5Hz n -? C -100MB= 10 8 d * f * n C 12,000*5* n 10 n = 8 10 5*12,000 8 = 1,666connections Doron Nussbaum Network Games Part II COMP 5900 7 Architecture of Network Game Player 1 Player 2 Player 1 Player 2 Server Player 5 Player 3 Player 5 Player 3 Player 4 Player 4 Client Server ~1600 players? Peer to Peer 57 players Doron Nussbaum Network Games Part II COMP 5900 8

Message sending pattern How many messages are sent and received? How much work does each processor handle? What are the tradeoffs? Doron Nussbaum Network Games Part II COMP 5900 9 Client Server Pee to Peer At each cycle At each cycle For each received message sends n messages Receive n messages Send n message Or Receive n messages (one from each) send n large messages Doron Nussbaum Network Games Part II COMP 5900 10

Sending a message T T T T T m m = T preprocess transmit postprocess preprocess + T transmit + T - time of message cycle postprocess - time to prepare the message to be sent - time of transmit the message - time to process the message by receiever In our case we are interested in the sending part T m = T preprocess + T transmit Doron Nussbaum Network Games Part II COMP 5900 11 What does it mean? Player 1 Player 2 Player 1 Player 2 Server Player 5 Player 3 Player 5 Player 3 Player 4 Player 4 Client Server Peer to Peer Doron Nussbaum Network Games Part II COMP 5900 12

Server Farm Communication Doron Nussbaum Network Games Part II COMP 5900 13 Server Farm A hierarchical solution One network at the servers level One network at the server/player level Commnication can be overlapped Doron Nussbaum Network Games Part II COMP 5900 14

Multitasking What is multitasking? Why? What to multitask? How to multitask? Doron Nussbaum Network Games Part II COMP 5900 15 What is multitasking? Why? Multitasking is performing two or more tasks simultaneously Purpose Imitate real life Often one does more than one job at the same time Working on a project/assignments for two or more courses Achieve more Write an introduction to a lab report while the experiment is on. Take advantage of unused time Computer Multitasking is achieved by Time slices By using two or more processors/cores Doron Nussbaum Network Games Part II COMP 5900 16

How is multitasking achieved? Providing capabilities to Start multiple program at the same time Ability to switch between the programs If needed, enabling programs to interact with each other Multitasking OS An OS that enables multitasking on HW with one or more processors/cores Doron Nussbaum Network Games Part II COMP 5900 17 Processes and Threads Process A process is a self contained program that is allocated system resources for its operation. Consume resources - the system manage processors as a whole (e.g., memory, program counter and file descriptors). Relatively expensive Threads A thread is a distinct execution path within the processor Imitation of the OS multitasking within a processor Doron Nussbaum Network Games Part II COMP 5900 18

How is multitasking achieved? process single thread process single thread process multi threads main main main IPC IPC Doron Nussbaum Network Games Part II COMP 5900 19 How to multitask? Issues coordination Between tasks (race condition) Accessing data Doron Nussbaum Network Games Part II COMP 5900 20

Task: Send/receive Messages Purpose Send messages to all players Receive messages from other players What needs to be done? Service many players (nodes) Interact with internal components Doron Nussbaum Network Games Part II COMP 5900 21 Servicing many clients Must assess the cohesion of tasks None!! Wait request response The show must go on!!! One cannot block and wait? Doron Nussbaum Network Games Part II COMP 5900 22

What must to be done? Doron Nussbaum Network Games Part II COMP 5900 23 Doron Nussbaum Network Games Part II COMP 5900 24

Externally Use IPC sockets Internally User threads Doron Nussbaum Network Games Part II COMP 5900 25 Non Blocking Sockets Instruct sockets not to block u_long imode; imode = 1; // non blocking is enabled ioctlsocket(sockfd, FIONBIO, &imode); Doron Nussbaum Network Games Part II COMP 5900 26

Non Blocking Sockets collect sockets Listen to connect messages Add socket to a list of sockets to service clientaddlen = sizeof(clientadd); clientsock = accept(sockfd, (struct sockaddr *) &clientadd, &clientaddlen); fd_set master_fds; typedef struct fd_set { u_int fd_count; SOCKET fd_array[fd_setsize]; } fd_set; if (clientsock == INVALID_SOCKET) { // error rc = GetLastError( ); if (rc == WSAEWOULDBLOCK) { // that's ok. There is nothing to accept Sleep (30); // sleep for a while if one can afford it } else { // error. } } if (clientsock!= INVALID_SOCKET) { if (FD_ISSET(clientSock, &master_fds) == 0) { // socket is not in the set FD_SET(clientSock, &master_fds); Doron Nussbaum Network } Games Part II COMP 5900 27 } Non Blocking Sockets Service requests Get message Process message If needed send reply on one or more // master_fds contains all sockets fd_set read_fds; read_fds = master_fds; rc = select(0,&read_fds,null,null,&timeout); for (i = i < rc; i++) { // read information from the socket int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const struct timeval* timeout ); nfds Ignored. (compatibility) readfds set of sockets to be checked for readability. (can be NULL) exceptfds set of sockets to be checked for errors. (can be NULL) timeout writefds Maximum time for select to wait, set of sockets to be (format TIMEVAL) checked for writability. Doron Nussbaum Network Games (can Part be NULL) II COMP 5900 28

Sockets descriptors sets Four macros FD_CLR(s, *set) removes the descriptor s from set. FD_ISSET(s, *set) nonzero if s is a member of the set else zero. FD_SET(s, *set) adds descriptor s to set. FD_ZERO(*set) Initializes the set to the null set. Note that FD_ISSET leaves only the sockets that are active in the set. Use a master_list and copy it. One can change the number of sockets that are available by redefining FD_SETSIZE Doron Nussbaum Network Games Part II COMP 5900 29