OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
OverSim
OverSim API Reference
GPL
Todo List
Namespaces
Classes
Files
File List
AbstractLookup.h
AbstractSendStrategy.cc
AbstractSendStrategy.h
AccessNet.cc
AccessNet.h
ALMTest.cc
ALMTest.h
ALMTestTracedMessage_m.h
apptunoutscheduler.cc
apptunoutscheduler.h
AreaDataContainer.cc
AreaDataContainer.h
Bamboo.cc
Bamboo.h
base64.h
BaseApp.cc
BaseApp.h
BaseLocation.h
BaseOverlay.cc
BaseOverlay.h
BasePastry.cc
BasePastry.h
BaseRpc.cc
BaseRpc.h
BaseTcpSupport.cc
BaseTcpSupport.h
BinaryValue.cc
BinaryValue.h
BootstrapList.cc
BootstrapList.h
BootstrapListAccess.h
BootstrapNodeHandle.h
BoundingBox2D.cc
BoundingBox2D.h
Broose.cc
Broose.h
BrooseBucket.cc
BrooseBucket.h
BrooseHandle.cc
BrooseHandle.h
BrooseMessage_m.h
CBR-DHT.cc
CBR-DHT.h
CBR-DHTMessage_m.h
Chord.cc
Chord.h
ChordFingerTable.cc
ChordFingerTable.h
ChordMessage_m.h
ChordSuccessorList.cc
ChordSuccessorList.h
Churn_m.h
ChurnGenerator.cc
ChurnGenerator.h
ChurnGeneratorAccess.h
cnetcommbuffer.cc
cnetcommbuffer.h
combination.h
CommonMessages_m.h
Comparator.h
ConnectivityProbe.cc
ConnectivityProbe.h
ConnectivityProbeApp.cc
ConnectivityProbeApp.h
ConnectivityProbeQuon.cc
ConnectivityProbeQuon.h
ConnectReaSE.cc
ConnectReaSE.h
CoordBasedRouting.cc
CoordBasedRouting.h
CoordBasedRoutingAccess.h
CoordDataContainer.cc
CoordDataContainer.h
CoordinateSystem.cc
CoordinateSystem.h
CoordMessages_m.h
CryptoModule.cc
CryptoModule.h
DHT.cc
DHT.h
DHTDataStorage.cc
DHTDataStorage.h
DHTMessage_m.h
DHTTestApp.cc
DHTTestApp.h
DHTTestAppMessages_m.h
DiscoveryMode.cc
DiscoveryMode.h
DiscoveryMode_m.h
ExtAPIMessages_m.h
ExtTCPSocketMap.cc
ExtTCPSocketMap.h
FinisherModule.cc
FinisherModule.h
GenericPacketParser.cc
GenericPacketParser.h
Gia.cc
Gia.h
GiaKeyList.cc
GiaKeyList.h
GiaKeyListModule.cc
GiaKeyListModule.h
GiaMessage_m.h
GiaMessageBookkeeping.cc
GiaMessageBookkeeping.h
GiaNeighborCandidateList.cc
GiaNeighborCandidateList.h
GiaNeighbors.cc
GiaNeighbors.h
GiaNode.cc
GiaNode.h
GIASearchApp.cc
GIASearchApp.h
GiaTokenFactory.cc
GiaTokenFactory.h
GlobalCoordinator.cc
GlobalCoordinator.h
GlobalDhtTestMap.cc
GlobalDhtTestMap.h
GlobalNodeList.cc
GlobalNodeList.h
GlobalNodeListAccess.h
GlobalParameters.cc
GlobalParameters.h
GlobalParametersAccess.h
GlobalStatistics.cc
GlobalStatistics.h
GlobalStatisticsAccess.h
GlobalTraceManager.cc
GlobalTraceManager.h
GlobalTraceManager_m.h
GlobalViewBuilder.cc
GlobalViewBuilder.h
greatGathering.cc
greatGathering.h
groupRoaming.cc
groupRoaming.h
HashFunc.h
hashWatch.h
hotspotRoaming.cc
hotspotRoaming.h
I3.cc
I3.h
I3Anycast.cc
I3BaseApp.cc
I3BaseApp.h
I3Composite.cc
I3HostMobility.cc
I3Identifier.cc
I3Identifier.h
I3IdentifierStack.cc
I3IdentifierStack.h
I3IPAddress.cc
I3IPAddress.h
I3LatencyStretch.cc
I3Message.cc
I3Message.h
I3Message_m.h
I3Multicast.cc
I3Session.cc
I3SessionMessage_m.h
I3SubIdentifier.cc
I3SubIdentifier.h
I3Trigger.cc
I3Trigger.h
I3TriggerRoutingTime.cc
I3Triggers.cc
I3TriggersMessage_m.h
index.h
InetInfo.cc
InetInfo.h
InetUnderlayConfigurator.cc
InetUnderlayConfigurator.h
InitStages.h
IterativeLookup.cc
IterativeLookup.h
IterativeLookupConfiguration.h
Kademlia.cc
Kademlia.h
KademliaBucket.cc
KademliaBucket.h
KademliaMessage_m.h
KademliaNodeHandle.cc
KademliaNodeHandle.h
KBRTestApp.cc
KBRTestApp.h
KBRTestMessage_m.h
Koorde.cc
Koorde.h
Landmark.cc
Landmark.h
LifetimeChurn.cc
LifetimeChurn.h
LoginCache.cc
LoginCache.h
LookupListener.h
MessageObserver.cc
MessageObserver.h
MovementGenerator.cc
MovementGenerator.h
MyApplication.cc
MyApplication.h
MyMessage_m.h
MyOverlay.cc
MyOverlay.h
MyOverlay_m.h
NeighborCache.cc
NeighborCache.h
Nice.cc
Nice.h
NiceCluster.cc
NiceCluster.h
NiceMessage_m.h
NicePeerInfo.cc
NicePeerInfo.h
NoChurn.cc
NoChurn.h
NodeHandle.cc
NodeHandle.h
NodeVector.cc
NodeVector.h
Nps.cc
Nps.h
Nps_m.h
NTree.cc
NTree.h
NTree_m.h
NTreeHelper.cc
NTreeHelper.h
OverlayAccess.h
OverlayDummy.cc
OverlayKey.cc
OverlayKey.h
oversim_byteswap.h
oversim_mapset.h
OverSimMessage.cc
OverSimMessage.h
OverSimMessage_m.h
P2pns.cc
P2pns.h
P2pnsCache.cc
P2pnsCache.h
P2pnsMessage_m.h
PacketParser.h
ParetoChurn.cc
ParetoChurn.h
Pastry.cc
Pastry.h
PastryLeafSet.cc
PastryLeafSet.h
PastryMessage_m.h
PastryNeighborhoodSet.cc
PastryNeighborhoodSet.h
PastryRoutingTable.cc
PastryRoutingTable.h
PastryStateObject.cc
PastryStateObject.h
PastryTypes.h
PeerInfo.cc
PeerInfo.h
PeerStorage.cc
PeerStorage.h
ProximityLookupMessages_m.h
ProxNodeHandle.cc
ProxNodeHandle.h
PubSubLobby.cc
PubSubLobby.h
PubSubMessage_m.h
PubSubMMOG.cc
PubSubMMOG.h
PubSubSubspace.cc
PubSubSubspace.h
PubSubSubspaceId.cc
PubSubSubspaceId.h
Quon.cc
Quon.h
Quon_m.h
QuonDefs.h
QuonHelper.cc
QuonHelper.h
RandomChurn.cc
RandomChurn.h
randomRoaming.cc
randomRoaming.h
realtimescheduler.cc
realtimescheduler.h
RealworldApp.cc
RealworldApp.h
RealworldConnector.cc
RealworldConnector.h
RealworldDevice.cc
RealworldDevice.h
realWorldRoaming.cc
realWorldRoaming.h
RealWorldTestApp.cc
RealWorldTestApp.h
RealWorldTestMessage_m.h
RealWorldTestPacketParser.cc
RealWorldTestPacketParser.h
ReaSEInfo.cc
ReaSEInfo.h
ReaSEUnderlayConfigurator.cc
ReaSEUnderlayConfigurator.h
RecursiveLookup.cc
RecursiveLookup.h
RegionDataContainer.cc
RegionDataContainer.h
RpcListener.cc
RpcListener.h
RpcMacros.h
RpcState.h
RUNetworkConfigurator.cc
RUNetworkConfigurator.h
SCPacket.h
Scribe.cc
Scribe.h
ScribeGroup.cc
ScribeGroup.h
ScribeMessage_m.h
SearchMsgBookkeeping.cc
SearchMsgBookkeeping.h
SendStrategyFactory.cc
SendStrategyFactory.h
SHA1.cc
SHA1.h
SimMud.cc
SimMud.h
SimMud_m.h
SimpleCoordDataContainer.cc
SimpleCoordDataContainer.h
SimpleGameClient.cc
SimpleGameClient.h
SimpleGameClient_m.h
SimpleInfo.cc
SimpleInfo.h
SimpleNcs.cc
SimpleNcs.h
SimpleNodeEntry.cc
SimpleNodeEntry.h
SimpleTCP.cc
SimpleTCP.h
SimpleUDP.cc
SimpleUDP.h
SimpleUnderlayConfigurator.cc
SimpleUnderlayConfigurator.h
SimpleUnderlayNCS.cc
SimpleUnderlayNCS.h
simplex.cc
simplex.h
SingleHostUnderlayConfigurator.cc
SingleHostUnderlayConfigurator.h
StrategyRegions.cc
StrategyRegions.h
StrategyRemoveCoords.cc
StrategyRemoveCoords.h
StrategyRemoveInaccurate.cc
StrategyRemoveInaccurate.h
StrategyRemoveRandom.cc
StrategyRemoveRandom.h
StrategySendAll.cc
StrategySendAll.h
StrategySimplifyCoords.cc
StrategySimplifyCoords.h
StrategyTreeTest.cc
StrategyTreeTest.h
StringConvert.h
SVivaldi.cc
SVivaldi.h
TCPExampleApp.cc
TCPExampleApp.h
TCPExampleMessage_m.h
TierDummy.cc
TierDummy.h
TopologyVis.cc
TopologyVis.h
TraceChurn.cc
TraceChurn.h
TransportAddress.cc
TransportAddress.h
traverseRoaming.cc
traverseRoaming.h
TreeManagement.cc
TreeManagement.h
TreeManagementMessage_m.h
TriggerTable.cc
TriggerTable.h
TunOutDevice.cc
TunOutDevice.h
tunoutscheduler.cc
tunoutscheduler.h
UdpOutDevice.cc
UdpOutDevice.h
udpoutscheduler.cc
udpoutscheduler.h
UnderlayConfigurator.cc
UnderlayConfigurator.h
UnderlayConfiguratorAccess.h
Vast.cc
Vast.h
Vast_m.h
VastDefs.cc
VastDefs.h
Vector2D.cc
Vector2D.h
Vivaldi.cc
Vivaldi.h
XmlRpc.h
XmlRpcClient.cc
XmlRpcClient.h
XmlRpcDispatch.cc
XmlRpcDispatch.h
XmlRpcException.h
XmlRpcInterface.cc
XmlRpcInterface.h
XmlRpcMutex.cc
XmlRpcMutex.h
XmlRpcServer.cc
XmlRpcServer.h
XmlRpcServerConnection.cc
XmlRpcServerConnection.h
XmlRpcServerMethod.cc
XmlRpcServerMethod.h
XmlRpcSocket.cc
XmlRpcSocket.h
XmlRpcSource.cc
XmlRpcSource.h
XmlRpcThread.cc
XmlRpcThread.h
XmlRpcThreadedServer.cc
XmlRpcThreadedServer.h
XmlRpcUtil.cc
XmlRpcUtil.h
XmlRpcValue.cc
XmlRpcValue.h
yang.cc
yang.h
ZeroconfConnector.cc
ZeroconfConnector.h
File Members
MyApplication.cc
Go to the documentation of this file.
1
//
2
// Copyright (C) 2009 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3
//
4
// This program is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU General Public License
6
// as published by the Free Software Foundation; either version 2
7
// of the License, or (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
//
18
23
#include <string>
24
25
#include "
UnderlayConfigurator.h
"
26
#include "
GlobalStatistics.h
"
27
28
#include "
MyMessage_m.h
"
29
30
#include "
MyApplication.h
"
31
32
Define_Module
(
MyApplication
);
33
34
// initializeApp() is called when the module is being created.
35
// Use this function instead of the constructor for initializing variables.
36
void
MyApplication::initializeApp
(
int
stage)
37
{
38
// initializeApp will be called twice, each with a different stage.
39
// stage can be either MIN_STAGE_APP (this module is being created),
40
// or MAX_STAGE_APP (all modules were created).
41
// We only care about MIN_STAGE_APP here.
42
43
if
(stage !=
MIN_STAGE_APP
)
return
;
44
45
// copy the module parameter values to our own variables
46
sendPeriod
= par(
"sendPeriod"
);
47
numToSend
= par(
"numToSend"
);
48
largestKey
= par(
"largestKey"
);
49
50
// initialize our statistics variables
51
numSent
= 0;
52
numReceived
= 0;
53
54
// tell the GUI to display our variables
55
WATCH(
numSent
);
56
WATCH(
numReceived
);
57
58
// start our timer!
59
timerMsg
=
new
cMessage(
"MyApplication Timer"
);
60
scheduleAt(simTime() +
sendPeriod
,
timerMsg
);
61
62
bindToPort
(2000);
63
}
64
65
66
// finish is called when the module is being destroyed
67
void
MyApplication::finishApp
()
68
{
69
// finish() is usually used to save the module's statistics.
70
// We'll use globalStatistics->addStdDev(), which will calculate min, max, mean and deviation values.
71
// The first parameter is a name for the value, you can use any name you like (use a name you can find quickly!).
72
// In the end, the simulator will mix together all values, from all nodes, with the same name.
73
74
globalStatistics
->
addStdDev
(
"MyApplication: Sent packets"
,
numSent
);
75
globalStatistics
->
addStdDev
(
"MyApplication: Received packets"
,
numReceived
);
76
}
77
78
79
// handleTimerEvent is called when a timer event triggers
80
void
MyApplication::handleTimerEvent
(cMessage* msg)
81
{
82
// is this our timer?
83
if
(msg ==
timerMsg
) {
84
// reschedule our message
85
scheduleAt(simTime() +
sendPeriod
,
timerMsg
);
86
87
// if the simulator is still busy creating the network,
88
// let's wait a bit longer
89
if
(
underlayConfigurator
->
isInInitPhase
())
return
;
90
91
for
(
int
i = 0; i <
numToSend
; i++) {
92
93
// let's create a random key
94
OverlayKey
randomKey(intuniform(1,
largestKey
));
95
96
MyMessage
*myMessage;
// the message we'll send
97
myMessage =
new
MyMessage
();
98
myMessage->
setType
(
MYMSG_PING
);
// set the message type to PING
99
myMessage->
setSenderAddress
(
thisNode
);
// set the sender address to our own
100
myMessage->setByteLength(100);
// set the message length to 100 bytes
101
102
numSent
++;
// update statistics
103
104
EV <<
thisNode
.
getIp
() <<
": Sending packet to "
105
<< randomKey <<
"!"
<< std::endl;
106
107
callRoute
(randomKey, myMessage);
// send it to the overlay
108
}
109
}
else
{
110
// unknown message types are discarded
111
delete
msg;
112
}
113
}
114
115
// deliver() is called when we receive a message from the overlay.
116
// Unknown packets can be safely deleted here.
117
void
MyApplication::deliver
(
OverlayKey
& key, cMessage* msg)
118
{
119
// we are only expecting messages of type MyMessage, throw away any other
120
MyMessage
*myMsg =
dynamic_cast<
MyMessage
*
>
(msg);
121
if
(myMsg == NULL) {
122
delete
msg;
// type unknown!
123
return
;
124
}
125
126
// are we a PING? send a PONG!
127
if
(myMsg->
getType
() ==
MYMSG_PING
) {
128
myMsg->
setType
(
MYMSG_PONG
);
// change type
129
130
EV <<
thisNode
.
getIp
() <<
": Got packet from "
131
<< myMsg->
getSenderAddress
() <<
", sending back!"
132
<< std::endl;
133
134
// send it back to its owner
135
sendMessageToUDP
(myMsg->
getSenderAddress
(), myMsg);
136
}
else
{
137
// only handle PING messages
138
delete
msg;
139
}
140
}
141
142
// handleUDPMessage() is called when we receive a message from UDP.
143
// Unknown packets can be safely deleted here.
144
void
MyApplication::handleUDPMessage
(cMessage* msg)
145
{
146
// we are only expecting messages of type MyMessage
147
MyMessage
*myMsg =
dynamic_cast<
MyMessage
*
>
(msg);
148
149
if
(myMsg && myMsg->
getType
() ==
MYMSG_PONG
) {
150
EV <<
thisNode
.
getIp
() <<
": Got reply!"
<< std::endl;
151
numReceived
++;
152
}
153
154
// Message isn't needed any more -> delete it
155
delete
msg;
156
}
src
applications
myapplication
MyApplication.cc
Generated on Fri Dec 7 2012 13:37:52 for OverSim by
1.8.1.2