CSCI-1680 Layering and Encapsulation Based partly on lecture notes by David Mazières, Phil Levis, John Jannotti Rodrigo Fonseca.

Slides:



Advertisements
Similar presentations
Chapter 17 Networking Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
Advertisements

20.1 Chapter 20 Network Layer: Internet Protocol Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Taekyung Kim 0x410 ~ 0x International Standards Organization (ISO) is a multinational body dedicated to worldwide agreement on international.
CSCI-1680 Layering and Encapsulation Based partly on lecture notes by David Mazières, Phil Levis, John Jannotti Theo Benson.
CCNA – Network Fundamentals
Socket Programming.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
Understanding Networks. Objectives Compare client and network operating systems Learn about local area network technologies, including Ethernet, Token.
Introduction To Networking
CS-3013 & CS-502, Summer 2006 Network Input & Output1 CS-3013 & CS-502, Summer 2006.
What Is TCP/IP? The large collection of networking protocols and services called TCP/IP denotes far more than the combination of the two key protocols.
CSCI Computer Networks Rodrigo Fonseca (rfonseca) Based partly on lecture notes by David Mazières, Phil Levis,
 The Open Systems Interconnection model (OSI model) is a product of the Open Systems Interconnection effort at the International Organization for Standardization.
Gursharan Singh Tatla Transport Layer 16-May
OIS Model TCP/IP Model.
1 TCP/IP architecture A set of protocols allowing communication across diverse networks Out of ARPANET Emphasize on robustness regarding to failure Emphasize.
UNIX Sockets COS 461 Precept 1.
What Can IP Do? Deliver datagrams to hosts – The IP address in a datagram header identify a host IP treats a computer as an endpoint of communication Best.
Process-to-Process Delivery:
Socket Programming. Introduction Sockets are a protocol independent method of creating a connection between processes. Sockets can be either – Connection.
University of Calgary – CPSC 441.  UDP stands for User Datagram Protocol.  A protocol for the Transport Layer in the protocol Stack.  Alternative to.
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
Review: – computer networks – topology: pair-wise connection, point-to-point networks and broadcast networks – switching techniques packet switching and.
Presentation on Osi & TCP/IP MODEL
What is a Protocol A set of definitions and rules defining the method by which data is transferred between two or more entities or systems. The key elements.
Introduction to Networks CS587x Lecture 1 Department of Computer Science Iowa State University.
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.
Fundamentals of Computer Networks ECE 478/578 Lecture #19: Transport Layer Instructor: Loukas Lazos Dept of Electrical and Computer Engineering University.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
1 The Internet and Networked Multimedia. 2 Layering  Internet protocols are designed to work in layers, with each layer building on the facilities provided.
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
TCOM 509 – Internet Protocols (TCP/IP) Lecture 03_b Protocol Layering Instructor: Dr. Li-Chuan Chen Date: 09/15/2003 Based in part upon slides of Prof.
The Transport Layer application transport network data link physical application transport network data link physical application transport network data.
Chapter 15 – Part 2 Networks The Internal Operating System The Architecture of Computer Hardware and Systems Software: An Information Technology Approach.
Chapter 2 Applications and Layered Architectures Sockets.
4061 Session 25 (4/17). Today Briefly: Select and Poll Layered Protocols and the Internets Intro to Network Programming.
CPSC 441 TUTORIAL – FEB 13, 2012 TA: RUITNG ZHOU UDP REVIEW.
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.
Networking Basics CCNA 1 Chapter 11.
S305 – Network Infrastructure Chapter 5 Network and Transport Layers.
Advanced UNIX programming Fall 2002, lecture 16 Instructor: Ashok Srinivasan Acknowledgements: The syllabus and power point presentations are modified.
Today’s topic: UDP Reliable communication over UDP.
Protocol Layering Chapter 11.
Review: – Why layer architecture? – peer entities – Protocol and service interface – Connection-oriented/connectionless service – Reliable/unreliable service.
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
Transport Protocols.
1 Transport Layer: Basics Outline Intro to transport UDP Congestion control basics.
Midterm Review. Chapter 1 Internet Concepts Applications, End-hosts, Routers, Switches, Communication Links Overall architecture How they are organized.
Data Communications and Networks Chapter 6 – IP, UDP and TCP ICT-BVF8.1- Data Communications and Network Trainer: Dr. Abbes Sebihi.
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
1 Network Communications A Brief Introduction. 2 Network Communications.
Client-server communication Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
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.
Chapter 9 The Transport Layer The Internet Protocol has three main protocols that run on top of IP: two are for data, one for control.
UDP: User Datagram Protocol. What Can IP Do? Deliver datagrams to hosts – The IP address in a datagram header identify a host – treats a computer as an.
SOCKET PROGRAMMING Presented By : Divya Sharma.
Chapter 5 Network and Transport Layers
The Transport Layer Implementation Services Functions Protocols
CSCI-1680 Layering and Encapsulation
UNIX Sockets COS 461 Precept 1.
Process-to-Process Delivery:
Lecture 4 Communication Network Protocols
1 TRANSMISSION CONTROL PROTOCOL / INTERNET PROTOCOL (TCP/IP) K. PALANIVEL Systems Analyst, Computer Centre Pondicherry University, Puducherry –
OSI Reference Model Unit II
Process-to-Process Delivery: UDP, TCP
OSI Model 7 Layers 7. Application Layer 6. Presentation Layer
Presentation transcript:

