• Tidak ada hasil yang ditemukan

BAB V KESIMPULAN DAN SARAN

5.2. Saran

Dengan mengadopsi mekanisme pengiriman pesan berdasarkan nilai ketertarikan (interest) pesan dapat menjadi salah satu pilihan dalam pemilihan routing protokol dijaringan sosial oportunistik. Kemudian dengan mengadopsi mekanisme tersebut dapat dicoba diterapkan dengan routing protokol lainnya. Selain itu, dapat juga dimainkan jumlah nilai ketertarikan (interest) pada simulasi dengan menambahkan atau mengurangi jumlah interest.

DAFTAR PUSTAKA

[1] K. A. H. C. Almeroth, "Transport Layer Issues in Delay Tolerant Mobile Networks," in NETWORKING 2006. Networking Technologies, Services, Protocols; Performance of Computer and Communication Networks; Mobile and Wireless Communications Systems, Springer, Berlin, Heidelberg, 2006, pp. 463-475.

[2] Kevin Fall Intel Research, Berkeley, CA, "A Delay-Tolerant Network Architecture for Challenged," in Applications, technologies, architectures, and protocols for computer communications, Karlsruhe, Germany, August 25 - 29, 2003.

[3] P. Puri and M. P. Singh, "A survey paper on routing in delay-tolerant networks," in International Conference on Information Systems and Computer Networks, Mathura, India , 2013.

[4] W. Moreira, "Social-Aware Opportunistic Routing Protocol Based on User’s Interactions and Interests," in Ad Hoc Networks, Barcelona, Spain, Springer, Cham, 2014, pp. 100-115.

[5] Becker, Amin Vahdat and David Department of Computer Science, "Epidemic Routing for Partially-Connected Ad Hoc Networks," Durham, NC 27708, 2000.

LAMPIRAN 1. MessageRouter

/**

* @author Junandus Sijabat * Sanata Dharma University */

/** group of interest */

public static final String CONTENT_PROPERTY = "interest"; protected String nodeInterest;

protected String interest;

public MessageRouter(Settings s) { /** Mengambil Nilai Interest dari settings*/ nodeInterest = s.getSetting("nodeList"); }

public void init(DTNHost host, List<MessageListener> mListeners) { /** mengambil nilai interest untuk setiap node */

String[] splittednodeList = nodeInterest.split("/"); for (String string : splittednodeList) {

String [] temp = string.split(":"); String val = temp[0];

String[] nodeInter = temp[1].split(","); for (String stringKey : nodeInter) { int temp2 = Integer.parseInt(stringKey); if (temp2 == host.getAddress()) { interest = val; }}}} protected MessageRouter(MessageRouter r) { this.nodeInterest = r.nodeInterest; }

public String getInterest() { return interest; }

2. Epidemic WithoutInterest

/**

* @author Junandus Sijabat * Sanata Dharma University */

public class EpidemicWithoutInterest implements routing.RoutingDecisionEngine { public static final String CONTENT_PROPERTY = "interest";

public EpidemicWithoutInterest(EpidemicWithoutInterest proto) {} @Override

public void connectionUp(DTNHost thisHost, DTNHost peer, String interest) {} @Override

public void connectionDown(DTNHost thisHost, DTNHost peer, String interest) {} @Override

public void doExchangeForNewConnection(Connection con, DTNHost peer, String interest) {} @Override

public boolean newMessage(Message m, String interest) { m.addProperty(CONTENT_PROPERTY, interest); return true;

} @Override

public boolean isFinalDest(Message m, DTNHost aHost, String interest) { return m.getTo() == aHost;

} @Override

public boolean shouldSaveReceivedMessage(Message m, DTNHost thisHost, String interest) { return true;

} @Override

public boolean shouldSendMessageToHost(Message m, DTNHost otherHost, String interest) { return true;

} @Override

public boolean shouldDeleteSentMessage(Message m, DTNHost otherHost, String interest) { return false;

} @Override

public boolean shouldDeleteOldMessage(Message m, DTNHost hostReportingOld, String interest) { return true;

} @Override

public RoutingDecisionEngine replicate() { return new EpidemicWithoutInterest(this); }

private EpidemicWithoutInterest getOtherDecisionEngine(DTNHost h){ MessageRouter otherRouter = h.getRouter();

assert otherRouter instanceof DecisionEngineRouter : "This router only works " + " with other routers of same type";

return (EpidemicWithoutInterest) ((DecisionEngineRouter)otherRouter).getDecisionEngine(); } } 3. Epidemic WithInterest /**

* @author Junandus Sijabat * Sanata Dharma University */

