Computer Networking Introduction

Similar documents
Chapter 2 Application Layer

Communication in Distributed Systems: Sockets Programming. Operating Systems

Lecture 05: Application Layer (Part 02) FTP, Peer-to-Peer, . Dr. Anis Koubaa

Chapter 2: outline. 2.1 principles of network applications. 2.6 P2P applications 2.7 socket programming with UDP and TCP

Chapter 2 outline. 2.1 Principles of app layer protocols

Chapter 2 Application Layer

Application Layer: P2P File Distribution

Introduction to Sockets 9/25/14

CPSC 441 UDP Socket Programming. Department of Computer Science University of Calgary

Chapter 2: Application layer

CSCD 330 Network Programming Winter 2019

CSCD 330 Network Programming Spring 2018

CS 355. Computer Networking. Wei Lu, Ph.D., P.Eng.

Layer 4 - Transport Layer. What do we need a Transport Layer for? Transport Protocols in the TCP/IP Reference Model. The Transport Layer TCP and UDP

CPSC 441 Tutorial - 11 UDP Socket Programming Department of Computer Science University of Calgary

Layer 4 - Transport Layer

Lecture 3. Java Socket Programming. TCP, UDP and URL

CC451 Computer Networks

CSC 4900 Computer Networks: P2P and Sockets

CSCD 330 Network Programming Spring 2018

Computer Networks. 2.Application Layer. László Böszörményi Computer Networks Application Layer - 1

CMPE 150/L : Introduction to Computer Networks. Chen Qian Computer Engineering UCSC Baskin Engineering Lecture 6

Chapter 2 Application Layer. 2: Application Layer 1

COMP 211 Chapter 2 Application Layer

Client/Server Computing & Socket Programming

Computer Networks 1 (Mạng Máy Tính 1) Lectured by: Dr. Phạm Trần Vũ

Chapter 2 Application Layer

TCP and UDP Socket Programming in JAVA TCP Socket Programming 1. Write code for Client and save in GreetingClient.java

COMP 3331/9331: Computer Networks and Applications

Chapter 2 Application Layer

Chapter 2 Application Layer

Chapter 2: Application layer. Chapter 2 Application Layer. Chapter 2: Application Layer. Some network apps

Chapter 2 Application Layer

Process Communication COMPUTER NETWORKING Part 2

CMSC 332 Computer Networks P2P and Sockets

Chapter 2: outline. 2.6 P2P applications 2.7 socket programming with UDP and TCP

Chapter 2: Application layer. Chapter 2 Application Layer. Some network apps. Chapter 2: Application Layer. Chapter 2: Application layer

Chapter 2: Application layer. Chapter 2 Application Layer. Chapter 2: Application Layer. Some network apps

Computer Networks Unit II Transport layer (2012 pattern)

A note on the use of these ppt slides:

Chapter 2: Application Layer last updated 22/09/03

Chapter 2 Application Layer

Lecture 8: Application Layer P2P Applications and DHTs

Chapter 2 Application Layer

Data Communications & Networks. Session 2 Main Theme Application Layer. Dr. Jean-Claude Franchitti

Data Communications & Networks. Session 2 Main Theme Application Layer. Dr. Jean-Claude Franchitti

Chapter 2 Application Layer

Section 2: Application layer

COMPUTER NETWORKS CHAP 2 : APPLICATION LAYER

Part 2: Application Layer

Chapter 2 Application Layer

Web Caching and HTTPS

Application-Layer Protocols Peer-to-Peer Systems, Media Streaming & Content Delivery Networks

Chapter 2 Application Layer

Chapter 2 Application Layer

Computer Networks. Application Layer

Chapter 2 Application Layer. 2: Application Layer 1

Chapter 2: Application layer. Computer Networks. Application Layer. Chapter 2: Application Layer. Some network apps. Bu-Ali Sina University, Hamedan

Computer Communication Networks Socket Programming

JAVA SOCKET PROGRAMMING

Chapter II: Application Layer

Chapter 2 Application Layer

Πρωτόκολλα Διαδικτύου (ΨΣ-326 DS151)

Chapter 2 Application Layer

CSCI Computer Networks Spring 2017

CSC 401 Data and Computer Communications Networks

SE322 Software Design and Architecture

Unit 1 Java Networking

Chapter 2 Application Layer

Chapter 2 APPLICATIONS

Computer Networks and Applications. Application Layer ( , DNS, P2P, Socket Programming)

We will cover in this order: 2.1, 2.7, 2.5, 2.4, 2.2

55:134/22C:178 Computer Communications Lecture Note Set 2 Summer 2004

Telematics Chapter 8: Transport Layer

Foundations of Telematics

