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

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

CS 428/528 Computer Networks Lecture 01. Yan Wang

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

Network Communication

Socket Programming for TCP and UDP

Tutorial on Socket Programming

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

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

TCP: Three-way handshake

Sockets 15H2. Inshik Song

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

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

CPS 214: Computer Networks. Slides by Adolfo Rodriguez

CSE 124 Discussion Section Sockets Programming 10/10/17

The TCP Protocol Stack

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

Programming with TCP/IP. Ram Dantu

STUDY OF SOCKET PROGRAMMING

What s an API? Do we need standardization?

EEC-484/584 Computer Networks

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

Socket Programming TCP UDP

System Programming. Sockets

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

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

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

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

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software

Group-A Assignment No. 6

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

Systems software design NETWORK COMMUNICATIONS & RPC SYSTEMS

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

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

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

Computer Networks. Text Book By Larry L Peterson & Bruce S. Davie

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

CS 351 Week 15. Course Review

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

System Programming. Introduction to computer networks

CLIENT-SIDE PROGRAMMING

Introduction to Socket Programming

UNIX Sockets. COS 461 Precept 1

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

CS 640: Computer Networking

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

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

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

A. Basic Function Calls for Network Communications

Computer Networks Prof. Ashok K. Agrawala

Elementary TCP Sockets

Unix Network Programming

Socket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory

CSE 333 Section 8 - Client-Side Networking

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

ECE 650 Systems Programming & Engineering. Spring 2018

CS 351 Week Advanced UNIX Programming: Rochkind, Marc J. 1. To learn about System Interprocess Communication (IPC). 2. To learn about Sockets.

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

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

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

Lab 1: Packet Sniffing and Wireshark

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

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005

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

Topics for this Week

A Client-Server Exchange

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

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018

Network Software Implementations

(Refer Slide Time: 1:09)

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

UNIX System Programming Lecture 19: IP Sockets

UNIT IV- SOCKETS Part A

Communication. Sockets (Haviland Ch. 10)

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

Client Server Computing

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

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

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1. Interprocess Communication (IPC) Work Individually (no groups)

Application Programming Interfaces

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

CompSci 356: Computer Network Architectures. Lecture 3: Network Architecture Examples and Lab 1. Xiaowei Yang

TSIN02 - Internetworking

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

Introduction to Socket Programming

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CS321: Computer Networks Introduction to Application Layer

#1 socket_server.c socket_client.c

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

Introduction to Lab 2 and Socket Programming. -Vengatanathan Krishnamoorthi

API Reference 12/13/2014

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

EECS122 Communications Networks Socket Programming. Jörn Altmann

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

WinSock. What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics

Computer Network Lab, SS Fachgebiet Technische Informatik, Joachim Zumbrägel. Overview. Sockets. Sockets in C.

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

TSIN02 - Internetworking

Interprocess Communication Mechanisms

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

Transcription:

Lecture 2 Outline Wireshark Project 1 posted, due in a week Lab from a different textbook Work through the lab and answer questions at the end Chapter 1 - Foundation 1.1 Applications 1.2 Requirements 1.3 Network Architecture 1.4 Implementing Network Software 1.5 Performance 1.6 Summary Thursday, August 30 CS 475 Networks - Lecture 2 1 Thursday, August 30 CS 475 Networks - Lecture 2 2 Network Architecture To deal with the complexity of network design, engineers have developed network architectures that are used to design and implement networks. After discussing general network architecture concepts we will examine the two most popular architectures the OSI and Internet architectures. Network architectures are defined in terms of abstract layers. Layering decomposes the design into simpler components. It also allows for a modular design. Fig 1.8:Layered Architecture Thursday, August 30 CS 475 Networks - Lecture 2 3 Thursday, August 30 CS 475 Networks - Lecture 2 4 Network architectures will typically have multiple abstractions at any given level. The abstract objects are known as protocols. Fig 1.9: Alternate Abstractions A protocol provides a communication service that higher level objects use to exchange messages. Thursday, August 30 CS 475 Networks - Lecture 2 5 Fig 1.10: Service and Peer Interfaces A protocol defines two interfaces a service interface to higher levels and a peer interface to a corresponding object on another machine. Thursday, August 30 CS 475 Networks - Lecture 2 6 1

Protocol specifications define the service and peer interfaces. The service interface defines the operations the protocol provides to other local, higher-level objects. The peer interface defines the form and meaning of data exchanged with the peer protocol on another machine. Fig 1.11: A Hypothetical Protocol Graph RRP: Request/Reply Protocol MSP: Msg. Streaming Protocol HHP: Host-to-host Protocol This is a protocol graph nodes correspond to protocols and edges represent dependencies. Thursday, August 30 CS 475 Networks - Lecture 2 7 Thursday, August 30 CS 475 Networks - Lecture 2 8 Higher-levels encapsulate data in a new message (typically by adding a header) as data is passed down the protocol stack. The headers are removed as the data passes up the stack on the peer. Fig 1.12: Message Encapsulation Multiplexing and demultiplexing can be achieved through the use of identifiers (demux keys) in the header. For example, different applications would be assigned different keys by RRP. The key is used on the peer to direct the message to the correct corresponding peer application. Similarly, keys can be used by HHP to demux a message between RRP and MSP. Thursday, August 30 CS 475 Networks - Lecture 2 9 Thursday, August 30 CS 475 Networks - Lecture 2 10 OSI Architecture The OSI architecture is one of the oldest. It consists of seven layers. Refer to the text for details. Fig 1.13: The OSI Architecture Thursday, August 30 CS 475 Networks - Lecture 2 11 The Internet (TCP/IP) architecture is overwhelmingly the most popular architecture in use. It has made almost all other architectures obsolete. The TCP/IP network model consists of four layers. Figs 1.14/1.15: The TCP/IP Arch. Thursday, August 30 CS 475 Networks - Lecture 2 12 2

