资源简介
主要是利用PeerSim进行Chord仿真所需要的一些协议与初始化变量内容,可以仿真出Chord网络结点的路由表,后继结点等信息,并能够执行结点加入退出以及索引的相关内容。
代码片段和文件信息
package peersim.chord;
import java.math.BigInteger;
import java.util.Random;
import peersim.config.Configuration;
import peersim.core.CommonState;
import peersim.core.Network;
import peersim.core.Node;
import peersim.dynamics.NodeInitializer;
public class ChordInitializer implements NodeInitializer {
private static final String PAR_PROT = “protocol“;
private int pid = 0;
private ChordProtocol cp;
public ChordInitializer(String prefix) {
pid = Configuration.getPid(prefix + “.“ + PAR_PROT);
}
public void initialize(Node n) {
cp = (ChordProtocol) n.getProtocol(pid);
join(n);
}
public void join(Node myNode) {
Random generator = new Random();
cp.predecessor = null;
// search a node to join
Node n;
do {
n = Network.get(generator.nextInt(Network.size()));
} while (n == null || n.isUp() == false);
cp.m = ((ChordProtocol) n.getProtocol(pid)).m;
cp.chordId = new BigInteger(cp.m CommonState.r);
ChordProtocol cpRemote = (ChordProtocol) n.getProtocol(pid);
Node successor = cpRemote.find_successor(cp.chordId);
cp.fails = 0;
cp.stabilizations = 0;
cp.varSuccList = cpRemote.varSuccList;
cp.varSuccList = 0;
cp.succLSize = cpRemote.succLSize;
cp.successorList = new Node[cp.succLSize];
cp.successorList[0] = successor;
cp.fingerTable = new Node[cp.m];
long succId = 0;
BigInteger lastId = ((ChordProtocol) Network.get(Network.size() - 1)
.getProtocol(pid)).chordId;
do {
cp.stabilizations++;
succId = cp.successorList[0].getID();
cp.stabilize(myNode);
if (((ChordProtocol) cp.successorList[0].getProtocol(pid)).chordId
.compareTo(cp.chordId) < 0) {
cp.successorList[0] = ((ChordProtocol) cp.successorList[0]
.getProtocol(pid)).find_successor(cp.chordId);
}
// controllo di non essere l‘ultimo elemento della rete
if (cp.chordId.compareTo(lastId) > 0) {
cp.successorList[0] = Network.get(0);
break;
}
} while (cp.successorList[0].getID() != succId
|| ((ChordProtocol) cp.successorList[0].getProtocol(pid)).chordId
.compareTo(cp.chordId) < 0);
cp.fixFingers();
}
}
- 上一篇:csapp203483
- 下一篇:串口数据转发工具
相关资源
- Peersim研究资料
- P2P、网贷后台原型
- 局域网封杀软件-P2POVER 2.7完美破解.
- chord-0.1实现代码
- UDP P2P打洞服务器
- FLASH局域网免服务器P2P聊天室源码(
- 计算机网络课程设计: 基于P2P的局域
- p2p搜索神器绿色无广告
- 基于KCP协议的P2P服务器和客户端
- p2p文件共享系统 含代码和文档
- 综合运用端口匹配、深度数据包检测
- p2p 的简单实现 上传文件
- jxse-doc-2.5
- P2P软件Shareaza 2.2.4.0源码
- P2P原理与技术P2P原理与技术
- Wi-Fi P2P Technical Specification v1.7翻译(中
- P2P终结者安装包
- P2P金融借贷项目--部分文档
- P2P终结者破解版
- OMNET++IDE_P2P网络仿真的安装步骤(Wi
- p2p相关技术 论文
- ActiveMQ-P2P文本消息
- go仿QQ聊天程序
- Peersim合集模拟器、源码、原理讲解
- p2p对等网络ppt讲义(全)
- P2PSearch3.5版本
- p2pSearcher无限制版
- stm32控制nfcPN532模块进行P2P点对点通信
- paw_release_0.27.zip
- webRTC服务器端代码
评论
共有 条评论