ECE 650 Systems Programming & Engineering. Spring 2018

Similar documents
ECE 650 Systems Programming & Engineering. Spring 2018

Transport Layer (TCP/UDP)

ECE 650 Systems Programming & Engineering. Spring 2018

Interprocess Communication Mechanisms

shared storage These mechanisms have already been covered. examples: shared virtual memory message based signals

Outline. Inter-Process Communication. IPC across machines: Problems. CSCI 4061 Introduction to Operating Systems

Memory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length)

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Client Server Computing

QUIZ: Longest Matching Prefix

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~

Unix Network Programming Chapter 4. Elementary TCP Sockets 광운대학교컴퓨터과학과 정보통신연구실 석사과정안중현

Announcement (1) Due date for PA3 is changed (~ next week) PA4 will also be started in the next class. Not submitted. Not scored

Network Programming. Introduction to Sockets. Dr. Thaier Hayajneh. Process Layer. Network Layer. Berkeley API

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation

socketservertcl a Tcl extension for using SCM_RIGHTS By Shannon Noe - FlightAware

Chapter 6. What happens at the Transport Layer? Services provided Transport protocols UDP TCP Flow control Congestion control

TSIN02 - Internetworking

CONCURRENCY MODEL. UNIX Programming 2014 Fall by Euiseong Seo

EEC-682/782 Computer Networks I

IEMS 5780 / IERG 4080 Building and Deploying Scalable Machine Learning Services

Intro to LAN/WAN. Transport Layer

Lecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction!

Experiential Learning Workshop on Basics of Socket Programming

Network Implementation

??? Traceroute. app. app. host. host. Apps talk to other apps with no real idea of what is inside the network

Concurrent Server Using Selective Repeat Data Link Layer

CSCI Computer Networks

(Refer Slide Time: 1:09)

Socket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory

Operating Systems and Networks. Network Lecture 8: Transport Layer. Adrian Perrig Network Security Group ETH Zürich

Operating Systems and Networks. Network Lecture 8: Transport Layer. Where we are in the Course. Recall. Transport Layer Services.

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

CSC Systems Programming Fall Lecture - XXIII Final Review. Tevfik Koşar. Louisiana State University

Using make. Using Variables in Makefiles. Implicit Rules. Static vs Dynamic Libraries. Libraries. Tevfik Ko!ar

Introduction to Socket Programming

Lecture 24. Thursday, November 19 CS 375 UNIX System Programming - Lecture 24 1

TSIN02 - Internetworking

CSE 461 Module 10. Introduction to the Transport Layer

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

Sockets Sockets Communication domains

CS3600 SYSTEMS AND NETWORKS

Unix Network Programming

Transport layer Internet layer

A Client-Server Exchange

ECE 650 Systems Programming & Engineering. Spring 2018

Introduction to Client-Server Model

CSE 461 Connections. David Wetherall

L6: OSI Reference Model

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

TSIN02 - Internetworking

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms

OSI Transport Layer. Network Fundamentals Chapter 4. Version Cisco Systems, Inc. All rights reserved. Cisco Public 1

CSEP 561 Connections. David Wetherall

CN1047 INTRODUCTION TO COMPUTER NETWORKING CHAPTER 6 OSI MODEL TRANSPORT LAYER

Network and Security: Introduction

9th Slide Set Computer Networks

Global Employee Location Server

Lecture 20 Overview. Last Lecture. This Lecture. Next Lecture. Transport Control Protocol (1) Transport Control Protocol (2) Source: chapters 23, 24

CSCD 330 Network Programming

CS 326: Operating Systems. Networking. Lecture 17

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

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

Sockets and Parallel Computing. CS439: Principles of Computer Systems April 11, 2018

CSEP 561 Connections. David Wetherall

TSIN02 - Internetworking

Interprocess Communication Mechanisms

Operating Systems. 16. Networking. Paul Krzyzanowski. Rutgers University. Spring /6/ Paul Krzyzanowski

CS 640: Introduction to Computer Networks. Today s Lecture. Page 1

Client-server model The course that gives CMU its Zip! Network programming Nov 27, Using ports to identify services.

Inter-Process Communication. Disclaimer: some slides are adopted from the book authors slides with permission 1

Agenda. Before we start: Assignment #1. Routing in a wide area network. Protocols more concepts. Internetworking. Congestion control

Lecture 2-ter. 2. A communication example Managing a HTTP v1.0 connection. Managing a HTTP request. transport session. Step 1 - opening transport

JAVA SOCKET PROGRAMMING

Computer Systems Laboratory Sungkyunkwan University

We will cover in this order: 2.1, 2.7, 2.5, 2.4, 2.2

Chapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP 23.1

Communication. Overview

Announcements. No book chapter for this topic! Slides are posted online as usual Homework: Will be posted online Due 12/6

19: Networking. Networking Hardware. Mark Handley

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Computer Communication Networks Socket Programming

ECE 4400:427/527 - Computer Networks Spring 2017

