|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgps.protocol.BT.BTSession
public class BTSession
BT Session corresponding to a downloading or uploading session for a document.
| Field Summary | |
|---|---|
static int |
COMPLETED
session status - completed |
static int |
FAILED
session status - failed |
static int |
MAX_ALLOWED_CONNECTION_NUM
max allowed connection num |
boolean |
mRemoved
if closed, set up the mClosed flag, and remove from hashmap |
int |
mStatus
session status |
static int |
PEER_CANDIDATE_LIST_LENGTH
peer candidate list length |
static int |
STOPPED
session status - stopped |
static int |
WORKING
session status - working |
| Constructor Summary | |
|---|---|
BTSession(BTTorrent t,
BTPeer agent)
constructs a bt session from torrent |
|
BTSession(java.lang.String key,
BTPeer agent)
constructs a bt session from document hash key |
|
| Method Summary | |
|---|---|
boolean |
addNodeHasPiece(BTPeer node,
int piece)
update piece information in local database |
void |
announcePeer(int index)
let all the connected peers know that this node finishes downloading a piece. |
void |
announceTracker()
sends announcement to tracker |
void |
closeConnection(BTPeer p)
close connection to peer |
void |
connectTo(BTPeer p,
boolean chokedornot)
set up a connection to a peer |
int |
countPeersWithPiece(int i)
count peers with a specific piece |
BTPeer |
getAgent()
gets the Agent object on which this session is running |
BTSocket |
getConnection(BTPeer p)
gets connection to a peer |
java.util.LinkedHashMap |
getConnections()
gets connections |
BTDocument |
getDocument()
gets document that the session is downloading/uploading |
double |
getDownloadBetweenSnubbingDetection()
gets download amount between snubbing detection |
java.util.LinkedList |
getPeerCandidateList()
gets candidate list |
java.util.LinkedHashSet |
getUnchokedList()
gets unchoked list |
boolean |
handle(SimEvent e)
process event sent to this session |
void |
handleConnectionTimeout(BTEvent e)
handles connection time event, cuts connection |
void |
handlePeerMessage(BTEvent e)
handles all the peer message from peers except for hand shaking. |
void |
handlePMBitField(BTEvent e)
handles the bitfield type peer message In this simulation, bitfiled message works as the reply of handshaking this is received by the initiator, and the connection is really setup. |
void |
handlePMCancel(BTEvent e)
handles the cancel type peer message |
void |
handlePMChoke(BTEvent e)
handles the choke type peer message |
void |
handlePMHave(BTEvent e)
handles the have type peer message |
void |
handlePMInterested(BTEvent e)
handles the interested type peer message |
void |
handlePMNotInterested(BTEvent e)
handles the notInterested type peer message |
void |
handlePMPiece(BTEvent e)
handles the piece type peer message |
void |
handlePMRequest(BTEvent e)
handles the request type peer message |
void |
handlePMUnChoke(BTEvent e)
handles the unchoke type peer message |
void |
handleTrackerResponse(BTEvent e)
process tracker response evnet |
void |
queryTracker()
the entry point of this session, after the session is initionalized, this function is called to start the communication with tracker and peers |
void |
sendChoked(boolean choked,
BTPeer p)
send choked type peer message |
void |
sendInterested(boolean interested,
BTPeer p)
send interested type peer message |
void |
sendRequest(int index,
BTPeer p)
send request for a specific piece to a peer |
void |
sendRequestTo(BTPeer p)
send a piece request message to a peer |
void |
setDownloadBetweenSnubbingDetection(double d)
sets download amount between snubbing detection |
void |
setTorrent(BTTorrent t)
set torrent for existing session |
java.lang.String |
toString()
gets string description |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int PEER_CANDIDATE_LIST_LENGTH
public static final int MAX_ALLOWED_CONNECTION_NUM
public static final int WORKING
public static final int COMPLETED
public static final int STOPPED
public static final int FAILED
public int mStatus
public boolean mRemoved
| Constructor Detail |
|---|
public BTSession(BTTorrent t,
BTPeer agent)
t - torrent fileagent - peer
public BTSession(java.lang.String key,
BTPeer agent)
key - document hash keyagent - peer| Method Detail |
|---|
public BTPeer getAgent()
public void setTorrent(BTTorrent t)
t - torrentpublic BTDocument getDocument()
public java.util.LinkedHashMap getConnections()
public BTSocket getConnection(BTPeer p)
p - peer as an index
public java.util.LinkedList getPeerCandidateList()
public java.util.LinkedHashSet getUnchokedList()
public double getDownloadBetweenSnubbingDetection()
public void setDownloadBetweenSnubbingDetection(double d)
d - new download amountpublic boolean handle(SimEvent e)
handle in interface SimEventHandlere - the event object with some parameters in it
public void handleTrackerResponse(BTEvent e)
e - the event objectpublic void handlePeerMessage(BTEvent e)
e - the event objectpublic void handleConnectionTimeout(BTEvent e)
e - the event objectpublic void handlePMBitField(BTEvent e)
e - the event objectpublic void handlePMRequest(BTEvent e)
e - the event objectpublic void handlePMPiece(BTEvent e)
e - the event objectpublic void handlePMHave(BTEvent e)
e - the event objectpublic void handlePMChoke(BTEvent e)
e - the event objectpublic void handlePMUnChoke(BTEvent e)
e - the event objectpublic void handlePMInterested(BTEvent e)
e - the event objectpublic void handlePMNotInterested(BTEvent e)
e - the event objectpublic void handlePMCancel(BTEvent e)
e - the event objectpublic void queryTracker()
public void announceTracker()
public void announcePeer(int index)
index - piece index
public void connectTo(BTPeer p,
boolean chokedornot)
p - destination peerchokedornot - initially choked or notpublic void closeConnection(BTPeer p)
p - destination peerpublic void sendRequestTo(BTPeer p)
p - destination peer
public void sendRequest(int index,
BTPeer p)
index - piece indexp - destination peer
public void sendInterested(boolean interested,
BTPeer p)
interested - interested or uninterestedp - destination peer
public void sendChoked(boolean choked,
BTPeer p)
choked - choked or unchokedp - destination peer
public boolean addNodeHasPiece(BTPeer node,
int piece)
node - peerpiece - piece index
public int countPeersWithPiece(int i)
i - piece index
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||