Introduction to Linux Network 劉德懿

Slides:



Advertisements
Similar presentations
Introduction to Sockets Jan Why do we need sockets? Provides an abstraction for interprocess communication.
Advertisements

CS 4700 / CS 5700 Network Fundamentals
Taekyung Kim 0x410 ~ 0x International Standards Organization (ISO) is a multinational body dedicated to worldwide agreement on international.
Review: –What functionality is supported by IP? –What IP does not do? –How many classes of IP addresses? –Explain fields in an IP header? –How subnet works?
Socket Programming.
Sockets Basics Conectionless Protocol. Today IPC Sockets Basic functions Handed code Q & A.
Tutorial 8 Socket Programming
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
The Basics of communication LectureII. Processing Techniques.
CS 360 – Spring 2007 Pacific University TCP section 6.5 (Read this section!) 27 Feb 2007.
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.
Sockets CIS 370 Fall 2009, UMassD. Introduction  Sockets provide a simple programming interface which is consistent for processes on the same machine.
Basic Socket Programming TCP/IP overview. TCP interface Reference: –UNIX Network Programming, by Richard Stevens. –UNIX man page.
ECE 4110 – Internetwork Programming Client-Server Model.
Sockets and intro to IO multiplexing. Goals We are going to study sockets programming as means to introduce IO multiplexing problem. We will revisit socket.
1 Networking (Stack and Sockets API). 2 Topic Overview Introduction –Protocol Models –Linux Kernel Support TCP/IP Sockets –Usage –Attributes –Example.
Elementary TCP Sockets
Socket Programming. Introduction Sockets are a protocol independent method of creating a connection between processes. Sockets can be either – Connection.
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
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.
NetworkProtocols. Objectives Identify characteristics of TCP/IP, IPX/SPX, NetBIOS, and AppleTalk Understand position of network protocols in OSI Model.
Sockets CIS 370 Lab 10 UMass Dartmouth. Introduction 4 Sockets provide a simple programming interface which is consistent for processes on the same machine.
TCP/IP: Basics1 User Datagram Protocol (UDP) Another protocol at transport layer is UDP. It is Connectionless protocol i.e. no need to establish & terminate.
Introduction to Networking and TCP/IP J. H. Wang Jun. 8, 2005.
LWIP TCP/IP Stack 김백규.
IT COOKBOOK Windows Network Programming. Chapter 01. Intro. to Network and Socket 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 Three Network Protocols By JD McGuire ARP Address Resolution Protocol Address Resolution Protocol The core protocol in the TCP/IP suite that.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 26.
Introduction to Network Programming with Sockets Network Programming Kansas State University at Salina.
11 TRANSPORT LAYER PROTOCOLS Chapter 6 TCP and UDP SPX and NCP.
Chapter 2 Applications and Layered Architectures Sockets.
Network Programming Eddie Aronovich mail:
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.
TELE202 Lecture 15 Socket programming 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (2) »Source: chapter 17 ¥This Lecture »Socket programming.
Prepared by: Azara Prakash L.. Contents:-  Data Transmission  Introduction  Socket Description  Data Flow Diagram  Module Design Specification.
UNIX Sockets COS 461 Precept 1. Socket and Process Communication The interface that the OS provides to its networking subsystem application layer transport.
1 Introduction to TCP/IP. 2 OSI and Protocol Stack OSI: Open Systems Interconnect OSI ModelTCP/IP HierarchyProtocols 7 th Application Layer 6 th Presentation.
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.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
Socket Programming.
Advanced UNIX programming Fall 2002, lecture 16 Instructor: Ashok Srinivasan Acknowledgements: The syllabus and power point presentations are modified.
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.
Networking OSI (Open Systems Interconnection) model of computer networking, seven layers (the Application, Presentation, Session, Transport, Network, Data.
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.
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
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.
1 Spring Semester 2008, Dept. of Computer Science, Technion Internet Networking recitation #7 Socket Programming.
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.
Socket Programming(1/2). Outline  1. Introduction to Network Programming  2. Network Architecture – Client/Server Model  3. TCP Socket Programming.
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.
Sockets API Developing Applications using the Sockets API.
SOCKET PROGRAMMING Presented By : Divya Sharma.
UNIX Sockets COS 461 Precept 1.
Socket Programming in C
Transport layer API: Socket Programming
Linux Networks TCP/IP Networking Layers BSD Socket Interface
Socket Programming in C
Internet Networking recitation #8
Outline Communications in Distributed Systems Socket Programming
Presentation transcript:

Introduction to Linux Network 劉德懿

Outline OSI and TCP/IP Overview Linux Networking Layers BSD Socket Interface INET Socket Interface An Example of Socket Programming

OSI Overview OSI (Open Systems Interconnection) See Figures …

TCP/IP Model OSI TCP/IP Application Presentation Session Transport Network Data Link Physical Application Transport Internet Host-to- Network Not present TCP IP

TCP Overview TCP (Transmission Control Protocol) Connection-Oriented Reliable Protocol UDP (User Datagram Protocol) Connectionless Unreliable Protocol

IP Overview 32-bit Unique IP Address Network Address Subnet Address Host Address XX XX Gatewa y (Router)

IP Overview (cont.) IP Header

Ethernet Layer 48-bit Unique Device Address ARP (Address Resolution Protocol) multicast

Linux Networking Layers Support Mechanism Various Networking Inter-Process Communication A Special Kind of Pipe Support Several Address Family … Support Several Socket Type …

Addr FamilyDescription UNIX Unix domain sockets INET Internet address family support TCP(UDP)/IP AX25 Amateur radio X25 IPX Novell IPX APPLETALK Appletalk DDP X25

Socket TypeDescription StreamReliable, Sequenced, Like TCP DatagramUnreliable, Not sequenced, Like UDP Reliable Delivered Messages Like datagram but reliable Sequenced PacketLike Stream but fixed size packet

BSD Sockets INET Sockets TCPUDP IP PPPSLIPEthernet ARP User Kernel Network Applications Socket Interface Protocol Layers Network Devices

Client/Server Communication Client 1. Create a socket 2. Bind an addr 3. Listen the client 4. Create a socket Server Connect Accept Send Recv

BSD Socket API See An Example

BSD Initialization void __init proto_init(void)

The INET Layer BSD Socket A part of VFS inode A socket can be operated just the same as a file by system call read(), write(), lseek() … INET Layer use sock data structure to handle BSD socket

Creating a BSD Socket For both client and server int socket(int family, int type, int protocol) Ex. fd=Socket(AF_INET, SOCK_STREAM,0);

files_struct count close_on_exec open_fs fd[0] fd[1] fd[255] file f_mode f_pos f_flags f_count f_owner f_op f_inode f_version inode sock socket type protocol data (sk) type protocol socket SOCK_STREAM Address Family socket operations BSD Socket File Operations lseek read write select ioctl close fasync Linux BSD Socket Data Structure

Binding an Address Only for Server Int bind(int sockfd, const struct sockaddr *address, size_t add_len) Port Number is optional for binding socket.socket_state = TCP_CLOSE; The bound socket can ’ t be used for other communication

Binding an Address (cont.) The bound addr was saved in sock.rcv_saddr UDP maintains a hash table udp_hash to allocate UDP port TCP doesn ’ t add the binding sock to hash table during binding operation

Listening Only for server int listen(int sockfd, int queue_size) socket.socket_state = TCP_LISTEN; Add the sock to tcp_bound_hash and tcp_listening_hash

Listening (cont.) After receiving client ’ s request Server build a new sock Clones the incoming sk_buff and queues it to the listening sock.receive_queue

Connecting Only for client Before connecting, socket.socket_state = SS_UNCONNECTED; Int connect(int csockfd, const struct sockaddr *address, size_t add_len) Add the sock to tcp_listening_hash waiting for server ’ s response

Accepting Only for server int accept(int sockfd, struct sockaddr *address, size_t *add_len) A new socket was cloned from the listening socket

Accepting (cont.) If there are no incoming connection to accept Non-Blocking — accept operation failed and throw away the new socket Blocking — accept operation was added to the wait queue

next prev dev head data tail end Packet to be transmitted sk_buffer structure truesize len Push Pull Put Trim

References The Linux Kernel, chapter 10 Linux Kernel Internals, chapter 8 Unix System Programming, chapter 10 Computer Networks, chapter 1, 5, 6