CS118 Discussion Week 2. Taqi

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

COMP/ELEC 429/556 Introduction to Computer Networks

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

I/O Models. Kartik Gopalan

Project 1: A Web Server Called Liso

CISC2200 Threads Spring 2015

Chapter 2: Application layer

CSC209H Lecture 10. Dan Zingaro. March 18, 2015

Application Layer Introduction; HTTP; FTP

Application Layer: P2P File Distribution

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

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

Introduction to Socket Programming

CMSC 332 Computer Networks P2P and Sockets

Introduction to the Application Layer. Computer Networks Term B14

Information Network Systems The application layer. Stephan Sigg

CSC 4900 Computer Networks: P2P and Sockets

CPS 214: Computer Networks. Slides by Adolfo Rodriguez

Key Points for the Review

CONCURRENCY MODEL. UNIX Programming 2014 Fall by Euiseong Seo

Internet Applications and the Application Layer Material from Kurose and Ross, Chapter 2: The Application Layer

Chapter 2 Application Layer. Lecture 4: principles of network applications. Computer Networking: A Top Down Approach

Network Games Part II. Architecture of Network Game

CMPE 150/L : Introduction to Computer Networks. Chen Qian Computer Engineering UCSC Baskin Engineering Lecture 4

Group-A Assignment No. 6

CSCI 466 Midterm Networks Fall 2013

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

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

Redesde Computadores(RCOMP)

Computer Networks. Wenzhong Li. Nanjing University

CONCURRENT PROGRAMMING. Lecture 5

CSE 489/589 Recitation TCP Socket & Synchronous I/O Multiplexing

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

Application Layer: HTTP

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

Application-Layer Protocols Peer-to-Peer Systems, Media Streaming & Content Delivery Networks

Redes de Computadores (RCOMP)

Chapter 2. Application Layer

Last Lecture SMTP. SUNY at Buffalo; CSE 489/589 Modern Networking Concepts; Fall 2010; Instructor: Hung Q. Ngo 1

CSC 401 Data and Computer Communications Networks

10. I/O System Library

CSCE 463/612 Networks and Distributed Processing Spring 2018

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

Application Layer Protocols

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

Computer Networks - Midterm

ISA 563: Fundamentals of Systems Programming

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

Chapter 2 Application Layer

COMPUTER NETWORK. Homework #1. Due Date: March 29, 2017 in class

Global Employee Location Server

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

CSC358 Week 2. Adapted from slides by J.F. Kurose and K. W. Ross. All material copyright J.F Kurose and K.W. Ross, All Rights Reserved

Application Layer Network Layer

Client/Server Computing & Socket Programming

Chapter 2 Application Layer

Chapter 10: Application Layer CCENT Routing and Switching Introduction to Networks v6.0

BSD Sockets API. Mesut Ali ERGIN. Yeditepe University Information and Computer Science Department

Chapter 2: outline. 2.6 P2P applications 2.7 socket programming with UDP and TCP

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

Lecture 04: Application Layer (Part 01) Principles and the World Wide Web (HTTP) Dr. Anis Koubaa

Network Programming TDC 561

PLEASE READ CAREFULLY BEFORE YOU START

Internet Technology 2/18/2016

Computer Networks. HTTP and more. Jianping Pan Spring /20/17 CSC361 1

3.2 COMMUNICATION AND INTERNET TECHNOLOGIES

Paper solution Subject: Computer Networks (TE Computer pattern) Marks : 30 Date: 5/2/2015

Chapter 2. Application Layer. Chapter 2: Application Layer. Application layer - Overview. Some network apps. Creating a network appication

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

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

Electronic Mail. Three Components: SMTP SMTP. SMTP mail server. 1. User Agents. 2. Mail Servers. 3. SMTP protocol

Lecture 2: Applications and Application Programming

CC451 Computer Networks

Chapter 2: Application Layer. Chapter 2 Application Layer. Some network apps. Application architectures. Chapter 2: Application layer

CSE 333 Lecture non-blocking I/O and select

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

PLEASE READ CAREFULLY BEFORE YOU START

PLEASE READ CAREFULLY BEFORE YOU START

PLEASE READ CAREFULLY BEFORE YOU START

HTTP Reading: Section and COS 461: Computer Networks Spring 2013

Internet applications

School of Engineering Department of Computer and Communication Engineering Semester: Fall Course: CENG415 Communication Networks

EECS 3214: Computer Network Protocols and Applications

