Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.

Similar presentations


Presentation on theme: "CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina."— Presentation transcript:

1 CSCE 515: Computer Network Programming Chin-Tser Huang huangct@cse.sc.edu University of South Carolina

2 4/21/20052 Peer-to-Peer Internet was designed to be an open and cooperative network Commercial applications and security concerns push Internet to client-server model A new trend for peer-to-peer File sharing Online chatting Resource sharing No boredom, more freedom!

3 4/21/20053 Issues in Peer-to-Peer Flexibility Scalability Anonymity Accountability

4 4/21/20054 Peer-to-Peer Applications Napster Gnutella Freenet Free Haven

5 4/21/20055 Napster Popular online music service Users first connect to Napster server to search for other users who have the target songs Server returns search results to users Users connect to each other to share songs Legal problems

6 4/21/20056 Gnutella A decentralized search system A language with many Gnutella-compatible implementations Emphasis on flexibility No privacy

7 4/21/20057 Freenet A decentralized system for distributing files User forwards a request to a node he/she knows and trusts Next node returns a hit or forwards request to a likely node Nodes in Freenet become increasingly connected Use unique ID for each file Provide partial anonymity

8 4/21/20058 Freenet Request Sequence From “Freenet: A Distributed Anonymous Information Storage and Retrieval System”, I. Clarke, O. Sandberg, B. Wiley, and T. Hong.

9 4/21/20059 Free Haven A system to provide anonymous storage that resists attempts of adversaries to find or destroy any stored data Emphasis on anonymity Publisher anonymity Reader anonymity Server anonymity Use a reputation system to address accountability

10 4/21/200510 Anonymity in Peer-to-Peer From “Tarzan: A Peer-to-Peer Anonymizing Network Layer”, by M. Freedman and R. Morris, ACM CCS’02.

11 4/21/200511 Overlay Networks A virtual network that uses underlying infrastructure network to provide connection between its nodes Messages between nodes are tunneled via underlying network Conceal unnecessary details about underlying network Can provide specialized functions

12 4/21/200512 Overlay Architecture

13 4/21/200513 Peer-to-Peer Overlay Networks Satisfy special need of a small group Make peer-to-peer application more scalable Improve efficiency

14 4/21/200514 An RMI Peering Example A peer-to-peer client locates central peering server and makes a remote call to obtain a partner If server has no client waiting to be partnered, it stores a reference to calling client and returns false If server has client waiting for same service, it notifies both clients of their new partner and returns true Remote interfaces PartnerServer and Partner Implementation classes PartnerServerImpl and PartnerImpl

15 4/21/200515 Interface PartnerServer /* Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN 188477749X * * http://nitric.com/jnp/ * * Copyright (c) 1997-1999 Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */ import java.rmi.*; public interface PartnerServer extends Remote { public boolean assignPartner (String service, Partner myself) throws RemoteException; }

16 4/21/200516 Interface Partner /* Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN 188477749X * * http://nitric.com/jnp/ * * Copyright (c) 1997-1999 Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */ import java.rmi.*; public interface Partner extends Remote { public void partnered (String service, Partner partner) throws RemoteException; }

17 4/21/200517 Class PartnerServerImpl /* Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN 188477749X * * http://nitric.com/jnp/ * * Copyright (c) 1997-1999 Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */ import java.rmi.*; import java.util.*; import java.rmi.server.*; import java.rmi.registry.*; public class PartnerServerImpl extends UnicastRemoteObject implements PartnerServer { // public PartnerServerImpl () throws RemoteException … // public synchronized boolean assignPartner (String service, Partner myself) throws RemoteException … // public static void main (String[] args) throws RemoteException, AlreadyBoundException … }

18 4/21/200518 Constructor PartnerServerImpl protected Hashtable pending; public PartnerServerImpl () throws RemoteException { pending = new Hashtable (); }

19 4/21/200519 Method assignPartner public synchronized boolean assignPartner (String service, Partner myself) throws RemoteException { if (!pending.containsKey (service)) { pending.put (service, myself); return false; } else { Partner partner = (Partner) pending.get (service); pending.remove (service); partner.partnered (service, myself); myself.partnered (service, partner); return true; }

20 4/21/200520 Method main public static void main (String[] args) throws RemoteException, AlreadyBoundException { if (args.length != 2) throw new IllegalArgumentException ("Syntax: PartnerServerImpl "); int port = Integer.parseInt (args[0]); String service = args[1]; PartnerServerImpl partnerServer = new PartnerServerImpl (); try { Registry registry = LocateRegistry.getRegistry (port); registry.bind (service, partnerServer); } catch (ConnectException ex) { Registry registry = LocateRegistry.createRegistry (port); registry.bind (service, partnerServer); }

21 4/21/200521 Class PartnerImpl /* Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN 188477749X * * http://nitric.com/jnp/ * * Copyright (c) 1997-1999 Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */ import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; public class PartnerImpl implements Partner { // public void partnered (String service, Partner partner) … // public static void main (String[] args) throws RemoteException, NotBoundException … }

22 4/21/200522 Methods of PartnerImpl public void partnered (String service, Partner partner) { System.out.println ("Partnered with " + partner + " for " + service + '.'); } public static void main (String[] args) throws RemoteException, NotBoundException { if (args.length != 3) throw new IllegalArgumentException ("Syntax: PartnerImpl "); PartnerImpl partner = new PartnerImpl (); Partner partnerRef = (Partner) UnicastRemoteObject.exportObject (partner); String host = args[0]; int port = Integer.parseInt (args[1]); String service = args[2]; Registry registry = LocateRegistry.getRegistry (host, port); PartnerServer server = (PartnerServer) registry.lookup (service); if (!server.assignPartner ("Testing", partnerRef)) System.out.println ("waiting..."); }

23 4/21/200523 Final Exam Will be held on Saturday, April 30, 9-11am Count for 20% toward your final grade More emphasis on programming than midterm


Download ppt "CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina."

Similar presentations


Ads by Google