CSCI-1680 Layering and Encapsulation Based partly on lecture notes by David Mazières, Phil Levis, John Jannotti Rodrigo Fonseca

Administrivia Sign and hand in Collaboration Policy Signup for Snowcast milestone –Thursday from 8pm to 11pm –See Piazza for links Github

Today Review –Switching, Multiplexing Layering and Encapsulation Intro to IP, TCP, UDP Performance Metrics

A Taxonomy of networks Communication Network Switched Communication Network Broadcast Communication Network Circuit-Switched Communication Network Packet-Switched Communication Network Datagram Network Virtual Circuit Network A hybrid of circuits and packets; headers include a “circuit identifier” established during a setup phase Point-to-point network

Circuit Switching Guaranteed allocation –Time division / Frequency division multiplexing Low space overhead Easy to reason about Failures: must re-establish connection –For any failures along path Overload: all or nothing –No graceful degradation Waste: allocate for peak, waste for less than peak Set up time

Packet Switching Break information in small chunks: packets Each packet forwarded independently –Must add metadata to each packet Allows statistical multiplexing –High utilization –Very flexible –Fairness not automatic –Highly variable queueing delays –Different paths for each packet

Traceroute map of the Internet, ~5 million edges, circa opte.org

Managing Complexity Very large number of computers Incredible variety of technologies –Each with very different constraints No single administrative entity Evolving demands, protocols, applications –Each with very different requirements! How do we make sense of all this?

Layering Separation of concerns –Break problem into separate parts –Solve each one independently –Tie together through common interfaces: abstraction –Encapsulate data from the layer above inside data from the layer below –Allow independent evolution

Layers Application – what the users sees, e.g., HTTP Presentation – crypto, conversion between representations Session – can tie together multiple streams (e.g., audio & video) Transport – demultiplexes, provides reliability, flow and congestion control Network – sends packets, using routing Data Link – sends frames, handles media access Physical – sends individual bits

OSI Reference Model Application Protocol Transport Protocol Network Protocol Link-Layer Protocol

Layers, Services, Protocols Layer N Protocol: rules for communication within same layer Layer N-1 Layer N+1 Service: abstraction provided to layer above API: concrete way of using the service Layer N uses the services provided by N-1 to implement its protocol and provide its own services

Layers, Services, Protocols Network Link Physical Transport Application Service: move bits to other node across link Service: move frames to other node across link. May add reliability, medium access control Service: move packets to any other node in the network IP: Unreliable, best-effort service model Service: multiplexing applications Reliable byte stream to other node (TCP), Unreliable datagram (UDP) Service: user-facing application. Application-defined messages

Protocols What do you need to communicate? –Definition of message formats –Definition of the semantics of messages –Definition of valid sequences of messages Including valid timings Also, who do you talk to? …

Addressing Each node typically has a unique* name –When that name also tells you how to get to the node, it is called an address Each layer can have its own naming/addressing Routing is the process of finding a path to the destination –In packet switched networks, each packet must have a destination address –For circuit switched, use address to set up circuit Special addresses can exist for broadcast/multicast/anycast * within the relevant scope

Challenge Decide on how to factor the problem –What services at which layer? –What to leave out? –More on this later (End-to-end principle) For example: –IP offers pretty crappy service, even on top of reliable links… why? –TCP: offers reliable, in-order, no-duplicates service. Why would you want UDP?

IP as the Narrow Waist Many applications protocols on top of UDP & TCP IP works over many types of networks This is the “Hourglass” architecture of the Internet. –If every network supports IP, applications run over many different networks (e.g., cellular network)

Network Layer: Internet Protocol (IP) Used by most computer networks today –Runs over a variety of physical networks, can connect Ethernet, wireless, modem lines, etc. Every host has a unique 4-byte IP address (IPv4) –E.g.,  –The network knows how to route a packet to any address Need more to build something like the Web –Need naming (DNS) –Interface for browser and server software (next lecture) –Need demultiplexing within a host: which packets are for web browser, Skype, or the mail program?

Inter-process Communication Talking from host to host is great, but we want abstraction of inter-process communication Solution: encapsulate another protocol within IP

Transport: UDP and TCP UDP and TCP most popular protocols on IP –Both use 16-bit port number & 32-bit IP address –Applications bind a port & receive traffic on that port UDP – User (unreliable) Datagram Protocol –Exposes packet-switched nature of Internet –Sent packets may be dropped, reordered, even duplicated (but there is corruption protection) TCP – Transmission Control Protocol –Provides illusion of reliable ‘pipe’ or ‘stream’ between two processes anywhere on the network –Handles congestion and flow control