public class EpidemicWithInterest implements routing.RoutingDecisionEngine { public static final String CONTENT_PROPERTY = "interest";

public EpidemicWithInterest(Settings s) {}

public EpidemicWithInterest(EpidemicWithInterest proto) {} @Override

public void connectionUp(DTNHost thisHost, DTNHost peer, String interest) {} @Override

public void connectionDown(DTNHost thisHost, DTNHost peer, String interest) {} @Override

public void doExchangeForNewConnection(Connection con, DTNHost peer, String interest) {} @Override

public boolean newMessage(Message m, String interest) { m.addProperty(CONTENT_PROPERTY, interest); return true;

} @Override

public boolean isFinalDest(Message m, DTNHost aHost, String interest) { return m.getTo() == aHost;}

@Override

public boolean shouldSaveReceivedMessage(Message m, DTNHost thisHost, String interest) { return true;

} @Override

public boolean shouldSendMessageToHost(Message m, DTNHost otherHost, String interest) { DecisionEngineRouter peer = (DecisionEngineRouter) (otherHost.getRouter());

return m.getProperty(CONTENT_PROPERTY).equals(peer.getInterest()); }

@Override

public boolean shouldDeleteSentMessage(Message m, DTNHost otherHost, String interest) { return false;

} @Override

public boolean shouldDeleteOldMessage(Message m, DTNHost hostReportingOld, String interest) { return true;

}

private EpidemicWithInterest getOtherDecisionEngine(DTNHost h) { MessageRouter otherRouter = h.getRouter();

assert otherRouter instanceof DecisionEngineRouter : "This router only works " + " with other routers of same type";

return (EpidemicWithInterest) ((DecisionEngineRouter) otherRouter).getDecisionEngine(); }

@Override

public RoutingDecisionEngine replicate() { return new EpidemicWithInterest(this); }

}

4. Epidemic WithInterestCommunity /**

* @author Junandus Sijabat * Sanata Dharma University */

