Download presentation
Presentation is loading. Please wait.
1
1 Review of Previous Lecture r Electronic Mail r DNS r P2P file sharing
2
2 Overview r P2P file sharing (cont.) r Socket programming with TCP r Socket programming with UDP
3
3 P2P file sharing Example r Alice runs P2P client application on her notebook computer r Intermittently connects to Internet; gets new IP address for each connection r Asks for “Hey Jude” r Application displays other peers that have copy of Hey Jude. r Alice chooses one of the peers, Bob. r File is copied from Bob’s PC to Alice’s notebook: HTTP r While Alice downloads, other users uploading from Alice. r Alice’s peer is both a Web client and a transient Web server. All peers are servers = highly scalable!
4
4 P2P: centralized directory original “Napster” design 1) when peer connects, it informs central server: m IP address m content 2) Alice queries for “Hey Jude” 3) Alice requests file from Bob centralized directory server peers Alice Bob 1 1 1 1 2 3
5
5 P2P: problems with centralized directory r Single point of failure m if the directory server crashes, then the entire p2p application crashes r Performance bottleneck m a centralized server must maintain a huge database r Copyright infringement m Easy to shut down the directory servers by legal actions file transfer is decentralized, but locating content is highly centralized
6
6 Query flooding: Gnutella r fully distributed m no central server r public domain protocol r many Gnutella clients implementing protocol overlay network: graph r edge between peer X and Y if there’s a TCP connection r all active peers and edges is overlay net r Edge is not a physical link r Given peer will typically be connected with < 10 overlay neighbors
7
7 Gnutella: protocol Query QueryHit Query QueryHit Query QueryHit File transfer: HTTP r Query message sent over existing TCP connections r peers forward Query message r QueryHit sent over reverse path Scalability: limited scope flooding
8
8 Gnutella: Peer joining 1. Joining peer X must find some other peer in Gnutella network: use list of candidate peers 2. X sequentially attempts to make TCP with peers on list until connection setup with Y 3. X sends Ping message to Y; Y forwards Ping message. 4. All peers receiving Ping message respond with Pong message 5. X receives many Pong messages. It can then setup additional TCP connections
9
9 Exploiting heterogeneity: KaZaA r Napster fully centralized r Gnutella floods in limited area r KaZaA: m Each peer is either a group leader or assigned to a group leader. TCP connection between peer and its group leader. TCP connections between some pairs of group leaders. m Group leader tracks the content in all its children.
10
10 KaZaA: Querying r Each file has a hash and a descriptor r Client sends keyword query to its group leader r Group leader responds with matches: m For each match: filename, hash, IP address r If group leader forwards query to other group leaders, they respond with matches r Client then selects files for downloading m HTTP requests using hash as identifier sent to peers holding desired file
11
11 DoS resilience in p2p file-sharing systems r P2p networks – highly replicated content m not enough to protect against DoS attacks r Music industry places false content on p2p networks (e.g., KaZaA) m companies such as “Overpeer” and “Ratsnap” publicly publicly offer their pollution-based services r My dilemma…
12
12 DoS resilience in p2p file-sharing systems (cont.) r Modeling the propagation of polluted files in the system m User-behavior factors Willingness to share files Persistence in downloading files Negligence in cleansing the infected hosts r Designed and evaluated attacks against p2p networks m % of nodes needed to collapse the system m Hierarchical vs. structured p2p networks m Counter-measures Reputations systems, randomization
13
13 Summary r P2P file sharing (cont.) r Socket programming with TCP r Socket programming with UDP
14
14 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm r two types of transport service via socket API: m unreliable datagram m reliable, byte stream- oriented a host-local, application-created, OS-controlled interface (a “door”) into which application process can both send and receive messages to/from another application process socket Goal: learn how to build client/server application that communicate using sockets
15
15 Socket-programming using TCP Socket: a door between application process and end- end-transport protocol (UDP or TCP) TCP service: reliable transfer of bytes from one process to another process TCP with buffers, variables socket controlled by application developer controlled by operating system host or server process TCP with buffers, variables socket controlled by application developer controlled by operating system host or server internet
16
16 Socket programming with TCP Client must contact server r server process must first be running r server must have created socket (door) that welcomes client’s contact Client contacts server by: r creating client-local TCP socket r specifying IP address, port number of server process r When client creates socket: client TCP establishes connection to server TCP r When contacted by client, server TCP creates new socket for server process to communicate with client m allows server to talk with multiple clients m source port numbers used to distinguish clients (more in Chap 3) TCP provides reliable, in-order transfer of bytes (“pipe”) between client and server application viewpoint
17
17 Stream jargon r A stream is a sequence of characters that flow into or out of a process. r An input stream is attached to some input source for the process, eg, keyboard or socket. r An output stream is attached to an output source, eg, monitor or socket.
18
18 Socket programming with TCP Example client-server app: 1) client reads line from standard input ( inFromUser stream), sends to server via socket ( outToServer stream) 2) server reads line from socket 3) server converts line to uppercase, sends back to client 4) client reads, prints modified line from socket ( inFromServer stream) Client process client TCP socket
19
19 Client/server socket interaction: TCP wait for incoming connection request connectionSocket = welcomeSocket.accept() create socket, port= x, for incoming request: welcomeSocket = ServerSocket() create socket, connect to hostid, port= x clientSocket = Socket() close connectionSocket read reply from clientSocket close clientSocket Server (running on hostid ) Client send request using clientSocket read request from connectionSocket write reply to connectionSocket TCP connection setup
20
20 Example: Java client (TCP) import java.io.*; import java.net.*; class TCPClient { public static void main(String argv[]) throws Exception { String sentence; String modifiedSentence; BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); Socket clientSocket = new Socket("hostname", 6789); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); Create input stream Create client socket, connect to server Create output stream attached to socket
21
21 Example: Java client (TCP), cont. 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(); } Create input stream attached to socket Send line to server Read line from server
22
22 Example: Java server (TCP) import java.io.*; import java.net.*; class TCPServer { public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence; ServerSocket welcomeSocket = new ServerSocket(6789); while(true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); Create welcoming socket at port 6789 Wait, on welcoming socket for contact by client Create input stream, attached to socket
23
23 Example: Java server (TCP), cont DataOutputStream outToClient = new DataOutputStream (connectionSocket.getOutputStream()); clientSentence = inFromClient.readLine(); capitalizedSentence = clientSentence.toUpperCase() + '\n'; outToClient.writeBytes(capitalizedSentence); } Read in line from socket Create output stream, attached to socket Write out line to socket End of while loop, loop back and wait for another client connection
24
24 Outline r P2P file sharing (cont.) r Socket programming with TCP r Socket programming with UDP
25
25 Socket programming with UDP UDP: no “connection” between client and server r no handshaking r sender explicitly attaches IP address and port of destination to each packet r server must extract IP address, port of sender from received packet UDP: transmitted data may be received out of order, or lost application viewpoint UDP provides unreliable transfer of groups of bytes (“datagrams”) between client and server
26
26 Client/server socket interaction: UDP close clientSocket Server (running on hostid ) read reply from clientSocket create socket, clientSocket = DatagramSocket() Client Create, address ( hostid, port=x, send datagram request using clientSocket create socket, port= x, for incoming request: serverSocket = DatagramSocket() read request from serverSocket write reply to serverSocket specifying client host address, port number
27
27 Example: Java client (UDP) Output: sends packet (TCP sent “byte stream”) Input: receives packet (TCP received “byte stream”) Client process client UDP socket
28
28 Example: Java client (UDP) import java.io.*; import java.net.*; class UDPClient { public static void main(String args[]) throws Exception { BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); DatagramSocket clientSocket = new DatagramSocket(); InetAddress IPAddress = InetAddress.getByName("hostname"); byte[] sendData = new byte[1024]; byte[] receiveData = new byte[1024]; String sentence = inFromUser.readLine(); sendData = sentence.getBytes(); Create input stream Create client socket Translate hostname to IP address using DNS
29
29 Example: Java client (UDP), cont. 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(); } Create datagram with data-to-send, length, IP addr, port Send datagram to server Read datagram from server
30
30 Example: Java server (UDP) import java.io.*; import java.net.*; class UDPServer { public static void main(String args[]) throws Exception { 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); Create datagram socket at port 9876 Create space for received datagram Receive datagram
31
31 Example: Java server (UDP), cont String sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivePacket.getAddress(); int port = receivePacket.getPort(); String capitalizedSentence = sentence.toUpperCase(); sendData = capitalizedSentence.getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port); serverSocket.send(sendPacket); } Get IP addr port #, of sender Write out datagram to socket End of while loop, loop back and wait for another datagram Create datagram to send to client
32
32 Summary r P2P file sharing (cont.) r Socket programming with TCP r Socket programming with UDP
33
33 Application Layer: Summary r Application architectures m client-server m P2P m hybrid r application service requirements: m reliability, bandwidth, delay r Internet transport service model m connection-oriented, reliable: TCP m unreliable, datagrams: UDP Our study of network apps now complete! r specific protocols: m HTTP m FTP m SMTP, POP, IMAP m DNS r socket programming
34
34 Application Layer: Summary r typical request/reply message exchange: m client requests info or service m server responds with data, status code r message formats: m headers: fields giving info about data m data: info being communicated Most importantly: learned about protocols r control vs. data msgs m in-band, out-of-band r centralized vs. decentralized r stateless vs. stateful r reliable vs. unreliable msg transfer r “complexity at network edge”
35
35 Quiz (Application Layer) r Q1. List four Internet apps and the application layer protocols
36
36 Quiz r Q2. What is the difference between network architecture and application architecture?
37
37 Quiz r Q3. In what way is instant messaging a hybrid of client-server and P2P architectures?
38
38 Quiz r Q4. For a communication session between a pair of processes, which process is the client and which is the server?
39
39 Quiz r Q5. Do you agree with the statement: “In P2p file sharing, there is no notion of client and server sides of a communication session”? r Why or why not?
40
40 Quiz r Q6. What information is used by a process running on one host to identify a process running on another host?
41
41 Quiz r Q9. What is meant by a handshaking protocol?
42
42 Quiz r Q10. Why HTTP, FTP, SMTP, POP3, and IMAP run on top of TCP rather than UDP?
43
43 Quiz r Q12. What is the difference between persistent HTTP with pipelining and persistent HTTP without pipelining? r Which of the two is used by HTTP/1.1?
44
44 Quiz r Q15. Why is it said that FTP sends control information “out-of-band”?
45
45 Quiz r Q19. Is it possible for an organization’s Web server and mail server to have exactly the same alias for a hostname? r What would be the type for the RR that contains the hostname of the mail server?
46
46 Quiz r Q22. A UDP-based server needs only one socket, whereas the TCP server needs two sockets. Why? r If the TCP server were to support n simultaneous connections, each from a different client host, how many sockets would the TCP server need?
47
47 Quiz (Chapter 1) r Q3. What is a client program? r What is a server program? r Does a server program request and receive services from a client program?
48
48 Quiz r Q4. What are the two types of transport services that the Internet provides to its applications?
49
49 Quiz r Q5. What is the difference between flow and congestion control?
50
50 Quiz r Q7. What advantage does a circuit- switched network has over a packet- switched network?
51
51 Quiz r Q8. Why is it said that packet switching employs statistical multiplexing?
52
52 Quiz r Q12. List five Internet access technologies. r Classify each one as residential, company access, or mobile access.
53
53 Quiz r Q15. Is cable-modem transmission rate dedicated or shared among users? r Are collisions possible in the downstream channel? r Why or why not?
54
54 Quiz r Q19. Consider sending packet from a sending host to a receiving host over a fixed route. List the delay components in the end-to-end delay. r Which of these delays are constant and which are variable?
55
55 Quiz r Q21. What are the five layers in the Internet protocol stack?
56
56 Quiz r Q23. Which layers in the Internet protocol stack does a router process? r Which layers does a link-layer switch process? r Which layers does a host process?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.