Tonight. Communication. Middleware Protocols. Remote Procedure Call (RPC) Several common communication mechanisms RPC RMI Sockets Next week: HTTP,

Chapter 2a SOCKET PROGRAMMING

Tommy Färnqvist, IDA, Linköping University

CS 43: Computer Networks BitTorrent & Content Distribution. Kevin Webb Swarthmore College September 28, 2017

Chapter 2 APPLICATIONS

Chapter 2: Application layer

CS 3516: Advanced Computer Networks

Chapter 2 Application Layer

Last Lecture SMTP. SUNY at Buffalo; CSE 489/589 Modern Networking Concepts; Fall 2010; Instructor: Hung Q. Ngo 1

Telematics 1. Chapter 9 Internet Application Layer. Principles of network applications Important application protocols Socket programming

Application Programming Interfaces

Client/Server Computing & Socket Programming

Application Layer. Application Layer 1. By Mikkel Christiansen for NA mm7 Spring 2004

Java Network Programming

Chapter 1 Introduction

Chapter 2 Application Layer

FTP. Mail. File Transfer Protocol (FTP) FTP commands, responses. Electronic Mail. TDTS06: Computer Networks

Chapter 2 Application Layer

SOURCE CODE. //Socket Programming using TCP Sockets. Server.java

Lecture 2 - Application Layer. Lecture 1 Review. Application Layer. Principles of network applications. Notes. Notes. Notes. Notes

CS 3516: Computer Networks

internet technologies and standards

Some network apps. Chapter 2 Application Layer. Chapter 2: Application layer. Chapter 2: Application Layer. Chapter 2: Application layer

Computer Networks. 5th of February, This exam consists of 6 questions with subquestions. Every subquestion counts for 10 points.

CPSC 441 Assignment-3 Discussion. Department of Computer Science University of Calgary

Transcription:

Computer Networking Introduction Halgurd S. Maghdid Software Engineering Department Koya University-Koya, Kurdistan-Iraq Lecture No.6

Chapter 2: outline 2.1 principles of network applications app architectures app requirements 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail 2.5 DNS SMTP, POP3, IMAP 2.6 P2P applications 2.7 Socket programming with UDP and TCP

Pure P2P architecture no always-on server arbitrary end systems directly communicate peers are intermittently connected and change IP addresses examples: file distribution (BitTorrent) Streaming (KanKan) VoIP (Skype)

File distribution: client-server vs P2P Question: how much time to distribute file (size F) from one server to N peers? peer upload/download capacity is limited resource u s : server upload capacity file, size F server u s u 1 d 1 u 2 d 2 d i : peer i download capacity u N d N network (with abundant bandwidth) d i u i u i : peer i upload capacity 4 of 23

File distribution time: client-server server transmission: must sequentially send (upload) N file copies: F u s network d i time to send one copy: F/u s u i time to send N copies: NF/u s client: each client must download file copy d min = min client download rate min client download time: F/d min time to distribute F to N clients using client-server approach D cs > max{nf/u s,, F/d min } 5 of 23 increases linearly in N

File distribution time: P2P server transmission: must upload at least one copy time to send one copy: F/u s The server must send each bit of the file at least once into its access link. A bit sent once by the server may not have to be sent by the server again, as the peers may redistribute the bit among themselves. client: each client must download file copy min client download time: F/d min clients: as aggregate must download NF bits max upload rate (limting max download rate) is u s + Su i time to distribute F to N clients using P2P approach F u s network D P2P > max{f/u s,,f/d min,,nf/(u s + Su i )} d i u i increases linearly in N but so does this, as each peer brings service capacity

Minimum Distribution Time Client-server vs. P2P: example client upload rate = u, F/u = 1 hour, u s = 10u, d min u s 3.5 3 2.5 2 1.5 1 0.5 0 P2P Client-Server 0 5 10 15 20 25 30 35 N

P2P file distribution: BitTorrent file divided into 256Kb chunks peers in torrent send/receive file chunks tracker: tracks peers participating in torrent torrent: group of peers exchanging chunks of a file Alice arrives obtains list of peers from tracker and begins exchanging file chunks with peers in torrent 8 of 23

P2P file distribution: BitTorrent peer joining torrent: has no chunks, but will accumulate them over time from other peers registers with tracker to get list of peers, connects to subset of peers ( neighbors ) while downloading, peer uploads chunks to other peers peer may change peers with whom it exchanges chunks churn: peers may come and go once peer has entire file, it may (selfishly) leave or (altruistically) remain in torrent

BitTorrent: requesting, sending file chunks requesting chunks: at any given time, different peers have different subsets of file chunks periodically, Alice asks each peer for list of chunks that they have Alice requests missing chunks from peers, rarest first sending chunks: tit-for-tat Alice sends chunks to those four peers currently sending her chunks at highest rate other peers are choked by Alice (do not receive chunks from her) re-evaluate top 4 every10 secs every 30 secs: randomly select another peer, starts sending chunks optimistically unchoke this peer newly chosen peer may join top 4

