CSCE 313 Network Socket MP8 DUE: FRI MAY 5, 2017

Slides:



Advertisements
Similar presentations
Introduction to Sockets Jan Why do we need sockets? Provides an abstraction for interprocess communication.
Advertisements

Socket Programming CS3320 Fall 2010.
1 Socket Programming r What is a socket? r Using sockets m Types (Protocols) m Associated functions m Styles m We will look at using sockets in C.
1 Netcomm Recitation 1: Sockets Communication Networks Recitation 1.
1 Netcomm Sockets Communication Networks Recitation 1.
Tutorial 8 Socket Programming
CS 311 – Lecture 18 Outline IPC via Sockets – Server side socket() bind() accept() listen() – Client side connect() Lecture 181CS Operating Systems.
CSE/EE 461 Getting Started with Networking. Basic Concepts  A PROCESS is an executing program somewhere.  Eg, “./a.out”  A MESSAGE contains information.
ISP – 9 th Recitation Socket programming – Client side.
CS 360 – Spring 2007 Pacific University TCP section 6.5 (Read this section!) 27 Feb 2007.
UNIX Sockets COS 461 Precept 1. Clients and Servers Client program – Running on end host – Requests service – E.g., Web browser Server program – Running.
UNIX Sockets COS 461 Precept 1.
1 Socket Programming r What is a socket? r Using sockets m Types (Protocols) m Associated functions m Styles.
Socket Programming Based on tutorial prepared by EUISOK CHUNG CS3320 Spring2008.
CPSC 441 TUTORIAL – JANUARY 18, 2012 TA: MARYAM ELAHI INTRODUCTION TO SOCKET PROGRAMMING WITH C.
TCP Socket Programming. r An abstract interface provided to the application programmer  File descriptor, allows apps to read/write to the network r Allows.
ECE 4110 – Internetwork Programming Client-Server Model.
Operating Systems Chapter 9 Distributed Communication.
Network Programming Tutorial #9 CPSC 261. A socket is one end of a virtual communication channel Provides network connectivity to any other socket anywhere.
University of Calgary – CPSC 441.  UDP stands for User Datagram Protocol.  A protocol for the Transport Layer in the protocol Stack.  Alternative to.
CS345 Operating Systems Φροντιστήριο Άσκησης 2. Inter-process communication Exchange data among processes Methods –Signal –Pipe –Sockets.
9/12/2015B.R1 Socket Abstraction and Interprocess Communication B.Ramamurthy CSE421.
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
Chapter 2 Applications and Layered Architectures Sockets.
1 Socket Programming r What is a socket? r Using sockets m Types (Protocols) m Associated functions m Styles m We will look at using sockets in C.
CS x760 Computer Networks1 Socket Programming. CS 6760 Computer Networks2 Socket Programming  What is a socket?  Using sockets  Types (Protocols) ‏
Remote Shell CS230 Project #4 Assigned : Due date :
Computer Networks : TP1 Prof. Dr. Amine Berqia and Prof. Dr. Fernando Lobo {bamine,
1 Introduction to Computer Networks Ilam University By: Dr. Mozafar Bag Mohammadi Sockets.
Networking Tutorial Special Interest Group for Software Engineering Luke Rajlich.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
CPSC 441 TUTORIAL – FEB 13, 2012 TA: RUITNG ZHOU UDP REVIEW.
1 Computer Networks An Introduction to Computer Networks University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani Lecture 3: Sockets.
TELE202 Lecture 15 Socket programming 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (2) »Source: chapter 17 ¥This Lecture »Socket programming.
University of Calgary – CPSC 441.  A socket is an interface between the application and the network (the lower levels of the protocol stack)  The application.
UNIX Sockets COS 461 Precept 1. Socket and Process Communication The interface that the OS provides to its networking subsystem application layer transport.
CSE/EE 461 Getting Started with Networking. 2 Basic Concepts A PROCESS is an executing program somewhere. –Eg, “./a.out” A MESSAGE contains information.
Socket Programming Lab 1 1CS Computer Networks.
Sockets Socket = abstraction of the port concept: –Application programs request that the operating system create a socket when one is needed –O.S. returns.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: HsinYu Ha.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
1 Spring Semester 2008, Dept. of Computer Science, Technion Internet Networking recitation #7 Socket Programming.
@Yuan Xue CS 283Computer Networks Spring 2013 Instructor: Yuan Xue.
Socket Programming(1/2). Outline  1. Introduction to Network Programming  2. Network Architecture – Client/Server Model  3. TCP Socket Programming.
Socket Abstraction and Interprocess Communication
Socket Programming What is a socket? Using sockets Types (Protocols)
Sockets and Beginning Network Programming
UNIX Sockets COS 461 Precept 1.
Socket Programming in C
Introduction to Computer Networks
Interprocess Communication
Socket Programming What is a socket? Using sockets Types (Protocols)
Socket Abstraction and Interprocess Communication
Socket Programming in C
TCP Sockets Programming
Socket Abstraction and Interprocess Communication
Socket Abstraction and Inter-process Communication
Socket Abstraction and Interprocess Communication
Interprocess Communication
Socket Abstraction and Interprocess Communication
Socket Abstraction and Interprocess Communication
Socket Abstraction and Interprocess Communication
Socket Abstraction and Inter-process Communication
Socket Programming What is a socket? Using sockets Types (Protocols)
Socket Programming(1/2)
Socket Programming What is a socket? Using sockets Types (Protocols)
Socket Abstraction and Inter-process Communication
Internet Networking recitation #8
Socket Programming What is a socket? Using sockets Types (Protocols)
Sockets.
Presentation transcript:

CSCE 313 Network Socket MP8 DUE: FRI MAY 5, 2017 Wei Zhang Acknowledgment: Yi Cui, Wei Zhang, Prof. Tanzir Ahmed, CSCE-313

MP8 Use network sockets for data communication between clients and servers Take MP7, change request channel to network channel Implement network channel Modify data server to work with network channel Network channel 2 Data Server DATA REP Network channel 1 Network channel w … w worker threads

Your Task - Code Create your network request channel class to replace the original request channel that uses named pipes NetworkRequestChannel.h, NetworkRequestChannel.cpp Modify workers to use network channels Worker logic stays the same, but use new channels Updated client.cpp Modify data server to use network channels Updated dataserver.cpp Updated Makefile (as applicable)

Your Task - Report In addition, write a report with three key sections: Performance Evaluation (especially relative to MP7) Graph the response time versus the number of client requests Plot multiple curves by varying the server backlog Commentary on your program performance in context of the system you ran it on

Background: Network Socket Provides communication between different machines Need hostname/IP + port to uniquely identify the communication destination Can be used for inter-process communication within the same machine Use 127.0.0.1 for local host IP Port number must be some predefined number between clients and data servers Use a large port number (e.g. 10000 or higher) to ensure you do not conflict with any well known ports

Background: How it works Data server side Client side More details, see beej’s guide http://beej.us/guide/bgnet/output/html/multipage/index.html s = socket() // create socket bind(s, port) // bind socket to a specific port listen(s) // start listening for incoming connections for (;;) { new_s = accept(s) // when a new connection arrive, function returns a new socket // to be used for the new connection pthread_create(connection_handler) // create a new thread to handle connection } s = socket() // create socket connect(s, hostname, port) // connect to data server send requests via socket

System Call: socket() int s = socket(domain, type, protocol); s: socket descriptor, an integer (like a file-descriptor) domain: integer, communication domain e.g., PF_INET (IPv4 protocol) – typically used type: communication type SOCK_STREAM: reliable, 2-way, connection-based service SOCK_DGRAM: unreliable, connectionless, other values: need root permission, rarely used, or obsolete protocol: specifies protocol (see file /etc/protocols for a list of options) - usually set to 0

System Call: bind() associates and (can exclusively) reserves a port for use by the socket int status = bind(sockid, &addrport, size); status: error status, = -1 if bind failed sockid: integer, socket descriptor (i.e. the return value of socket(...)) addrport: struct sockaddr, the (IP) address and port of the machine size: the size (in bytes) of the addrport structure

System Call: listen() and accept() int status = listen(sock, queuelen); status: 0 if listening, -1 if error sock: integer, socket descriptor queuelen: integer, # of active clients that can “wait” for a connection listen is non-blocking: returns immediately int s = accept(sock, &name, &namelen); s: integer, the new socket (used for data-transfer) sock: integer, the orig. socket (being listened on) name: struct sockaddr, address of the client namelen: sizeof(name) accept is blocking: waits for connection before returning

System Call: connect() int status = connect(sock, &name, namelen); status: 0 if successful connect, -1 otherwise sock: integer, socket to be used in connection name: struct sockaddr: address and port of server namelen: integer, sizeof(name) connect is blocking

System Call: send() and recv() int count = send(sock, &buf, len, flags); count: # bytes transmitted (-1 if error) buf: char[], buffer to be transmitted len: integer, length of buffer (in bytes) to transmit flags: integer, special options, usually just 0 int count = recv(sock, &buf, len, flags); count: # bytes received (-1 if error) buf: void[], stores received bytes len: # bytes received Calls are blocking [returns only after data is sent (to socket buf) / received] You can use write/read instead

System Call: close() When finished using a socket, the socket should be closed: status = close(s); status: 0 if successful, -1 if error s: the file descriptor (socket being closed) Closing a socket closes a connection (for SOCK_STREAM) frees up the port used by the socket