56
1 Review of Previous Lecture Electronic Mail DNS P2P file sharing

1 Review of Previous Lecture r Electronic Mail r DNS r P2P file sharing

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

1

Review of Previous Lecture

Electronic Mail

DNS

P2P file sharing

2

Overview

P2P file sharing (cont.)

Socket programming with TCP

Socket programming with UDP

3

P2P file sharing

Example Alice runs P2P client

application on her notebook computer

Intermittently connects to Internet; gets new IP address for each connection

Asks for “Hey Jude” Application displays

other peers that have copy of Hey Jude.

Alice chooses one of the peers, Bob.

File is copied from Bob’s PC to Alice’s notebook: HTTP

While Alice downloads, other users uploading from Alice.

Alice’s peer is both a Web client and a transient Web server.

All peers are servers = highly scalable!

4

P2P: centralized directory

original “Napster” design

1) when peer connects, it informs central server: IP address content

2) Alice queries for “Hey Jude”

3) Alice requests file from Bob

centralizeddirectory server

peers

Alice

Bob

1

1

1

12

3

5

P2P: problems with centralized directory

Single point of failure if the directory server

crashes, then the entire p2p application crashes

Performance bottleneck a centralized server

must maintain a huge database

Copyright infringement Easy to shut down the

directory servers by legal actions

file transfer is decentralized, but locating content is highly centralized

6

Query flooding: Gnutella

fully distributed no central server

public domain protocol

many Gnutella clients implementing protocol

overlay network: graph edge between peer X

and Y if there’s a TCP connection

all active peers and edges is overlay net

Edge is not a physical link

Given peer will typically be connected with < 10 overlay neighbors

7

Gnutella: protocol

Query

QueryHit

Query

Query

QueryHit

Query

Query

QueryHit

File transfer:HTTP

Query messagesent over existing TCPconnections peers forwardQuery message QueryHit sent over reversepath

Scalability:limited scopeflooding

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

Exploiting heterogeneity: KaZaA

Napster fully centralized Gnutella floods in limited

area KaZaA:

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.

Group leader tracks the content in all its children.

ordinary peer

group-leader peer

neighoring re la tionshipsin overlay network

10

KaZaA: Querying

Each file has a hash and a descriptor Client sends keyword query to its group

leader Group leader responds with matches:

For each match: filename, hash, IP address If group leader forwards query to other

group leaders, they respond with matches

Client then selects files for downloading HTTP requests using hash as identifier sent

to peers holding desired file

11

DoS resilience in p2p file-sharing systems

P2p networks – highly replicated content not enough to protect against DoS attacks

Music industry places false content on p2p networks (e.g., KaZaA) companies such as “Overpeer” and

“Ratsnap” publicly publicly offer their pollution-based services

My dilemma…

12

DoS resilience in p2p file-sharing systems (cont.) Modeling the propagation of polluted files in

the system User-behavior factors

• Willingness to share files• Persistence in downloading files• Negligence in cleansing the infected hosts

Designed and evaluated attacks against p2p networks % of nodes needed to collapse the system Hierarchical vs. structured p2p networks Counter-measures

• Reputations systems, randomization

13

Summary

P2P file sharing (cont.)

Socket programming with TCP

Socket programming with UDP

14

Socket programming

Socket API introduced in BSD4.1 UNIX,

1981 explicitly created, used,

released by apps client/server paradigm two types of transport

service via socket API: unreliable datagram 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

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 withbuffers,

variables

socket

controlled byapplicationdeveloper

controlled byoperating

system

host orserver

process

TCP withbuffers,

variables

socket

controlled byapplicationdeveloper

controlled byoperatingsystem

host orserver

internet

16

Socket programming with TCPClient 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 client-local 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 client allows server to talk

with multiple clients 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

Stream jargon

A stream is a sequence of characters that flow into or out of a process.

An input stream is attached to some input source for the process, eg, keyboard or socket.

An output stream is attached to an output source, eg, monitor or socket.

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 socket3) server converts line to

uppercase, sends back to client

4) client reads, prints modified line from socket (inFromServer stream)

outT

oSer

ver

to network from network

inFr

omS

erve

r

inFr

omU

ser

keyboard monitor

Process

clientSocket

inputstream

inputstream

outputstream

TCPsocket

Clientprocess

client TCP socket

19

Client/server socket interaction: TCP

wait for incomingconnection requestconnectionSocket =welcomeSocket.accept()

create socket,port=x, forincoming request:welcomeSocket =

ServerSocket()

create socket,connect to hostid, port=xclientSocket =

Socket()

closeconnectionSocket

read reply fromclientSocket

closeclientSocket

Server (running on hostid) Client

send request usingclientSocketread request from

connectionSocket

write reply toconnectionSocket

TCP connection setup

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());

Createinput stream

Create client socket,

connect to server

Createoutput stream

