Network Communication

Similar documents
Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013

Chapter 6. The Transport Layer. Transport Layer 3-1

STUDY OF SOCKET PROGRAMMING

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

TCP: Three-way handshake

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

Group-A Assignment No. 6

Unix Network Programming

EEC-484/584 Computer Networks

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

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

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

Oral. Total. Dated Sign (2) (5) (3) (2)

A. Basic Function Calls for Network Communications

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

Socket Programming for TCP and UDP

Socket Programming(2/2)

Systems software design NETWORK COMMUNICATIONS & RPC SYSTEMS

Programming Internet with Socket API. Hui Chen, Ph.D. Dept. of Engineering & Computer Science Virginia State University Petersburg, VA 23806


CSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?

CSE 124 Discussion Section Sockets Programming 10/10/17

Outline. Distributed Computing Systems. Socket Basics (1 of 2) Socket Basics (2 of 2) 3/28/2014

CS 640: Computer Networking

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.

Review. Preview. Closing a TCP Connection. Closing a TCP Connection. Port Numbers 11/27/2017. Packet Exchange for TCP Connection

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

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Elementary TCP Sockets

Introduction to Socket Programming

UNIT IV- SOCKETS Part A

MSc Integrated Electronics Networks Assignment. Investigation of TCP/IP Sockets and Ports. Gavin Cameron

UNIX Sockets. COS 461 Precept 1

Tutorial on Socket Programming

CS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm

Announcements. CS 5565 Network Architecture and Protocols. Queuing. Demultiplexing. Demultiplexing Issues (1) Demultiplexing Issues (2)

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

CS 428/528 Computer Networks Lecture 01. Yan Wang

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Sockets 15H2. Inshik Song

Socket Programming TCP UDP

What s an API? Do we need standardization?

UDP CONNECT TO A SERVER

The User Datagram Protocol

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

Outline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS

Communication. Sockets (Haviland Ch. 10)

CLIENT-SIDE PROGRAMMING

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

Networks. Practical Investigation of TCP/IP Ports and Sockets. Gavin Cameron

Programming with TCP/IP. Ram Dantu

The TCP Protocol Stack

Socket Programming. #In the name of Allah. Computer Engineering Department Sharif University of Technology CE443- Computer Networks

How do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs

Networked Applications: Sockets. Goals of Todayʼs Lecture. End System: Computer on the ʻNet. Client-server paradigm End systems Clients and servers

CSMC 412. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala Set 2. September 15 CMSC417 Set 2 1

CS321: Computer Networks Introduction to Application Layer

Computer Networks Prof. Ashok K. Agrawala

NT1210 Introduction to Networking. Unit 10

Introduction for SPI mapping Service Discovery Interoperability Testing. 20, Sep PWG Fumio Nagasaka

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

Networked Applications: Sockets. End System: Computer on the Net

Different Layers Lecture 21

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme

CS321: Computer Networks Socket Programming

Transport Layer. Chapter 3: Transport Layer

Chapter 4 Network Layer: The Data Plane. Part A. Computer Networking: A Top Down Approach

Application. Transport. Network. Link. Physical

CS Lecture 1 Review of Basic Protocols

Distributed Systems. 02. Networking. Paul Krzyzanowski. Rutgers University. Fall 2017

CSE 333 Section 8 - Client-Side Networking

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

Network Layer: Internet Protocol

CS 3516: Advanced Computer Networks

Introduction to the Application Layer. Computer Networks Term B14

CSc 450/550 Computer Networks Network Architectures & Client-Server Model

Department of Computer Science

Different Layers Lecture 20

CS 3516: Computer Networks

Introduction to Socket Programming

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

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

Goal and A sample Network App

Chapter 2 Applications and

Lecture 7. Berkeley Socket Programming

Transport layer. UDP: User Datagram Protocol [RFC 768] Review principles: Instantiation in the Internet UDP TCP

Basics. Once socket is configured, applica6ons. Socket is an interface between applica6on and network

CS 4390 Computer Networks. Transport Services and Protocols

Transport layer. Review principles: Instantiation in the Internet UDP TCP. Reliable data transfer Flow control Congestion control

CS4700/CS5700 Fundamentals of Computer Networking

Network Socket Programming - 2 BUPT/QMUL

Client software design

SOCKETS. COMP750 Distributed Systems

Content 1. SDK Library Overview API Library Introduction API Data Structure HAL Driver Function Type LIB

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

5. System Calls or Bust

Last time. Wireless link-layer. Introduction. Characteristics of wireless links wireless LANs networking. Cellular Internet access

CS 43: Computer Networks. 15: Transport Layer & UDP October 5, 2018

Transcription:

Network Communication

Processes communicating Process: program running within a host. q within same host, two processes communicate using inter- process communica6on (defined by OS). q processes in different hosts communicate by exchanging messages Client process: process that initiates communication Server process: process that waits to be contacted q Note: applications with P2P architectures have client processes & server processes 15

Sockets q process sends/receives messages to/from a socket q socket is a soeware communica6on channel q sending process sends into socket q sending process relies on transport infrastructure on other side of socket to deliver message to socket at receiving process host or server process socket TCP with buffers, variables controlled by app developer controlled by OS Internet host or server process socket TCP with buffers, variables API: (1) choice of transport protocol; (2) ability to fix a few parameters (lots more on this later) 16