TCP/IP can utilize many different Network protocols (Ethernet, token-ring, serial line, carrier pigeon). The Network layer is typically implemented using hardware (a network adapter) and software (a device driver). The IP or Internet Protocol defines how messages are routed between networks. It provides support for connecting networks to form an internetwork. The Transport layer (above the IP layer) consists of two main protocols: TCP (Transport Control Protocol) and UDP (User Datagram Protocol). TCP is a reliable, connection-oriented channel (similar to our theoretical RRP protocol) while UDP is an unreliable, connectionless channel (similar to MSP). The top or Application layer consists of many, many protocols (FTP, Telnet, SSH, SMTP, HTTP, etc). Programmers often define their own protocols for comm. between applications. Thursday, August 30 CS 475 Networks - Lecture 2 13 Thursday, August 30 CS 475 Networks - Lecture 2 14 Implementing Network Software The TCP/IP model has three notable features: Layering is not strict. Applications can bypass the Transport layer and use the IP or Network layers. The model is narrow-waisted. The IP layer can utilize multiple Network protocols. Many Transport protocols can be implemented above IP. The protocol suite can be expanded by adding new protocols. Official inclusion requires a specification AND an implementation. The success of the Internet can be attributed to the fact that much of its functionality is provided by software running on general-purpose computers. Knowing how to implement network software is essential to understanding computer networks. The way an application uses the network is similar to the way in which a high-level protocol uses a lower-level protocol. Thursday, August 30 CS 475 Networks - Lecture 2 15 Thursday, August 30 CS 475 Networks - Lecture 2 16 The socket API The socket API The socket interface to the TCP/IP protocol suite is supported on all popular OSes. Porting network applications that use the sockets API is relatively simple. The socket is the main abstraction in the socket API. Think of a socket as the point at which an application connects to the network. To create a socket in C/C++ call the socket function: int socket(int domain, int type, int protocol) Note: The socket API supports communication over several network protocol suites (TCP/IP, IPX, Appletalk, etc) as well as communication between processes on the same machine (local sockets). Thursday, August 30 CS 475 Networks - Lecture 2 17 Thursday, August 30 CS 475 Networks - Lecture 2 18 3

The socket API To specify that we want to use the IP protocol, domain should be AF_INET. (To bypass IP and use raw packets use AF_PACKET.) The type argument should be either SOCK_STREAM to specify TCP or SOCK_DGRAM to specify UDP. The protocol argument should be 0 (zero) when the domain is AF_INET. An integer identifier (the socket) is returned. It is used in all subsequent socket functions. If you are writing a server that uses the TCP transport protocol, you would then call: int bind(int sck, struct sockaddr *addr, int addrlen) int listen(int sck, int backlog) int accept(int sck, struct sockaddr *addr, int *addrlen) Each of these functions takes a sck argument, this is the identifier that is returned by a previous call to socket(). Thursday, August 30 CS 475 Networks - Lecture 2 19 Thursday, August 30 CS 475 Networks - Lecture 2 20 A server application waits for clients to connect to a particular socket address on the local machine. It does a passive open of the socket The addr argument used in the bind() call is a pointer to a data structure that contains the IP address of the server and a TCP port number. The TCP port number is used as a demux key to associate received data with this server. The addrlen argument is the size of the addr data structure in bytes. The backlog argument to listen() defines the maximum length to which the queue of pending connections for the socket may grow. The server process will block at accept() until a client connects. The addr argument is a pass-back argument, it contains the IP address and TCP port number of the client. The addrlen argument is a value-return argument. It should be initialized to the size (in bytes) of the addr structure. Thursday, August 30 CS 475 Networks - Lecture 2 21 Thursday, August 30 CS 475 Networks - Lecture 2 22 The socket API - Client Side The accept() routine returns an index to a new, active socket. This new socket is used for communicating with the connected client. In the event of an error, each of these routines (socket(), bind(), listen(), accept()) returns the value -1. You should ALWAYS check for an error and take appropriate action. Refer to the man pages for each of these routines for additional details. Thursday, August 30 CS 475 Networks - Lecture 2 23 After creating a socket via a call to socket(), the client performs an active open via: int connect(int sck, struct sockaddr *addr, int addrlen) The addr argument contains the IP address and port number of the server the client wishes to connect to. On error, -1 is returned. An error may occur due to network problems or if no server is listening at the indicated addr. Thursday, August 30 CS 475 Networks - Lecture 2 24 4

The socket API - Communication In-class Exercises After a connection had been established data is transferred between the server and client using: int send(int sck, void *buf, size_t len, int flags) int recv(int sck, void *buf, size_t len, int flags) recv() will block until a message is available or the connection is terminated. The write() and read() routines can used instead of send() and recv(). Note that sockets are bidirectional. After discussion of the simplex server and client, compile the client and connect to the server being run at csserver. Modify the server to display the IP address and port being used at the client peer (getpeername()). Run this server on localhost with a localhost client using hostname "localhost". Thursday, August 30 CS 475 Networks - Lecture 2 25 Thursday, August 30 CS 475 Networks - Lecture 2 26 In-class Exercises Use a port number of 0 on the server, so that a port is dynamically assigned by bind(). Use getsockname() to determine and display the port number. Modify the client to accept the server port number as the second argument. Run the server on csserver; run the client on the localhost. When you have complete this exercise, zip the client and server files together and email the archive as an attachment to the instructor at randall@evansville.edu Thursday, August 30 CS 475 Networks - Lecture 2 27 5