CSE/EE 461 Getting Started with Networking. Basic Concepts  A PROCESS is an executing program somewhere.  Eg, “./a.out”  A MESSAGE contains information.

Slides:



Advertisements
Similar presentations
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Socket Programming 0.
Advertisements

Socket Programming Application Programming Interface.
Networks: TCP/IP Socket Calls1 Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Socket Programming.
Tutorial 8 Socket Programming
UNIX Sockets COS 461 Precept 1. Clients and Servers Client program – Running on end host – Requests service – E.g., Web browser Server program – Running.
1 Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Yukun Zhu (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian,
UNIX Sockets COS 461 Precept 1.
TCP Socket Programming. r An abstract interface provided to the application programmer  File descriptor, allows apps to read/write to the network r Allows.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
ECE 4110 – Internetwork Programming Client-Server Model.
Elementary TCP Sockets
Socket Programming. Introduction Sockets are a protocol independent method of creating a connection between processes. Sockets can be either – Connection.
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.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
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.
The Socket Interface Chapter 22. Introduction This chapter reviews one example of an Application Program Interface (API) which is the interface between.
Remote Shell CS230 Project #4 Assigned : Due date :
Page 1 Jan 5, 1998 CMPN 369 CPSC441 Sockets Module Sockets Application Programming Interface (API)
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.
Distributed Computing A Programmer’s Perspective.
UNIX Sockets COS 461 Precept 1. Socket and Process Communication The interface that the OS provides to its networking subsystem application layer transport.
CSE 331: Introduction to Networks and Security Fall 2000 Instructor: Carl A. Gunter Slide Set 5.
CSE/EE 461 Getting Started with Networking. 2 Basic Concepts A PROCESS is an executing program somewhere. –Eg, “./a.out” A MESSAGE contains information.
Chapter 27 Socket API Interface The interface between an application program and the communication protocols in an operating system is known as the Application.
CS 6401 Introduction to Computer Networks 09/21/2010 Outline - UNIX sockets - A simple client-server program - Project 1 - LAN bridges and learning.
Socket Programming.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
CSCI 330 UNIX and Network Programming Unit XV: Transmission Control Protocol.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: HsinYu Ha.
Introduction to Sockets
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Review: – Why layer architecture? – peer entities – Protocol and service interface – Connection-oriented/connectionless service – Reliable/unreliable service.
Socket Programming. Computer Science, FSU2 Interprocess Communication Within a single system – Pipes, FIFOs – Message Queues – Semaphores, Shared Memory.
UNIX Sockets Outline UNIX sockets CS 640.
Inter-Process Communication 9.1 Unix Sockets You may regard a socket as being a communication endpoint. –For two processes to communicate, both must create.
1 Spring Semester 2008, Dept. of Computer Science, Technion Internet Networking recitation #7 Socket Programming.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
Lecture 3 TCP and UDP Sockets CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
1 Network Communications A Brief Introduction. 2 Network Communications.
1 K. Salah Application Layer Module K. Salah Network layer duties.
1 Socket Interface. 2 Client-Server Architecture The client is the one who speaks first Typical client-server situations  Client and server on the same.
Sockets Intro to Network Programming. Before the internet... Early computers were entirely isolated No Internet No network No model No external communications.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
SOCKET PROGRAMMING Presented By : Divya Sharma.
Socket Abstraction and Interprocess Communication
Sockets and Beginning Network Programming
Socket Programming in C
Socket Interface 1 Introduction 11 Socket address formats 2 API 12 13
Interprocess Communication
Transport layer API: Socket Programming
UNIX Sockets Outline Homework #1 posted by end of day
Socket Abstraction and Interprocess Communication
Socket Programming in C
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 Abstraction and Inter-process Communication
Socket Programming Neil Tang 09/08/2008
Internet Networking recitation #8
Sockets.
Presentation transcript:

CSE/EE 461 Getting Started with Networking

Basic Concepts  A PROCESS is an executing program somewhere.  Eg, “./a.out”  A MESSAGE contains information sent by one PROCESS to ANOTHER  Eg, “please get  A COMMUNICATIONS ENDPOINT is the name of some source or destination of a message  Host: Port: 80www.cs.washington.edu  A PROTOCOL is the SET-OF-RULES governing the transmission of MESSAGES  Protocol: TCP/IP  A MESSAGING-API is the programming interface used by PROCESSES to send/receive MESSAGES  Typically,  OS implements the PARTS IN RED  Application provides/consumes the MESSAGES.

Example: TCP Delivery Application process Write bytes TCP Send buffer Segment Transmit segments Application process Read bytes TCP Receive buffer … …… OS APP

The API Unix SOCKETS

Berkeley Sockets  Networking protocols are implemented as part of the OS  The networking API exported by most OS’s is the socket interface  Originally provided by BSD 4.1c ~1982.  The principal abstraction is a socket  Point at which an application attaches to the network  Defines operations for creating connections, attaching to network, sending/receiving data, closing.  Two primary protocols used  Reliable Connections (TCP) Like a telephone  Unreliable Datagrams (UDP) Like postcards

The Client/Server Paradigm  A Server is a long lived process that LISTENS in at some well-known COMMUNICATIONS-ENDPOINT  Awaiting a new request  Satisfy the new request  Send a response  Do it again  A Client is a (possibly short lived) process that makes requests on Servers  Format a message containing the request  Send the message to the Server  Await the response  Process the response  Classic Example:  WWW Web Servers (Apache, IIS, etc) Web Clients (IE, Safari, Firefox)  Clients CONNECT to SERVERS by means of an OS API

Client/Server Connection API Server Socket() Bind() Client Socket() Listen() Accept() Recv() Send() Connect() Send() Recv() Block until connect Process request Connection Establishment. Data (request) Data (reply)

Structure  Server  Make a “rendezvous socket” on which to accept requests socket  Associate an “address” with that socket so that others can submit requests bind  Ready the socket for requests listen  Await a request on the rendezvous socket accept –Creates a SECOND socket  Read the request (from the SECOND socket) read  Do the request XX  Send the response write  Client  Make a local “socket” on which to send requests to the rendezvous address socket  Connect to the rendezvous address by means of the local socket connect  Send the request write  Await the response read

Socket call  Means by which an application attached to the network  #include …  int socket(int family, int type, int protocol)  Family: address family (protocol family)  AF_UNIX, AF_INET, AF_NS, AF_IMPLINK  Type: semantics of communication  SOCK_STREAM, SOCK_DGRAM, SOCK_RAW  Not all combinations of family and type are valid  Protocol: Usually set to 0 but can be set to specific value.  Family and type usually imply the protocol  Return value is a handle for new socket

Bind call  Typically a server call  Binds a newly created socket to the specified address  int bind(int socket, struct sockaddr *address, int addr_len)  Socket: newly created socket handle  Address: data structure of address of local system  IP address (host identifier) and port number (endpoint on identified host)  SOCKET and PORT are not the same concept  Socket: “widget” that a process uses to manipulate its endpoint  Port: hostwide name of a communication’s endpoint  Address: hostname.port pair  For comparison: Socket == file descriptor port == file name, address == network file name

Listen call  Used by connection-oriented servers to indicate an application is willing to receive connections  Int(int socket, int backlog)  Socket: handle of newly creates socket  Backlog: number of connection requests that can be queued by the system while waiting for server to execute accept call.

Accept call  A server call  After executing listen, the accept call carries out a passive open (server prepared to accept connects).  int accept(int socket, struct sockaddr *address, int addr_len)  It blocks until a remote client carries out a connection request.  When it does return, it returns with a new socket that corresponds with new connection and the address contains the clients address

Connect call  A client call  Client executes an active open of a connection  int connect(int socket, struct sockaddr *address, int addr_len)  How does the OS know where the server is?  Call does not return until the three-way handshake (TCP) is complete  Address field contains remote system’s address  Client OS usually selects random, unused port

Input and Output  After connection has been made, application uses send/recv to data  int send(int socket, char *message, int msg_len, int flags)  Send specified message using specified socket  int recv(int socket, char *buffer, int buf_len, int flags)  Receive message from specified socket into specified buffer  Or can use read/write  int read(int socket, char* buffer, int len)  int write(int socket, char* buffer, int len);  Or can sometimes use sendto/recvfrom  Or can use sendmsg, recvmsg for “scatter/gather”

Connection Establishment  Both sender and receiver must be ready before we start to transfer the data  Sender and receiver need to agree on a set of parameters  e.g., the Maximum Segment Size (MSS)  This is signaling  It sets up state at the endpoints  Compare to “dialing” in the telephone network  In TCP a Three-Way Handshake is used

Sample Code

SERVER

CLIENT

Running it… Run 1 Run 2 How are these two runs different? dogmatix.dyn.cs.washington.edu arvind%./server 9998 & [1] 736 dogmatix.dyn.cs.washington.edu arvind%./client localhost 9998 Please enter the message: This is a test Here is the message: This is a test I got your message dogmatix.dyn.cs.washington.edu arvind%./server 9999 & [1] 736 dogmatix.dyn.cs.washington.edu arvind%./client dogmatix 9999 Please enter the message: This is a test Here is the message: This is a test I got your message

Observing Communication Messages are sent via NETWORK INTERFACES eg, “lo0”, “en0” The tcpdump program allows us to observe network traffic. “man tcpdump” for more information!