Addressing processes q For a process to receive messages, it must have an iden6fier q A host has a unique 32- bit IP address Q: does the IP address of the host on which the process runs suffice for iden6fying the process? Answer: No, many processes can be running on same host q Identifier includes both the IP address and port numbers associated with the process on the host. q Example port numbers: q HTTP server: 80 q Mail server: 25 q More on this later 17

Internet Layer Model Applica'on (DHCP, DNS, FTP, HTTP, IRC, POP3, TELNET...) Transport (TCP, UDP, RTP...) Internet (IP) Data Link (ATM, Ethernet, FDDI, Frame Relay, PPP...) Physical Layer (Ethernet physical layer, ISDN, Modems, SONET...)

Packets Ethernet Header IP Header Protocol Header Applica'on Header Data Applica'on Transport Internet Data Link Physical Layer

App-layer protocol defines q Types of messages exchanged, q eg, request & response q Message Syntax q What fields in messages & how fields are delineated q Message Seman6cs q Meaning of informa6on in fields q Rules for when and how processes send & respond to messages Public-domain protocols: q defined in RFCs q allows for interoperability q eg, HTTP, SMTP Proprietary protocols: q eg, Skype 18

UDP: User Datagram Protocol [RFC 768] no frills, bare bones Internet transport protocol best effort service, UDP segments may be: lost delivered out of order to app connec6onless: no handshaking between UDP sender, receiver each UDP segment handled independently of others Why is there a UDP? r no connection establishment (which can add delay) r simple: no connection state at sender, receiver r small segment header r no congestion control: UDP can blast away as fast as desired r Higher level functionality can be added by applications Transport Layer 3-17

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 socket door point-to-point: one sender, one receiver reliable, in-order byte steam: no message boundaries pipelined: TCP congestion and flow control set window size send & receive buffers application writes data TCP send buffer segment application reads data TCP receive buffer socket door full duplex data: bi-directional data flow in same connection MSS: maximum segment size connection-oriented: handshaking (exchange of control msgs) init s sender, receiver state before data exchange flow controlled: sender will not overwhelm receiver Transport Layer 3-9

TCP Connection Management TCP server lifecycle TCP client lifecycle Transport Layer 3-10

IP Network layer Transport segment from sending to receiving host On sending side encapsulates segments into datagrams On recving side, delivers segments to transport layer Network layer protocols in every host, router Router examines header fields in all IP datagrams passing through it application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical application transport network data link physical Network Layer 4-11

IP datagram format IP protocol version number header length (bytes) type of data max number remaining hops (decremented at each router) upper layer protocol to deliver payload to how much overhead with TCP? 20 bytes of TCP 20 bytes of IP = 40 bytes + app layer overhead ver head. len 16-bit identifier time to live 32 bits type of service upper layer flgs length fragment offset header checksum 32 bit source IP address 32 bit destination IP address Options (if any) data (variable length, typically a TCP or UDP segment) total datagram length (bytes) for fragmentation/ reassembly E.g. timestamp, record route taken, specify list of routers to visit. Network Layer 4-12

SERVER STUFF

socket() Creates a Socket Descriptor #include <sys/types.h> #include <sys/socket.h> int socket(int domain, int type, int protocol); Parameter domain type Values PF_INET for IPv4 PF_INET6 for IPv6 SOCK_STREAM SOCK_DGRAM SOCK_SEQPACKET SOCK_RAW protocol IPPROTO_IP (defined as 0)

bind() Abach a socket to a port int bind(int sockfd, struct sockaddr *addr, int addrlen); memset(&my_addr, 0, sizeof(struct sockaddr)); my_addr.sin_family = AF_INET; my_addr.sin_port = htons(port); my_addr.sin_addr.s_addr =net_addr( 127.0.0.1");

listen() Set up a listening socket int listen(int sockfd, int backlog); backlog how many pending connec6ons are allowed to wait (OS max usually around 20, set to lower, ~10)

accept() Block and wait for connec6on to occur int accept(int sockfd, struct sockaddr *cliaddr, socklen_t *addrlen); Will return informa6on about the client through the structure (can be NULL)

send() and recv() int send(int sockfd, const void *msg, int len, int flags); int recv(int sockfd, void *buf, int len, unsigned int flags);

CLIENT STUFF

socket() Creates a Socket Descriptor #include <sys/types.h> #include <sys/socket.h> int socket(int domain, int type, int protocol); Parameter domain type Values PF_INET for IPv4 PF_INET6 for IPv6 SOCK_STREAM SOCK_DGRAM SOCK_SEQPACKET SOCK_RAW protocol IPPROTO_IP (defined as 0)

connect() Connect to a server located at some address and port int connect(int sockfd, struct sockaddr *serv_addr, int addrlen); memset(&my_addr, 0, sizeof(struct sockaddr)); my_addr.sin_family = AF_INET; my_addr.sin_port = htons(port); my_addr.sin_addr.s_addr = inet_addr( 127.0.0.1");

send() and recv() int send(int sockfd, const void *msg, int len, int flags); int recv(int sockfd, void *buf, int len, unsigned int flags);

CONNECTIONLESS COMMUNICATION

Datagram Send and Receive int sendto(int sockfd, const void *msg, int len, unsigned int flags, const struct sockaddr *to, socklen_t tolen); int recvfrom(int sockfd, void *buf, int len, unsigned int flags, struct sockaddr *from, int *fromlen);

DNS Domain Name Server Resolve a name to an IP address: hbp://www.cs.pib.edu - > 130.49.220.23

DNS #include <netdb.h> struct hostent *gethostbyname(const char *name); struct hostent { } char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses */ #define h_addr h_addr_list[0] /* for backward compatibility */