1 MP2: P2P File Server Hoang Nguyen. 2 Outline Basic network concepts revisited –Client/Server, Peer-to-peer –IP address, TCP/UDP Basic network programming.

Slides:



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

Socket Programming CS3320 Fall 2010.
Socket Programming. Basics Socket is an interface between application and network – Application creates a socket – Socket type dictates the style of communication.
Transport Layer3-1 Transport Overview and UDP. Transport Layer3-2 Goals r Understand transport services m Multiplexing and Demultiplexing m Reliable data.
Socket Programming Application Programming Interface.
Computer Communication Digital Communication in the Modern World Transport Layer Multiplexing, UDP
Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Chapter 3: Transport Layer
Socket Programming.
1 Socket Interfaces Professor Jinhua Guo CIS527 Fall 2003.
Introduction to Transport Layer. Transport Layer: Motivation A B R1 R2 r Recall that NL is responsible for forwarding a packet from one HOST to another.
Transport Layer3-1 Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer.
Tutorial 8 Socket Programming
Java Socket Support Presentation by: Lijun Yuan Course Number: cs616.
CSE/EE 461 Getting Started with Networking. Basic Concepts  A PROCESS is an executing program somewhere.  Eg, “./a.out”  A MESSAGE contains information.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
Client Server Model The client machine (or the client process) makes the request for some resource or service, and the server machine (the server process)
Some slides are in courtesy of J. Kurose and K. Ross Review of Previous Lecture Electronic Mail: SMTP, POP3, IMAP DNS Socket programming with TCP.
1 Computer Networks Transport Layer Protocols. 2 Application-layer Protocols Application-layer protocols –one “piece” of an app –define messages exchanged.
8-1 Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer m flow.
UNIX Sockets COS 461 Precept 1. Clients and Servers Client program – Running on end host – Requests service – E.g., Web browser Server program – Running.
UNIX Sockets COS 461 Precept 1.
Socket Programming Based on tutorial prepared by EUISOK CHUNG CS3320 Spring2008.
Socket Programming References: redKlyde ’ s tutorial set Winsock2 for games (gamedev.net)
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.
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.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Discussion 2 Sockets Programming Applets TCP UDP HTTP Delay Estimation
Application Layer 2-1 ESERCITAZIONE SOCKET PROGRAMMING.
Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system.
 Wind River Systems, Inc Chapter - 13 Network Programming.
Transport Layer1 Ram Dantu (compiled from various text books)
Chapter 2 Applications and Layered Architectures Sockets.
Remote Shell CS230 Project #4 Assigned : Due date :
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.
Transport Layer 3-1 Chapter 3 Outline r 3.1 Transport-layer services r 3.2 Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP.
Chapter 3: Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer.
UNIX Sockets COS 461 Precept 1. Socket and Process Communication The interface that the OS provides to its networking subsystem application layer transport.
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.
Part 4: Network Applications Client-server interaction, example applications.
Socket Programming.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: HsinYu Ha.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
1 Tips for the assignment. 2 Socket: a door between application process and end- end-transport protocol (UDP or TCP) TCP service: reliable transfer of.
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 WITH JAVA By Collin Donaldson.
1 Network Communications A Brief Introduction. 2 Network Communications.
1 K. Salah Application Layer Module K. Salah Network layer duties.
Network Programming. These days almost all devices.
SOCKET PROGRAMMING Presented By : Divya Sharma.
UDP Socket Programming
Chapter 3 outline 3.1 Transport-layer services
CSCE 313 Network Socket MP8 DUE: FRI MAY 5, 2017
Sockets and Beginning Network Programming
UNIX Sockets COS 461 Precept 1.
MCA – 405 Elective –I (A) Java Programming & Technology
Socket Programming in C
Chapter 2 Introduction Application Requirements VS. Transport Services
Transport layer API: Socket Programming
Socket Programming in C
Internet Networking recitation #8
Transport Layer Our goals:
Presentation transcript:

1 MP2: P2P File Server Hoang Nguyen

2 Outline Basic network concepts revisited –Client/Server, Peer-to-peer –IP address, TCP/UDP Basic network programming revisited –Server socket, Client Socket –Send/Receive data –Data Serialization: converting objects to bits Network Design: Control/Data plane –MP explanation –Implementation suggestions/hints