BitTorrent: tit-for-tat (1) Alice optimistically unchokes Bob (2) Alice becomes one of Bob s top-four providers; Bob reciprocates (3) Bob becomes one of Alice s top-four providers higher upload rate: find better trading partners, get file faster!

Distributed Hash Table (DHT) Hash table DHT paradigm Circular DHT and overlay networks Peer churn 12 of 23

Simple Database Simple database with(key, value) pairs: key: human name; value: social security # 13 of 23 Key Value John Washington 132-54-3570 Diana Louise Jones 761-55-3791 Xiaoming Liu 385-41-0902 Rakesh Gopal 441-89-1956 Linda Cohen 217-66-5609. Lisa Kobayashi 177-23-0199 key: movie title; value: IP address

Hash Table More convenient to store and search on numerical representation of key key = hash(original key) Original Key Key Value John Washington 8962458 132-54-3570 Diana Louise Jones 7800356 761-55-3791 Xiaoming Liu 1567109 385-41-0902 Rakesh Gopal 2360012 441-89-1956 Linda Cohen 5430938 217-66-5609. Lisa Kobayashi 9290124 177-23-0199 14 of 23

Distributed Hash Table (DHT) Distribute (key, value) pairs over millions of peers pairs are evenly distributed over peers Any peer can query database with a key database returns value for the key To resolve query, small number of messages exchanged among peers Each peer only knows about a small number of other peers Robust to peers coming and going (churn) 15 of 23

Assign key-value pairs to peers rule: assign key-value pair to the peer that has the closest ID. convention: closest is the immediate successor of the key. e.g., ID space {0,1,2,3,,63} suppose 8 peers: 1,12,13,25,32,40,48,60 If key = 58, then assigned to peer 60 If key = 60, then assigned to peer 60 If key = 64, then assigned to peer 1 16 of 23

Circular DHT each peer only aware of immediate successor and predecessor. 1 60 12 13 48 25 17 of 23 40 32 overlay network

Resolving a query value 1 12 What is the value associated with key 58? 60 13 48 O(N) messages on avgerage to resolve query, when there are N peers 40 32 25

Circular DHT with shortcuts 60 48 40 value 1 32 each peer keeps track of IP addresses of predecessor, successor, short cuts. reduced from 6 to 3 messages. possible to design shortcuts with O(log N) neighbors, O(log N) messages in query 12 25 What is the value for key 58 13 19 of 23

1 Peer churn 15 12 10 8 example: peer 5 abruptly leaves 3 5 4 handling peer churn: peers may come and go (churn) each peer knows address of its two successors each peer periodically pings its two successors to check aliveness if immediate successor leaves, choose next successor as new immediate successor 20 of 23

1 Peer churn 15 12 example: peer 5 abruptly leaves peer 4 detects peer 5 s departure; makes 8 its immediate successor 4 asks 8 who its immediate successor is; makes 8 s immediate successor its second successor. 21 of 23 10 8 3 4 handling peer churn: peers may come and go (churn) each peer knows address of its two successors each peer periodically pings its two successors to check aliveness if immediate successor leaves, choose next successor as new immediate successor

Chapter 2: outline 2.1 principles of network applications app architectures app requirements 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail SMTP, POP3, IMAP 2.5 DNS 2.6 P2P applications 2.7 socket programming with UDP and TCP

Socket programming goal: learn how to build client/server applications that communicate using sockets socket: door between application process and end-endtransport protocol application process socket application process controlled by app developer transport network link physical Internet transport network link physical controlled by OS 23 of 23

Socket programming Two socket types for two transport services: UDP: unreliable datagram TCP: reliable, byte stream-oriented Application Example: 1. Client reads a line of characters (data) from its keyboard and sends the data to the server. 2. The server receives the data and converts characters to uppercase. 3. The server sends the modified data to the client. 4. The client receives the modified data and displays the line on its screen. 24 of 23

Socket programming with UDP UDP: no connection between client & server no handshaking before sending data sender explicitly attaches IP destination address and port # to each packet rcvr extracts sender IP address and port# from received packet UDP: transmitted data may be lost or received out-of-order Application viewpoint: UDP provides unreliable transfer of groups of bytes ( datagrams ) between client and server

Client/server socket interaction: UDP server (running on serverip) create socket, port= x: serversocket = socket(af_inet,sock_dgram) read datagram from serversocket write reply to serversocket specifying client address, port number client create socket: clientsocket = socket(af_inet,sock_dgram) Create datagram with server IP and port=x; send datagram via clientsocket read datagram from clientsocket close clientsocket

