An Example Architecture for CS179i based on Gnutella and Python

9
An Example Architecture An Example Architecture for CS179i for CS179i based on Gnutella and based on Gnutella and Python Python Yihua He Yihua He

description

An Example Architecture for CS179i based on Gnutella and Python. Yihua He. Sources. Gnutella Protocol v0.4 Norman Matloff’s “Introduction to Threads Programming with Python” Gnutella Developer’s Forum (GDF) Sources available online at www.cs.ucr.edu/~yhe/cs179i Trying to keep updated. - PowerPoint PPT Presentation

Transcript of An Example Architecture for CS179i based on Gnutella and Python

Page 1: An Example Architecture for CS179i based on Gnutella and Python

An Example Architecture for An Example Architecture for CS179iCS179i

based on Gnutella and Pythonbased on Gnutella and Python

Yihua HeYihua He

Page 2: An Example Architecture for CS179i based on Gnutella and Python

SourcesSources

Gnutella Protocol v0.4Gnutella Protocol v0.4 Norman Matloff’s “Introduction to Threads Norman Matloff’s “Introduction to Threads

Programming with Python”Programming with Python” Gnutella Developer’s Forum (GDF)Gnutella Developer’s Forum (GDF) Sources available online at Sources available online at

www.cs.ucr.edu/~yhe/cs179iwww.cs.ucr.edu/~yhe/cs179i Trying to keep updatedTrying to keep updated

Page 3: An Example Architecture for CS179i based on Gnutella and Python

Basic ComponentsBasic Components

A Gnutella ServerA Gnutella Server Setup and maintain connection with neighborsSetup and maintain connection with neighbors Routing Pings/Pongs and Querys/QueryHitsRouting Pings/Pongs and Querys/QueryHits A local searching mechanismA local searching mechanism

A Gnutella ClientA Gnutella Client Customized FTP/HTTP server and client Customized FTP/HTTP server and client

for retrieving target files.for retrieving target files.

Page 4: An Example Architecture for CS179i based on Gnutella and Python

Data Structures – Neighbor TableData Structures – Neighbor Table

NeighborTableNeighborTable Fields: IP, TimeStampFields: IP, TimeStamp Keep track of current active neighbors. Keep track of current active neighbors.

Neighbors are supposed to send pings Neighbors are supposed to send pings periodically in order to keep themselves periodically in order to keep themselves active. Timeout neighbors will be deleted from active. Timeout neighbors will be deleted from NeighborTable.NeighborTable.

RoutingHistoryRoutingHistory FileSharingTableFileSharingTable

Page 5: An Example Architecture for CS179i based on Gnutella and Python

Data Structures – Neighbor TableData Structures – Neighbor Table

NeighborTableNeighborTable Fields: IP, TimeStampFields: IP, TimeStamp Keep track of current active neighbors. Keep track of current active neighbors.

Neighbors are supposed to send pings Neighbors are supposed to send pings periodically in order to keep themselves periodically in order to keep themselves active. Timeout neighbors will be deleted from active. Timeout neighbors will be deleted from NeighborTable.NeighborTable.

RoutingHistoryRoutingHistory FileSharingTableFileSharingTable

Page 6: An Example Architecture for CS179i based on Gnutella and Python

Data Structures –RoutingHistoryData Structures –RoutingHistory

NeighborTableNeighborTable RoutingHistoryRoutingHistory

Fields: DescriptionID, MsgType, SourceIP, Fields: DescriptionID, MsgType, SourceIP, TimestampTimestamp

Pong/QueryHit descriptors may only be sent back Pong/QueryHit descriptors may only be sent back along the same path that carried the orginal along the same path that carried the orginal Ping/Query descriptors. Ping/Query descriptors.

To limit the size of RoutingHistory Table, entries will To limit the size of RoutingHistory Table, entries will be deleted after a certain period of time (timeout –Soft be deleted after a certain period of time (timeout –Soft state) state)

FileSharingTableFileSharingTable

Page 7: An Example Architecture for CS179i based on Gnutella and Python

Data Structures—FileSharing Table Data Structures—FileSharing Table

NeighborTableNeighborTable RoutingHistoryRoutingHistory FileSharingTableFileSharingTable

Fields: FileID, FileName, FilePath, MetaDescription, Fields: FileID, FileName, FilePath, MetaDescription, FileSize, Date and so onFileSize, Date and so on

Includes the files a node willing to shareIncludes the files a node willing to share In “QueryHit”, a node only sends out FileID to its peer. In “QueryHit”, a node only sends out FileID to its peer.

The peer opens a customized FTP/HTTP connection The peer opens a customized FTP/HTTP connection to the node and retrieve target files by FileIDto the node and retrieve target files by FileID

Page 8: An Example Architecture for CS179i based on Gnutella and Python

Main LoopMain Loop

Listen for new connection request

“GNUTELLA CONNECT/0.4\n\n”

If neighbor table full

Spawn a new thread to handle connection

Send “GNUTELLA NOT OK\n\n”

Close connection

Y

N

Page 9: An Example Architecture for CS179i based on Gnutella and Python

Maintain and RoutingMaintain and Routing

Re-check if neighbor

table full

Put a new entry in NeighborTable

Send “GNUTELLA OK\n\n”

Send “GNUTELLA NOT OK\n\n”

Close connectionThread ends

Y

N

Listen for Description Head (23 bytes)

At any stage, if it timeouts or any unexpected strings are received, the entry in NeighborTable will be deleted, connection will be closed and the thread ends

Process descriptions accordingly:1. Ping: Response with a Pong with

node’s information. Update routinghistory table, TTL-=1 and forwardPing to all neighbors if TTL>0

2. Pong: Check with routing historytable and if it is in, then TTL-=1 and forward to its destination; else discard

3. Query: Search local file (File Sharing Table), if hit, send Query/Hit with FileID and otherinfo. Update routing history table,TTL-=1 and forward Queryto all neighbors if TTL>0

4. QueryHit: Check with routinghistory table and if it is in, thenTTL-=1 and forward to itsdestination; else discard