public class EpidemicWithInterestCommunity implements routing.RoutingDecisionEngine, CommunityDetectionEngine {

public static final String COMMUNITY_ALG_SETTING = "communityDetectAlg"; public static final String CONTENT_PROPERTY = "interest";

protected CommunityDetection community;

protected Map<DTNHost, Double> startTimestamps; protected Map<DTNHost, List<Duration>> connHistory; protected Map<DTNHost, String> ListInterest;

public EpidemicWithInterestCommunity(Settings s) { if (s.contains(COMMUNITY_ALG_SETTING)) {

this.community = (CommunityDetection) s.createIntializedObject(s.getSetting(COMMUNITY_ALG_SETTING));

} else {

this.community = new SimpleCommunityDetection(s); }

}

public EpidemicWithInterestCommunity(EpidemicWithInterestCommunity proto) { this.community = proto.community.replicate();

startTimestamps = new HashMap<DTNHost, Double>(); connHistory = new HashMap<DTNHost, List<Duration>>(); ListInterest = new HashMap<DTNHost, String>();

@Override

public void connectionUp(DTNHost thisHost, DTNHost peer, String interest) {} @Override

public void connectionDown(DTNHost thisHost, DTNHost peer, String interest) { DecisionEngineRouter otherHost = (DecisionEngineRouter) (peer.getRouter()); double time = startTimestamps.get(peer);

double etime = SimClock.getTime(); List<Duration> history;

if (!connHistory.containsKey(peer)) { history = new LinkedList<>(); connHistory.put(peer, history); } else {

history = connHistory.get(peer); }

if (etime - time > 0) {

history.add(new Duration(time, etime)); if (!ListInterest.containsKey(peer)) {

ListInterest.put(peer, otherHost.getInterest()); }

//System.out.println(ListInterest); }

CommunityDetection peerCD = this.getOtherDecisionEngine(peer).community; community.connectionLost(thisHost, peer, peerCD, history);

startTimestamps.remove(peer); }

@Override

public void doExchangeForNewConnection(Connection con, DTNHost peer, String interest) { DTNHost myHost = con.getOtherNode(peer);

EpidemicWithInterestCommunity Epic = this.getOtherDecisionEngine(peer); this.startTimestamps.put(peer, SimClock.getTime());

Epic.startTimestamps.put(myHost, SimClock.getTime()); this.community.newConnection(myHost, peer, Epic.community); }

@Override

public boolean newMessage(Message m, String interest) { m.addProperty(CONTENT_PROPERTY, interest); return true;

} @Override

public boolean isFinalDest(Message m, DTNHost aHost, String interest) { return m.getTo() == aHost;

} @Override

public boolean shouldSaveReceivedMessage(Message m, DTNHost thisHost, String interest) { return true;

} @Override

public boolean shouldSendMessageToHost(Message m, DTNHost otherHost, String interest) { DTNHost thisHost = null;

List<DTNHost> listHop = m.getHops(); Iterator it = listHop.iterator();

while (it.hasNext()) {

thisHost = (DTNHost) it.next(); }

DecisionEngineRouter peer = (DecisionEngineRouter) (otherHost.getRouter()); DecisionEngineRouter me = (DecisionEngineRouter) (thisHost.getRouter()); EpidemicWithInterestCommunity epic = getOtherDecisionEngine(otherHost); if(m.getProperty(CONTENT_PROPERTY).equals(peer.getInterest())){ return true; } Set<DTNHost> Ls = epic.getLocalCommunity(); for (DTNHost L : Ls) { if((L.getAddress()!=thisHost.getAddress()&&L.getRouter().getInterest().equals(m.getProperty(CO NTENT_PROPERTY)))){ return true; } } return false; } @Override

public boolean shouldDeleteSentMessage(Message m, DTNHost otherHost, String interest) { return false;

} @Override

public boolean shouldDeleteOldMessage(Message m, DTNHost hostReportingOld, String interest) { return true;

}

protected boolean commumesWithHost(DTNHost h) { return community.isHostInCommunity(h);

} @Override

public Set<DTNHost> getLocalCommunity() { return this.community.getLocalCommunity(); }

@Override

public RoutingDecisionEngine replicate() {

return new EpidemicWithInterestCommunity(this); }

private EpidemicWithInterestCommunity getOtherDecisionEngine(DTNHost h) { MessageRouter otherRouter = h.getRouter();

assert otherRouter instanceof DecisionEngineRouter : "This router only works " + " with other routers of same type";

return (EpidemicWithInterestCommunity) ((DecisionEngineRouter) otherRouter).getDecisionEngine();

} }

5. AllReport

/**

* @author Junandus Sijabat * Sanata Dharma University */

public class AllReport extends Report implements MessageListener{ private int DeliveredInterest;

private int nrofRelayed;

private Map <String, ConvergenceData>ConvergenceTimeInterest; public AllReport(){

init(); } @Override

protected void init(){ super.init();

DeliveredInterest = 0; nrofRelayed = 0;

ConvergenceTimeInterest = new HashMap<String , ConvergenceData>(); }

@Override

public void newMessage(Message m) {} @Override

public void messageTransferStarted(Message m, DTNHost from, DTNHost to) {} @Override

public void messageDeleted(Message m, DTNHost where, boolean dropped) {} @Override

public void messageTransferAborted(Message m, DTNHost from, DTNHost to) {} @Override

public void messageTransferred(Message m, DTNHost from, DTNHost to, boolean firstDelivery) { nrofRelayed++;

MessageRouter otherRouter = to.getRouter();

DecisionEngineRouter epic = (DecisionEngineRouter)otherRouter; if(m.getProperty("interest").equals(epic.getInterest())){

DeliveredInterest++;

if (ConvergenceTimeInterest.containsKey(m.getId())) {

ConvergenceData d = ConvergenceTimeInterest.get(m.getId()); Set<DTNHost> nodeList = d.getNodeList();

if (!nodeList.contains(to)) { nodeList.add(to); d.setNodeList(nodeList); d.setConvergenceTime(d.getConvergenceTime() + (getSimTime() - m.getCreationTime())); d.setLastNodeTime(getSimTime() - m.getCreationTime()); ConvergenceTimeInterest.replace(m.getId(), d); } } else {

ConvergenceData d = new ConvergenceData(); d.setSource(from);

d.setConvergenceTime(getSimTime() - m.getCreationTime()); d.setLastNodeTime(getSimTime() - m.getCreationTime()); Set<DTNHost> nodeList = new HashSet<>();

nodeList.add(to); d.setNodeList(nodeList); ConvergenceTimeInterest.put(m.getId(), d); } } } @Override public void done() {

Settings s = new Settings();

int nrofNode = s.getInt("Group.nrofHosts") - 1; String report = "";

/*write("Convergence Report\nSource Node\tMessage ID\tConvergenceTime\t\tLast Node Time\tNumber Of Node");

for (Map.Entry<String, ConvergenceData> e : convergenceTime.entrySet()) { String m = e.getKey();

report = report+v.getSource()+"\t\t"+m+"\t\t"+v.getConvergenceTime()/v.getNodeList().size()+"\t"+v.getLa stNodeTime()+"\t\t"+v.getNodeList().size()+"\n"; }*/ double avgConvTime = 0; double lastUpdateTime = 0; double nrofInfected = 0;

for (Map.Entry<String, ConvergenceData> e : ConvergenceTimeInterest.entrySet()) { ConvergenceData v = e.getValue();

avgConvTime += v.getConvergenceTime() / v.getNodeList().size(); lastUpdateTime += v.getLastNodeTime();

nrofInfected += v.getNodeList().size(); }

int TotalCopyForward = nrofRelayed - DeliveredInterest; report += "Message Relayed = " + nrofRelayed + "\n"

+ "Average Convergence Time = " + avgConvTime / ConvergenceTimeInterest.size() + "\n"

+ "Totl Delivered Interest = " + DeliveredInterest + "\n" + "Total Relayed = " + TotalCopyForward + "\n"; write(report);

super.done(); }

Dokumen terkait