3 Basic network concepts revisited

4 Basic network concepts (1) Client/server –Servers = machines providing network services –Clients = machines connecting to servers and use network services –Example: FTP server/FTP client

5 Basic network concepts (2) A server provides a network service through a “port” –Has to “bind” to a particular port Clients requests for a specific service at a server via a pre-defined port E.g.: Port 21: FTP control, Port 20: FTP data Port: ( ) – : well-known ports, requiring admin right to bind – : registered ports (for propriety apps) –The rest: dynamic/private ports

6 Basic network concepts (3) What is a Protocol? –A convention standard that controls or enables the connection, communication and data transfer between two parties. Example: –“Protocol” to apply to UIUC –“Admission protocol” In our MP, we will have to define our own “protocols” and use some existing network protocols

7 Basic network concepts (3) IP address: a tuple of four 8-bit integers –E.g.: Host name: name representative of IP –E.g.: TCP: Transmission Control Protocol –Reliable, ordered, heavy-weight, streaming (connection- oriented/stateful) –Suitable for any applications requiring reliability such as FTP UDP: User Datagram Protocol –Unreliable, not-ordered, light-weight, datagrams (connectionless/stateless) –Suitable for any protocols that can tolerate reasonable losses such as video/audio/real-time streaming

8 Basic network programming revisited

9 Highly recommended tutorial –Beej's Guide to Network Programming Using Internet Sockets Make sure you go through until Section 7 (esp. Section 6 and Section 7.4)

10 Network Socket A socket is a one end of a two-way communications link between two programs running on the network –In UNIX, socket is just a file descriptor on which send() and recv() can be used. As mentioned above, a socket can be –SOCK_STREAM: streaming, reliable, connection- oriented, ordered –SOCK_DGRAM: datagram, unreliable, connection- less, not-ordered

11 How to create a server socket? Pseudo-code & example fill out address information sock_fd = create/set socket option bind to the port listen for incoming connections while (forever || not crash) client_fd = accept a client socket create a process/thread to communicate with the client … // ready to send/recv

12 Comments sock_fd: Server socket keeps listening for incoming connections –If the accept() function is not invoked, no client connection can be accepted –If the number of pending connections exceeds the backlog, any incoming requests are refused. client_fd: socket to communicate with the client –Think of it like a file descriptor.

13 How to create a client socket? Pseudo-code & example fill out address information (hostname, port) sock_fd = connect to the server … // ready to send/recv

14 Sending/Receiving data no_send = send(sock_fd, data, len, flag) no_recv = recv(sock_fd, buf, max_len, flag) Example

15 Data serialization Converting data objects into bits Three ways: 1)Use readable string description: e.g. “text ‘this is a text’, int 1, float ” 2)Sending raw data, passing it send() (dangerous, un- portable) double d = ; send(s, &d, sizeof d, 0); 3) Encode the data into a portable binary form. The receiver encodes it. (see pack(), unpack() in the tutorial)

16 Control/Data Plane Control plane: a set of protocols/software to bootstrap/setup and control the communication Data plane: a set of protocols/software to transmit data E.g.: FTP has two ports for control channel (21) and data channel (20)

17 In our MP…

18 An example implementation of control plane for our MP 1)Dispatcher setup peer-to-peer connections 2)Handling a client request

19 Entities (1) A server has –a server socket listening on port 7000 for dispatcher setup connection request –a client socket to communicate with dispatcher obtained once accepting dispatcher setup connection request –an on-demand server socket listening on a on- demand port for the client to send/recv data

20 Entities (2) A dispatcher has –several client sockets for connections to each server –a server socket listening on port 8000 for clients to send/recv control messages A client has –A client socket to send/recv control messages to the dispatcher –A client socket to send/recv data to the server

21 Dispatcher setup connection Socket on port 7000 Setup connection request socket Socket on port 8000 socket Setup connection request Bi-directional cairo sanjose

22 Handling a client request socket Bi-directional Socket on port 8000 cairo sanjose 1. request 2. request 3. response 4. response