attached to socket

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(); } }

Createinput stream

attached to socket

Send lineto server

Read linefrom server

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()));

Createwelcoming socket

at port 6789

Wait, on welcomingsocket for contact

by client

Create inputstream, attached

to socket

23

Example: Java server (TCP), cont

DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());

clientSentence = inFromClient.readLine();

capitalizedSentence = clientSentence.toUpperCase() + '\n';

outToClient.writeBytes(capitalizedSentence); } } }

Read in linefrom socket

Create outputstream,

attached to socket

Write out lineto socket

End of while loop,loop back and wait foranother client connection

24

Outline

P2P file sharing (cont.)

Socket programming with TCP

Socket programming with UDP

25

Socket programming with UDP

UDP: no “connection” between client and server

no handshaking sender explicitly attaches

IP address and port of destination to each packet

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

Client/server socket interaction: UDP

closeclientSocket

Server (running on hostid)

read reply fromclientSocket

create socket,clientSocket = DatagramSocket()

Client

Create, address (hostid, port=x,send datagram request using clientSocket

create socket,port=x, forincoming request:serverSocket = DatagramSocket()

read request fromserverSocket

write reply toserverSocketspecifying clienthost address,port number

27

Example: Java client (UDP)

sendP

ack

et

to network from network

rece

iveP

ack

et

inF

rom

Use

r

keyboard monitor

Process

clientSocket

UDPpacket

inputstream

UDPpacket

UDPsocket

Output: sends packet (TCP sent “byte stream”)

Input: receives packet (TCP received “byte stream”)

Clientprocess

client UDP socket

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();

Createinput stream

Create client socket

Translate hostname to IP

address using DNS

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 datagramto server

Read datagramfrom server

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);

Createdatagram socket

at port 9876

Create space forreceived datagram

Receivedatagra

m

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 addrport #, of

sender

Write out datagramto socket

End of while loop,loop back and wait foranother datagram

Create datagramto send to client

32

Summary

P2P file sharing (cont.)

Socket programming with TCP

Socket programming with UDP

33

Application Layer: Summary

Application architectures client-server P2P hybrid

application service requirements: reliability, bandwidth, delay

Internet transport service model connection-oriented, reliable:

TCP unreliable, datagrams: UDP

Our study of network apps now complete!

specific protocols: HTTP FTP SMTP, POP, IMAP DNS

socket programming

34

Application Layer: Summary

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

Most importantly: learned about protocols

control vs. data msgs in-band, out-of-band

centralized vs. decentralized

stateless vs. stateful reliable vs. unreliable msg

transfer “complexity at network

edge”

35

Quiz (Application Layer)

Q1. List four Internet apps and the application layer protocols

36

Quiz

Q2. What is the difference between network architecture and application architecture?

37

Quiz

Q3. In what way is instant messaging a hybrid of client-server and P2P architectures?

38

Quiz

Q4. For a communication session between a pair of processes, which process is the client and which is the server?

39

Quiz

Q5. Do you agree with the statement: “In P2p file sharing, there is no notion of client and server sides of a communication session”?

Why or why not?

40

Quiz

Q6. What information is used by a process running on one host to identify a process running on another host?

41

Quiz

Q9. What is meant by a handshaking protocol?

42

Quiz

Q10. Why HTTP, FTP, SMTP, POP3, and IMAP run on top of TCP rather than UDP?

43

Quiz

Q12. What is the difference between persistent HTTP with pipelining and persistent HTTP without pipelining?

Which of the two is used by HTTP/1.1?

44

Quiz

Q15. Why is it said that FTP sends control information “out-of-band”?

45

Quiz

Q19. Is it possible for an organization’s Web server and mail server to have exactly the same alias for a hostname?

What would be the type for the RR that contains the hostname of the mail server?

46

Quiz

Q22. A UDP-based server needs only one socket, whereas the TCP server needs two sockets. Why?

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

Quiz (Chapter 1)

Q3. What is a client program?

What is a server program?

Does a server program request and receive services from a client program?

48

Quiz

Q4. What are the two types of transport services that the Internet provides to its applications?

49

Quiz

Q5. What is the difference between flow and congestion control?

50

Quiz

Q7. What advantage does a circuit-switched network has over a packet-switched network?

51

Quiz

Q8. Why is it said that packet switching employs statistical multiplexing?

52

Quiz

Q12. List five Internet access technologies.

Classify each one as residential, company access, or mobile access.

53

Quiz

Q15. Is cable-modem transmission rate dedicated or shared among users?

Are collisions possible in the downstream channel?

Why or why not?

54

Quiz

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.

Which of these delays are constant and which are variable?

55

Quiz

Q21. What are the five layers in the Internet protocol stack?

56

Quiz

Q23. Which layers in the Internet protocol stack does a router process?

Which layers does a link-layer switch process?

Which layers does a host process?