Announcements. CS 5565 Network Architecture and Protocols. Outline for today. The Internet: nuts and bolts view. The Internet: nuts and bolts view

APPENDIX F THE TCP/IP PROTOCOL ARCHITECTURE

Networks and Their Abstractions. CS439: Principles of Computer Systems April 9, 2018

UDP and TCP. Introduction. So far we have studied some data link layer protocols such as PPP which are responsible for getting data

Lecture 2: Internet Structure

Interprocess Communication Mechanisms

System Programming. Introduction to computer networks

NT1210 Introduction to Networking. Unit 10

CSE 461 The Transport Layer

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

Concurrent Programming

CSEN 503 Introduction to Communication Networks. Mervat AbuElkheir Hana Medhat Ayman Dayf. ** Slides are attributed to J. F.

Transport Layer. Chapter 3: Transport Layer

EECS122 Communications Networks Socket Programming. Jörn Altmann

3.2 COMMUNICATION AND INTERNET TECHNOLOGIES

Transcription:

ECE 650 Systems Programming & Engineering Spring 2018 Programming with Network Sockets Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke)

Sockets We ve looked at shared memory vs. message passing All on a single system (meaning running under a single OS) What about communication across distributed processes? Running on different systems Assume systems are connected by a network (e.g. the internet) We can program using network sockets For creating connections and sending / receiving messages Often follows a client / server pattern We will assume basic network knowledge E.g. what is an IP address We will cover the networking stack in more detail in next lectures 2

Client-Server Model Common communication model in networked systems Client typically communicates with a server Server may connect to multiple clients at a time Client needs to know: Existence of a server providing the desired service Address (commonly IP address) of the server Server does not need to know either about the client 3

Client-Server Overview Client side Server side Client app User process Server app Application Layer Socket API Socket API TCP Kernel TCP Transport Layer IP IP Network Layer Ethernet Driver Ethernet Driver Data Link Layer Ethernet Network Client and Server communicating across Ethernet using TCP/IP 4

TCP Connection-oriented Service Transmission Control Protocol Designed for end-to-end byte stream over unreliable network Robust against failures and changing network properties TCP transport entity e.g. Library procedure(s), user processes, or a part of the kernel Manages TCP streams and interfaces to the IP layer Accepts user data streams from processes Breaks up into pieces not larger than 64 KB Often 1460 data bytes to fit in 1 Ethernet frame w/ IP + TCP headers Sends each piece separately as IP datagram Destination machine TCP entity reconstructs original byte stream Handles retransmissions & re-ordering Connection-oriented transport layer Provides error-free, reliable communication Can think of communication between two processes on different machines as just like UNIX pipes or fifos One process puts data in one end, other process takes it out 5

Network Sockets Network interface is identified by an IP address Or a hostname, which translates into an IP address E.g. 127.0.0.1, localhost or login.oit.duke.edu Interface has 65536 ports (0-65535) Processes attach to ports to use network services Port attachment is done with bind() operation Allows application-level multiplexing of network services E.g. SSH vs. Web vs. Email may all use different ports Many ports are standard (e.g. 80 for web server, 22 for SSH) You may have seen URLs like http://127.0.0.1:4444 127.0.0.1 is the IP, 4444 is the port 6

TCP Service Model TCP service setup as follows: Two endpoint processes create endpoints (sockets) Each socket has an address: IP address of host + 16-bit port API functions used to create & communicate on sockets Ports Numbers below 1024 called well-known ports Reserved for standard services, like FTP, HTTP, SMTP http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml But not all services usually used & active all at once Don t want them all active, just waiting for incoming connections Special daemon: inetd (Internet daemon) Attaches to multiple ports Waits for incoming connection (Still around, but less common nowadays) fork() s of the new, appropriate process to handle that connection 7

TCP Socket API TCP Server socket() TCP Client socket() connect() write() read() close() Establish TCP connection Data (request) Data (response) EOF notification bind() listen() accept() read() write() read() Blocks until connection from client Do work close() 8

Example UNIX TCP sockets Let s look at example code Here is a great reference for use of socket-related calls http://beej.us/guide/bgnet/ Primitive socket() bind() listen() accept() connect() send() recv() close() Meaning Create a new communication end point Attach a local address to a socket Announce willingness to accept connections; give queue size Block the caller until a connection attempt arrives Actively attempt to establish a connection Send some data over the connection Receive some data from the connection Release the connection 9

Server-Side Structure Often follows a common pattern to serve incoming requests pid_t pid; int listenfd, connfd; listenfd = socket(...); /***fill the socket address with server s well known port***/ bind(listenfd,...); listen(listenfd,...); for ( ; ; ) { connfd = accept(listenfd,...); /* blocking call */ if ( (pid = fork()) == 0 ) { /* create a child process to service */ close(listenfd); /* child closes listening socket */ /***process the request doing something using connfd ***/ /*... */ } } close(connfd); exit(0); /* child terminates } close(connfd); /*parent closes connected socket*/ 10