Review for Internet Introduction

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Application Layer -1- Network Tools

Lecture 7: Organizing Game Clients and Servers

CSE 333 Lecture fork, pthread_create, select

Proxy: Concurrency & Caches

ECE 650 Systems Programming & Engineering. Spring 2018

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

Chapter 10: Application Layer

CS348: Computer Networks (SMTP, POP3, IMAP4); FTP

Application Layer: OSI and TCP/IP Models

P2P Programming Assignment

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

Review of Previous Lecture

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

Lecture 05: Application Layer (Part 02) Domain Name System. Dr. Anis Koubaa

Transcription:

CS118 Discussion Week 2 Taqi

Outline Any Questions for Course Project 1? Socket Programming: Non-blocking mode Lecture Review: Application Layer Much of the other related stuff we will only discuss during the discussion.

Serve Multiple TCP Connections Simultaneously Problem: accept ( ) works under blocking mode by default Unless a new connection request arrives, accept ( ) will not return Perquisite: listen ( ) allows multiple TCP connection Three approaches fork ( ): each connection is served by a new process Easy to write, but expensive and hard to share data between processes POSIX pthread: each connection is served by a new thread Hard to maintain Non-block mode: use select ( )

What is select ( )? A monitor for multiple sockets (or file descriptors) Given a set of sockets, if any of them were ready to receive/send, select ( ) would exit int select (int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); numfds: the highest file descriptor plus one readfds, writefds, exceptfds: set of sockets timeout: timer for select to exit without any changes return when some sockets are ready, or timeout return value: the number of sockets that are ready

What is fd_set? A set of sockets (or file descriptors) that will be monitored by select ( ) Macros of set operation FD_SET(int fd, fd_set *set); //add fd to the set FD_CLR(int fd, fd_set *set); // remove fd from the set FD_ISSET(int fd, fd_set *set); // return if fd is in the set FD_ZERO(fd_set *set); // clear all entries in the set

How to use select ( )? Assume the server has created a socket sock, which is bound with server s IP address and port number fd_set active_fd_set; //set for holding sockets int new_sock; //socket representing client /* Initialize the set of active sockets */ FD_ZERO (&active_fd_set); FD_SET (sock, &active_fd_set); /*put sock to the set, s.t. we can monitor whether a new connection request arrives. This means you have to do accept(), etc.*/

How to use select ( )? while (1){ /* Block until some sockets are active. Let N is #sockets+1 in active_fd_set*/ if(select (sock+1, &active_fd_set, NULL, NULL, NULL)<0) {exit(-1);} /*errors*/ /* Now some sockets are active */ if(fd_isset(sock, &active_fd_set)) //new connection request { new_sock = accept (sock, (struct sockaddr*)&client_addr, sizeof(client_addr); FD_SET (new_sock, &active_fd_set); }

How to use select ( )? /* Decide whether client has sent data */ if (FD_ISSET(new_sock, &active_fd_set)) { /*receive and process data here*/ } }//end of while

How to use select ( )? /* Decide whether client has sent data */ if (FD_ISSET(new_sock, &active_fd_set)) { /*receive and process data here*/ } }//end of while

Application Layer Application Architectures Client-server model: Web (TCP), FTP (TCP), E-mail (TCP), DNS (TCP), RTP Peer-to-Peer (P2P): BitTorrent (TCP) Hybrid model: Skype (TCP&UDP), GTalk (TCP&UDP)

Application Layer HTTP: a stateless protocol on top of TCP HTTP is based on pull model Persistent HTTP V.S. Non-persistent HTTP How many TCP connections do we need to get one HTML-file with 5 embedded images? How many RTTs shall we need? Method Types: GET, HEAD, POST, PUT, DELETE, Conditional GET What if we want stateful service (e.g. online banking)? Cookie Web Caches (proxy server)

Application Layer FTP: separate control from data transmission SMTP: protocol for email exchange between email servers SMTP is based on push model Mail access protocol: POP, IMAP, HTTP between client and server P2P: no always-on server, peers are intermittently connected BitTorrent: tracker and torrent. Files are divided into multiple chunks.

Application Layer DNS: convert name (IP address) to IP address (name) Scalability via distribution and caching Who will use Iterative/recursive query? Why is DNS resolver needed?

Exercise Assume the cache is empty initially Host A queries www.ucla.edu, how many queries should resolver issue? After A s DNS query, host B queries www.mit.edu, how many queries should resolver issue?