Uses of TCP Most applications use TCP –Easier to program (reliability is convenient) –Automatically avoids congestion (don’t need to worry about taking down the network Servers typically listen on well-know ports: –SSH: 22 –SMTP ( ): 25 –Finger: 79 –HTTP (web): 80

Transport: UDP and TCP UDP and TCP most popular protocols on IP –Both use 16-bit port number & 32-bit IP address –Applications bind a port & receive traffic on that port UDP – User (unreliable) Datagram Protocol –Exposes packet-switched nature of Internet –Sent packets may be dropped, reordered, even duplicated (but there is corruption protection) TCP – Transmission Control Protocol –Provides illusion of reliable ‘pipe’ or ‘stream’ between two processes anywhere on the network –Handles congestion and flow control

Internet Layering Strict layering not required –TCP/UDP “cheat” to detect certain errors in IP-level information like address –Overall, allows evolution, experimentation

We didn’t cover these in class, but these concepts about the socket API are useful for, and exercised by, the Snowcast assignment!

Using TCP/IP How can applications use the network? Sockets API. –Originally from BSD, widely implemented (*BSD, Linux, Mac OS X, Windows, …) –Important do know and do once –Higher-level APIs build on them After basic setup, much like files

Sockets: Communication Between Machines Network sockets are file descriptors too Datagram sockets: unreliable message delivery –With IP, gives you UDP –Send atomic messages, which may be reordered or lost –Special system calls to read/write: send/recv Stream sockets: bi-directional pipes –With IP, gives you TCP –Bytes written on one end read on another –Reads may not return full amount requested, must re- read

System calls for using TCP ClientServer socket – make socket bind – assign address, port listen – listen for clients socket – make socket bind* – assign address connect – connect to listening socket accept – accept connection This call to bind is optional, connect can choose address & port.

Socket Naming Recall how TCP & UDP name communication endpoints –IP address specifies host ( ) –16-bit port number demultiplexes within host –Well-known services listen on standard ports (e.g. ssh – 22, http – 80, mail – 25, see /etc/services for list) –Clients connect from arbitrary ports to well known ports A connection is named by 5 components –Protocol, local IP, local port, remote IP, remote port –TCP requires connected sockets, but not UDP

Dealing with Address Types All values in network byte order (Big Endian) –htonl(), htons() : host to network, 32 and 16 bits –ntohl(), ntohs() : network to host, 32 and 16 bits –Remember to always convert! All address types begin with family –sa_family in sockaddr tells you actual type Not all addresses are the same size –e.g., struct sockaddr_in6 is typically 28 bytes, yet generic struct sockaddr is only 16 bytes –So most calls require passing around socket length –New sockaddr_storage is big enough

Client Skeleton (IPv4)

Server Skeleton (IPv4)

Using UDP Call socket with SOCK_DGRAM, bind as before New calls for sending/receiving individual packets –sendto(int s, const void *msg, int len, int flags, const struct sockaddr *to, socklen t tolen); –recvfrom(int s, void *buf, int len, int flags, struct sockaddr *from, socklen t *fromlen); –Must send/get peer address with each packet Example: udpecho.c Can use UDP in connected mode (Why?) –connect assigns remote address –send / recv syscalls, like sendto / recvfrom w/o last two arguments

Uses of UDP Connected Sockets Kernel demultiplexes packets based on port –Can have different processes getting UDP packets from different peers Feedback based on ICMP messages (future lecture) –Say no process has bound UDP port you sent packet to –Server sends port unreachable message, but you will only receive it when using connected socket

Serving Multiple Clients A server may block when talking to a client –Read or write of a socket connected to a slow client can block –Server may be busy with CPU –Server might be blocked waiting for disk I/O Concurrency through multiple processes –Accept, fork, close in parent; child services request Advantages of one process per client –Don’t block on slow clients –May use multiple cores –Can keep disk queues full for disk-heavy workloads

Threads One process per client has disadvantages: –High overhead – fork + exit ~100μsec –Hard to share state across clients –Maximum number of processes limited Can use threads for concurrency –Data races and deadlocks make programming tricky –Must allocate one stack per request –Many thread implementations block on some I/O or have heavy thread-switch overhead Rough equivalents to fork(), waitpid(), exit(), kill(), plus locking primitives.

Non-blocking I/O fcntl sets O_NONBLOCK flag on descriptor int n; if ((n = fcntl(s, F_GETFL)) >= 0) fcntl(s, F_SETFL, n|O_NONBLOCK); Non-blocking semantics of system calls: –read immediately returns -1 with errno EAGAIN if no data –write may not write all data, or may return EAGAIN –connect may fail with EINPROGRESS (or may succeed, or may fail with a real error like ECONNREFUSED) –accept may fail with EAGAIN or EWOULDBLOCK if no connections present to be accepted

How do you know when to read/write? Entire program runs in an event loop

Event-driven servers Quite different from processes/threads –Race conditions, deadlocks rare –Often more efficient But… –Unusual programming model –Sometimes difficult to avoid blocking –Scaling to more CPUs is more complex

Coming Up Next class: Physical Layer Thu 13th: Snowcast milestones