Example app: UDP client include Java s socket library get user keyboard input create UDP socket for server Attach server name, port to packet; send into socket read reply characters from socket into string print out received string and close socket Java UDPClient import java.io.*; import java.net.*; BufferedReader infromuser = new BufferedReader(new InputStreamReader(System.in)); DatagramSocket clientsocket = new DatagramSocket(); InetAddress IPAddress = InetAddress.getByName("localhost"); byte[] senddata = new byte[1024]; byte[] receivedata = new byte[1024]; String sentence = infromuser.readline(); senddata = sentence.getbytes(); DatagramPacket sendpacket = new DatagramPacket(sendData, senddata.length, IPAddress, 9876); clientsocket.send(sendpacket); DatagramPacket receivepacket = new DatagramPacket(receiveData, receivedata.length); clientsocket.receive(receivepacket); String modifiedsentence = new String(receivePacket.getData()); System.out.println("FROM SERVER:" + modifiedsentence); clientsocket.close();

Example app: UDP server create UDP socket loop forever Read from UDP socket into message, getting client s address (client IP and port) send upper case string back to this client Java UDPServer DatagramSocket serversocket = new DatagramSocket(9876); byte[] receivedata = new byte[1024]; byte[] senddata = new byte[1024]; while(true) { DatagramPacket receivepacket = new DatagramPacket(receiveData, receivedata.length); serversocket.receive(receivepacket); String sentence = new String( receivepacket.getdata()); System.out.println("RECEIVED: " + sentence); InetAddress IPAddress = receivepacket.getaddress(); int port = receivepacket.getport(); String capitalizedsentence = sentence.touppercase(); senddata = capitalizedsentence.getbytes(); DatagramPacket sendpacket = new DatagramPacket(sendData, senddata.length, IPAddre serversocket.send(sendpacket); }

Socket programming with TCP client must contact server server process must first be running server must have created socket (door) that welcomes client s contact client contacts server by: Creating TCP socket, specifying IP address, port number of server process when client creates socket: client TCP establishes connection to server TCP when contacted by client, server TCP creates new socket for server process to communicate with that particular client allows server to talk with multiple clients source port numbers used to distinguish clients (more in Chap 3) application viewpoint: TCP provides reliable, in-order byte-stream transfer ( pipe ) between client and server

Client/server socket interaction: TCP server (running on hostid) client create socket, port=x, for incoming request: serversocket = socket() wait for incoming connection request connectionsocket = serversocket.accept() read request from connectionsocket write reply to connectionsocket close connectionsocket TCP connection setup create socket, connect to hostid, port=x clientsocket = socket() send request using clientsocket read reply from clientsocket close clientsocket

Example app: TCP client create TCP socket for server, remote port 6789 No need to attach server name, port Java TCPClient String sentence; String modifiedsentence; BufferedReader infromuser = new BufferedReader( new InputStreamReader(System.in)); Socket clientsocket = new Socket("localhost", 6789); DataOutputStream outtoserver = new DataOutputStream(clientSocket.getOutputStream()); BufferedReader infromserver = new BufferedReader( new InputStreamReader(clientSocket.getInputStream())); sentence = infromuser.readline(); outtoserver.writebytes(sentence + '\n'); modifiedsentence = infromserver.readline(); System.out.println("FROM SERVER: " + modifiedsentence); clientsocket.close();

Example app: TCP server create TCP welcoming socket loop forever server waits on accept() for incoming requests, new socket created on return read bytes from socket (but not address as in UDP) Java TCPServer String clientsentence; String capitalizedsentence; ServerSocket welcomesocket = new ServerSocket(6789); while(true) { Socket connectionsocket = welcomesocket.accept(); BufferedReader infromclient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); DataOutputStream outtoclient = new DataOutputStream(connectionSocket.getOutputStream()); clientsentence = infromclient.readline(); System.out.println("Received: " + clientsentence); capitalizedsentence = clientsentence.touppercase() + '\n'; outtoclient.writebytes(capitalizedsentence); }

Chapter 2: summary our study of network apps now complete! application architectures client-server P2P application service requirements: reliability, bandwidth, delay Internet transport service model connection-oriented, reliable: TCP unreliable, datagrams: UDP specific protocols: HTTP FTP SMTP, POP, IMAP DNS P2P: BitTorrent, DHT socket programming: TCP, UDP sockets

Chapter 2: summary most importantly: learned about protocols! typical request/reply message exchange: client requests info or service server responds with data, status code message formats: headers: fields giving info about data data: info being communicated important themes: control vs. data msgs in-band, out-of-band centralized vs. decentralized stateless vs. stateful reliable vs. unreliable msg transfer complexity at network edge