├── data ├── cluster │ ├── origin.wkt │ └── ferryroute.wkt ├── HelsinkiMedium │ ├── B_meetingspots.wkt │ ├── C_meetingspots.wkt │ ├── D_meetingspots.wkt │ ├── E_meetingspots.wkt │ ├── A_meetingspots.wkt │ ├── F_meetingspots.wkt │ ├── G_meetingspots.wkt │ ├── D_bus.wkt │ ├── A_bus.wkt │ ├── C_bus.wkt │ ├── E_bus.wkt │ ├── B_offices.wkt │ ├── F_bus.wkt │ ├── B_bus.wkt │ ├── G_bus.wkt │ ├── H_bus.wkt │ ├── D_offices.wkt │ ├── C_offices.wkt │ ├── E_offices.wkt │ ├── A_offices.wkt │ ├── G_offices.wkt │ └── F_offices.wkt ├── helsinki_underlay.png ├── WestPOIs.wkt ├── CentralPOIs.wkt ├── tram10.wkt ├── throwboxes.wkt ├── tram4.wkt ├── tram3.wkt ├── ParkPOIs.wkt ├── Manhattan │ └── bus.wkt ├── demo_bus.wkt └── pedestrian_paths.wkt ├── lib ├── ECLA.jar └── DTNConsoleConnection.jar ├── one.bat ├── example_settings ├── epidemic_settings.txt ├── snw_settings.txt ├── connect_connector_test.txt ├── snw_comparison_settings.txt ├── ping_app_settings.txt ├── wlan-interface.txt └── prophet_settings.txt ├── one.sh ├── src ├── gui │ ├── buttonGraphics │ │ ├── Play16.gif │ │ ├── Play24.gif │ │ ├── Zoom16.gif │ │ ├── Zoom24.gif │ │ ├── Pause16.gif │ │ ├── Pause24.gif │ │ ├── FastForward16.gif │ │ ├── FastForward24.gif │ │ ├── StepForward16.gif │ │ └── StepForward24.gif │ ├── package.html │ ├── playfield │ │ ├── package.html │ │ ├── MessageGraphic.java │ │ ├── MapGraphic.java │ │ ├── PathGraphic.java │ │ ├── ScaleReferenceGraphic.java │ │ └── PlayFieldGraphic.java │ ├── nodefilter │ │ ├── NodeFilter.java │ │ └── NodeMessageFilter.java │ └── EventLogControl.java ├── util │ ├── package.html │ ├── Tuple.java │ ├── ParetoRNG.java │ └── Range.java ├── routing │ ├── maxprop │ │ └── package.html │ ├── package.html │ ├── DirectDeliveryRouter.java │ ├── PassiveRouter.java │ ├── EpidemicRouter.java │ ├── util │ │ └── RoutingInfo.java │ ├── FirstContactRouter.java │ └── schedule │ │ ├── ScheduleEntry.java │ │ └── ScheduleOracle.java ├── test │ ├── package.html │ ├── CoordTest.java │ ├── MessageTest.java │ ├── StationaryMovement.java │ ├── WKTPointReaderTest.java │ ├── ActivenessHandlerTest.java │ ├── TestSettings.java │ ├── TestDTNHost.java │ ├── AllTests.java │ ├── ExternalMovementReaderTest.java │ ├── MessageGraphvizReportTest.java │ ├── MapNodeTest.java │ ├── DijkstraPathFinderTest.java │ ├── TestInterface.java │ └── DistanceDelayReportTest.java ├── ui │ ├── package.html │ └── DTNSimTextUI.java ├── input │ ├── package.html │ ├── ExternalEventsReader.java │ ├── EventQueue.java │ ├── MessageEvent.java │ ├── MessageDeleteEvent.java │ ├── MessageCreateEvent.java │ ├── ConnectionEvent.java │ ├── ExternalEvent.java │ ├── MessageRelayEvent.java │ ├── OneToEachMessageGenerator.java │ └── OneFromEachMessageGenerator.java ├── movement │ ├── map │ │ └── package.html │ ├── TransportMovement.java │ ├── package.html │ ├── SwitchableMovement.java │ ├── ModifiedRandomDirection.java │ ├── RandomWaypoint.java │ ├── StationaryMovement.java │ ├── CarMovement.java │ ├── ClusterMovement.java │ ├── RandomWalk.java │ ├── ShortestPathMapBasedMovement.java │ ├── BusMovement.java │ └── ExtendedMovementModel.java ├── core │ ├── Constants.java │ ├── package.html │ ├── SettingsError.java │ ├── SimError.java │ ├── ModuleCommunicationListener.java │ ├── UpdateListener.java │ ├── ConnectionListener.java │ ├── MovementListener.java │ ├── ApplicationListener.java │ ├── MessageListener.java │ ├── SimClock.java │ └── ArithmeticCondition.java ├── report │ ├── package.html │ ├── LocationSnapshotReport.java │ ├── MovementListenerTestReport.java │ ├── EnergyLevelReport.java │ ├── InterContactTimesReport.java │ ├── MessageCopyCountReport.java │ ├── ContactsPerHourReport.java │ ├── CreatedMessagesReport.java │ ├── MessageReport.java │ ├── TotalEncountersReport.java │ ├── ConnectivityDtnsim2Report.java │ ├── EncountersVSUniqueEncountersReport.java │ ├── ConnectivityONEReport.java │ ├── MessageDeliveryReport.java │ ├── UniqueEncountersReport.java │ ├── MessageDelayReport.java │ ├── MessageGraphvizReport.java │ ├── DeliveredMessagesReport.java │ ├── PingAppReporter.java │ ├── TotalContactTimeReport.java │ └── BufferOccupancyReport.java └── interfaces │ └── ConnectivityOptimizer.java ├── target └── gui │ └── buttonGraphics │ ├── Pause16.gif │ ├── Pause24.gif │ ├── Play16.gif │ ├── Play24.gif │ ├── Zoom16.gif │ ├── Zoom24.gif │ ├── FastForward16.gif │ ├── FastForward24.gif │ ├── StepForward16.gif │ └── StepForward24.gif ├── toolkit ├── dtnsim2patches │ ├── README.txt │ ├── DummyEpidemicHandler.java.diff │ └── EpidemicKnowledgeHandler.java.diff ├── messageAvailabilityAnalyzer.pl ├── Common.pm ├── createCircles.pl ├── transimsParser.pl ├── messageCopyCountPlotter.pl ├── dtnsim2parser.pl ├── getAverages.pl ├── getStatsAverages.pl ├── createCreates.pl └── delProb.pl ├── doc └── create_docs.sh ├── .gitignore ├── README.md ├── compile.sh ├── .gitattributes ├── compile.bat ├── CONTRIBUTING.md ├── wdm_settings └── WDM_conf_help.txt └── ee └── 70_events_100_nodes_700ks.txt /data/cluster/origin.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (0 0, 100 -100) 2 | -------------------------------------------------------------------------------- /lib/ECLA.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/lib/ECLA.jar -------------------------------------------------------------------------------- /data/cluster/ferryroute.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (100 -100, 600 -100, 350 -533, 100 -100) 2 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/B_meetingspots.wkt: -------------------------------------------------------------------------------- 1 | POINT (2548669.62194887 6672165.182219516) 2 | -------------------------------------------------------------------------------- /one.bat: -------------------------------------------------------------------------------- 1 | java -Xmx512M -cp target;lib/ECLA.jar;lib/DTNConsoleConnection.jar core.DTNSim %* -------------------------------------------------------------------------------- /example_settings/epidemic_settings.txt: -------------------------------------------------------------------------------- 1 | Scenario.name = Epidemic 2 | Group.router = EpidemicRouter 3 | -------------------------------------------------------------------------------- /data/helsinki_underlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/data/helsinki_underlay.png -------------------------------------------------------------------------------- /lib/DTNConsoleConnection.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/lib/DTNConsoleConnection.jar -------------------------------------------------------------------------------- /one.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | java -Xmx512M -cp target:lib/ECLA.jar:lib/DTNConsoleConnection.jar core.DTNSim $* 3 | -------------------------------------------------------------------------------- /src/gui/buttonGraphics/Play16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/src/gui/buttonGraphics/Play16.gif -------------------------------------------------------------------------------- /src/gui/buttonGraphics/Play24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/src/gui/buttonGraphics/Play24.gif -------------------------------------------------------------------------------- /src/gui/buttonGraphics/Zoom16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/src/gui/buttonGraphics/Zoom16.gif -------------------------------------------------------------------------------- /src/gui/buttonGraphics/Zoom24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/src/gui/buttonGraphics/Zoom24.gif -------------------------------------------------------------------------------- /src/gui/buttonGraphics/Pause16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/src/gui/buttonGraphics/Pause16.gif -------------------------------------------------------------------------------- /src/gui/buttonGraphics/Pause24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/src/gui/buttonGraphics/Pause24.gif -------------------------------------------------------------------------------- /target/gui/buttonGraphics/Pause16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/target/gui/buttonGraphics/Pause16.gif -------------------------------------------------------------------------------- /target/gui/buttonGraphics/Pause24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/target/gui/buttonGraphics/Pause24.gif -------------------------------------------------------------------------------- /target/gui/buttonGraphics/Play16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/target/gui/buttonGraphics/Play16.gif -------------------------------------------------------------------------------- /target/gui/buttonGraphics/Play24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/target/gui/buttonGraphics/Play24.gif -------------------------------------------------------------------------------- /target/gui/buttonGraphics/Zoom16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/target/gui/buttonGraphics/Zoom16.gif -------------------------------------------------------------------------------- /target/gui/buttonGraphics/Zoom24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/target/gui/buttonGraphics/Zoom24.gif -------------------------------------------------------------------------------- /toolkit/dtnsim2patches/README.txt: -------------------------------------------------------------------------------- 1 | Patches that have to be applied to dtnsim2 sources for dtnsim2parser to work properly. 2 | -------------------------------------------------------------------------------- /src/gui/buttonGraphics/FastForward16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/src/gui/buttonGraphics/FastForward16.gif -------------------------------------------------------------------------------- /src/gui/buttonGraphics/FastForward24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/src/gui/buttonGraphics/FastForward24.gif -------------------------------------------------------------------------------- /src/gui/buttonGraphics/StepForward16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/src/gui/buttonGraphics/StepForward16.gif -------------------------------------------------------------------------------- /src/gui/buttonGraphics/StepForward24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/src/gui/buttonGraphics/StepForward24.gif -------------------------------------------------------------------------------- /target/gui/buttonGraphics/FastForward16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/target/gui/buttonGraphics/FastForward16.gif -------------------------------------------------------------------------------- /target/gui/buttonGraphics/FastForward24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/target/gui/buttonGraphics/FastForward24.gif -------------------------------------------------------------------------------- /target/gui/buttonGraphics/StepForward16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/target/gui/buttonGraphics/StepForward16.gif -------------------------------------------------------------------------------- /target/gui/buttonGraphics/StepForward24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akeranen/the-one/HEAD/target/gui/buttonGraphics/StepForward24.gif -------------------------------------------------------------------------------- /data/HelsinkiMedium/C_meetingspots.wkt: -------------------------------------------------------------------------------- 1 | POINT (2551019.4859670075 6675223.744247892) 2 | 3 | POINT (2551776.083972117 6676132.332795221) 4 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/D_meetingspots.wkt: -------------------------------------------------------------------------------- 1 | POINT (2553423.037969719 6674726.15003564) 2 | 3 | POINT (2551506.1838812567 6676962.873428298) 4 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/E_meetingspots.wkt: -------------------------------------------------------------------------------- 1 | POINT (2552080.145394281 6673330.999808344) 2 | 3 | POINT (2552531.1145652616 6673268.445450311) 4 | -------------------------------------------------------------------------------- /data/WestPOIs.wkt: -------------------------------------------------------------------------------- 1 | POINT (2550854.3137440286 6672591.750129179) 2 | 3 | POINT (2551121.9534618445 6672693.903576347) 4 | 5 | POINT (2550700.913609861 6672866.723243455) 6 | -------------------------------------------------------------------------------- /example_settings/snw_settings.txt: -------------------------------------------------------------------------------- 1 | Scenario.name = SprayAndWait 2 | Group.router = SprayAndWaitRouter 3 | SprayAndWaitRouter.nrofCopies = 10 4 | SprayAndWaitRouter.binaryMode = true 5 | -------------------------------------------------------------------------------- /doc/create_docs.sh: -------------------------------------------------------------------------------- 1 | javadoc -classpath ../target:../lib/ECLA.jar:../lib/DTNConsoleConnection.jar -sourcepath ../src/ -subpackages core:ui:gui:input:movement:report:routing:applications:interfaces:util 2 | -------------------------------------------------------------------------------- /src/gui/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | Contains the classes of Graphical User Interface. 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Contains utility classes used in different contexts. 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/routing/maxprop/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Contains MaxProp routing module specific classes. 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/test/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Provides some unit and integration tests for the classes. 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /data/CentralPOIs.wkt: -------------------------------------------------------------------------------- 1 | POINT (2552448.388211649 6673384.4020657055) 2 | 3 | POINT (2552275.9398973365 6673509.820852942) 4 | 5 | POINT (2552361.289603607 6673630.088457832) 6 | 7 | POINT (2552782.3212060533 6673285.5993876355) 8 | -------------------------------------------------------------------------------- /src/ui/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Contains superclass for all user interfaces and a simple user interface(s). 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/input/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Provides interfaces and classes for reading input data from external sources. 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/A_meetingspots.wkt: -------------------------------------------------------------------------------- 1 | POINT (2551832.205570006 6673236.458108292) 2 | 3 | POINT (2552398.0412894213 6673352.814815518) 4 | 5 | POINT (2552271.1386670014 6673506.220026447) 6 | 7 | POINT (2552747.310172474 6672343.373119477) 8 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/F_meetingspots.wkt: -------------------------------------------------------------------------------- 1 | POINT (2551753.9422157253 6673510.250951662) 2 | 3 | POINT (2552669.1210640236 6673406.247079767) 4 | 5 | POINT (2550808.454569743 6675266.964168113) 6 | 7 | POINT (2550105.5033015246 6676255.961171506) 8 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/G_meetingspots.wkt: -------------------------------------------------------------------------------- 1 | POINT (2552399.5592041663 6675863.2110239975) 2 | 3 | POINT (2552122.746001586 6673002.154328803) 4 | 5 | POINT (2552677.906820565 6673285.539373861) 6 | 7 | POINT (2552459.211603745 6673074.480929848) 8 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/D_bus.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (2553320.273491563 6674457.528379207, 2553719.84804916 6675104.546888653, 2553670.9035481643 6675714.12680486, 2553683.145860566 6676146.346011659, 2553528.33505563 6676650.701775882, 2553727.5943640824 6677300.7809878485) 2 | -------------------------------------------------------------------------------- /src/movement/map/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Sub package for MapBasedMovement movement model's (and its sub classes) 6 | helper classes. 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /data/tram10.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (2552787.726166266 6672530.040305593, 2552686.56058452 6672754.707532612, 2552579.465099618 6673027.760206092, 2552440.104393391 6673297.548247428, 2552172.432960881 6673639.590638857, 2551943.3598269443 6674056.316289438, 2551761.5729668215 6674388.38925647) 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled files 2 | *.class 3 | 4 | # Simulation report files 5 | *reports*/*.txt 6 | 7 | # Javadocs 8 | *.html 9 | doc/stylesheet.css 10 | doc/resources/*.gif 11 | doc/package-list 12 | 13 | # Eclipse IDE files 14 | .classpath 15 | .project 16 | /target/ 17 | .settings/org.eclipse.* 18 | -------------------------------------------------------------------------------- /toolkit/dtnsim2patches/DummyEpidemicHandler.java.diff: -------------------------------------------------------------------------------- 1 | 255c255,256 2 | < network.vprint("Removing copy of " + m + " - ACKed or delivered to final destination."); 3 | --- 4 | > network.vprint("Removing copy of " + m + " at " + this.parent.getName()); 5 | > // ACKed or delivered to final destination. 6 | -------------------------------------------------------------------------------- /src/gui/playfield/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Contains the classes of Graphical User Interface's playfield -view 6 | (the graphical presentation of the nodes' locations and other information). 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example_settings/connect_connector_test.txt: -------------------------------------------------------------------------------- 1 | Report.nrofReports = 1 2 | Report.report1 = ConnectivityReportConnector 3 | ConnectivityReportConnector.address = localhost 4 | ConnectivityReportConnector.port = 50042 5 | # How many digits in connection speed 6 | ConnectivityReportConnector.precision = 0 7 | 8 | Optimization.realtime = true -------------------------------------------------------------------------------- /src/core/Constants.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | /** 4 | * Global constants. 5 | * 6 | * @author teemuk 7 | */ 8 | public final class Constants { 9 | /** Disallow instantiation */ 10 | private Constants() {} 11 | 12 | /** Enable/disable debug mode. Used to compile out debug logging etc. */ 13 | public static final boolean DEBUG = false; 14 | } 15 | -------------------------------------------------------------------------------- /data/throwboxes.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (2553039.1292822366 6673301.743093083) 2 | 3 | LINESTRING (2552275.9398973365 6673509.820852942) 4 | 5 | LINESTRING (2552559.517719977 6673146.45745054) 6 | 7 | LINESTRING (2552017.9191392646 6673946.871168619) 8 | 9 | LINESTRING (2551949.8274636846 6673239.518810811) 10 | 11 | LINESTRING (2552473.318311431 6673253.912114491) 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The ONE 2 | 3 | The Opportunistic Network Environment simulator. 4 | 5 | For introduction and releases, see [the ONE homepage at GitHub](http://akeranen.github.io/the-one/). 6 | 7 | For instructions on how to get started, see [the README](https://github.com/akeranen/the-one/wiki/README). 8 | 9 | The [wiki page](https://github.com/akeranen/the-one/wiki) has the latest information. 10 | -------------------------------------------------------------------------------- /compile.sh: -------------------------------------------------------------------------------- 1 | targetdir=target 2 | 3 | if [ ! -d "$targetdir" ]; then mkdir $targetdir; fi 4 | 5 | javac -sourcepath src -d $targetdir -cp lib/ECLA.jar:lib/DTNConsoleConnection.jar src/core/*.java src/movement/*.java src/report/*.java src/routing/*.java src/gui/*.java src/input/*.java src/applications/*.java src/interfaces/*.java 6 | 7 | if [ ! -d "$targetdir/gui/buttonGraphics" ]; then cp -R src/gui/buttonGraphics target/gui/; fi 8 | 9 | -------------------------------------------------------------------------------- /data/tram4.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (2554383.251038637 6673258.043062663, 2554164.2258403506 6673085.173384075, 2553841.6277093147 6673119.391238062, 2553707.4902432454 6673207.421443538, 2553241.3996715695 6673442.8554824535, 2552930.1703346907 6673422.44040407, 2552720.809051393 6673409.434952837, 2552480.8583879373 6673392.573941387, 2552172.432960881 6673639.590638857, 2551943.3598269443 6674056.316289438, 2 | 2551761.5729668215 6674388.38925647) 3 | -------------------------------------------------------------------------------- /src/core/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Contains core classes and interfaces of the simulator. 6 | 7 | Almost all of these classes are needed for every run of the simulator. 8 | DTNSim is the main class of the program. It starts up a proper user interface 9 | which in turn starts the simulation. 10 | 11 | @see ui.DTNSimUI 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/A_bus.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (2553558.1158829676 6674022.108437747, 2553256.4880741183 6674002.824011413, 2552932.8422519267 6673978.828503751, 2552757.3251099777 6673680.650063182, 2552363.5334775783 6673567.544102095, 2552275.651163554 6673509.600802434, 2551892.3364427104 6673318.977048773, 2552122.746001586 6673002.154328803, 2552264.671030261 6672803.6187591525, 2552483.811722061 6672500.92928317, 2 | 2552253.088680792 6672172.793966631) 3 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/C_bus.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (2551844.6623703605 6674216.3330179015, 2551557.9002265697 6674544.118254086, 2551245.6800126503 6674810.619423806, 2551126.16072554 6675032.970459795, 2551042.675414555 6675236.6272049025, 2550817.5785572873 6675557.160776621, 2550277.86912047 6675871.0628262125, 2549830.537995156 6676063.476990825, 2549305.5374822007 6676406.915819961, 2548940.256248493 6676559.490840337, 2 | 2548569.3983280044 6677113.988113486) 3 | -------------------------------------------------------------------------------- /example_settings/snw_comparison_settings.txt: -------------------------------------------------------------------------------- 1 | Scenario.name = SNWComp-%%SprayAndWaitRouter.nrofCopies%%-B%%SprayAndWaitRouter.binaryMode%% 2 | 3 | Group.router = SprayAndWaitRouter 4 | 5 | SprayAndWaitRouter.nrofCopies = [1;2;3;4;5;6;7;8;9;10;11] 6 | SprayAndWaitRouter.binaryMode = [true;false] 7 | 8 | 9 | MovementModel.rngSeed = 0 10 | Report.nrofReports = 1 11 | Report.report1 = MessageStatsReport 12 | 13 | Report.reportDir = snwcomp_reports/ 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Keep EOLs consistent 2 | 3 | * text=auto 4 | 5 | *.java text 6 | *.txt text 7 | *.md text 8 | *.bat text 9 | *.sh text 10 | *.pl text 11 | *.pm text 12 | *.py text 13 | 14 | # Windows batch files should retain CRLF 15 | *.bat text eol=crlf 16 | 17 | *.class binary 18 | *.gif binary 19 | *.png binary 20 | *.jar binary 21 | -------------------------------------------------------------------------------- /src/movement/TransportMovement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Aalto University, ComNet 3 | * Released under GPLv3. See LICENSE.txt for details. 4 | */ 5 | package movement; 6 | 7 | import core.Coord; 8 | 9 | /** 10 | * MovementModels used for transportation should implement this interface 11 | * 12 | * @author Frans Ekman 13 | */ 14 | public interface TransportMovement extends SwitchableMovement { 15 | 16 | public void setNextRoute(Coord nodeLocation, Coord nodeDestination); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /compile.bat: -------------------------------------------------------------------------------- 1 | set targetdir=target 2 | 3 | IF NOT EXIST "%targetdir%" mkdir %targetdir% 4 | 5 | javac -sourcepath src -d %targetdir% -cp lib/ECLA.jar;lib/DTNConsoleConnection.jar src/core/*.java src/movement/*.java src/report/*.java src/routing/*.java src/gui/*.java src/input/*.java src/applications/*.java src/interfaces/*.java 6 | 7 | 8 | 9 | IF NOT EXIST "%targetdir%\gui\buttonGraphics" ( 10 | mkdir %targetdir%\gui\buttonGraphics 11 | copy src\gui\buttonGraphics\* %targetdir%\gui\buttonGraphics\ 12 | ) 13 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/E_bus.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (2548008.8175634407 6672181.105874455, 2547920.7125119264 6672681.830805297, 2548383.8002522583 6672630.819096636, 2549125.219109916 6672924.776568371, 2550869.4433942605 6673004.914962448, 2551317.2612422374 6672889.818544494, 2551612.3884162 6672988.061093998, 2551699.751009415 6673299.7926453985, 2551893.5491245994 6673447.066448992, 2552153.657015446 6673654.484057328, 2 | 2552256.454491749 6673534.296470803, 2552719.2287496882 6673650.273090789, 2553233.3316247175 6673542.7184038805) 3 | -------------------------------------------------------------------------------- /src/core/SettingsError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Aalto University, ComNet 3 | * Released under GPLv3. See LICENSE.txt for details. 4 | */ 5 | package core; 6 | 7 | /** 8 | * Settings related error 9 | * 10 | */ 11 | public class SettingsError extends SimError { 12 | 13 | public SettingsError(String cause) { 14 | super(cause); 15 | } 16 | 17 | public SettingsError(String cause, Exception e) { 18 | super(cause,e); 19 | } 20 | 21 | public SettingsError(Exception e) { 22 | super(e); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /data/tram3.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (2552480.8583879373 6673392.573941387, 2552720.809051393 6673409.434952837, 2552930.1703346907 6673422.44040407, 2553055.669603237 6673293.861283979, 2553058.119715625 6673058.3372244015, 2553281.9791423935 6672606.85359586, 2553180.9635660085 6672364.467961353, 2552883.7245106613 6672239.799346303, 2552708.001130296 6672220.484913082, 2552440.7491407027 6672213.753367998, 2 | 2552483.811722061 6672500.92928317, 2552341.7794494093 6672696.104081427, 2552261.900555275 6672932.613958296, 2552508.7708714856 6673110.496865532) 3 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/B_offices.wkt: -------------------------------------------------------------------------------- 1 | POINT (2547765.695468574 6671861.002401457) 2 | 3 | POINT (2547876.3630028493 6671967.746902404) 4 | 5 | POINT (2548337.0088803307 6671880.666915031) 6 | 7 | POINT (2548821.3804252422 6671791.406427169) 8 | 9 | POINT (2549000.560361468 6672094.435981209) 10 | 11 | POINT (2549328.726929748 6672406.747665767) 12 | 13 | POINT (2548973.5431289105 6672751.016685456) 14 | 15 | POINT (2549125.4665960157 6671310.466037451) 16 | 17 | POINT (2548899.0168147366 6671469.6525753625) 18 | 19 | POINT (2549038.92070693 6671689.052934085) 20 | -------------------------------------------------------------------------------- /toolkit/dtnsim2patches/EpidemicKnowledgeHandler.java.diff: -------------------------------------------------------------------------------- 1 | 212c212,213 2 | < network.vprint("Removing copy of " + m + " - ACKed or delivered to final destination."); 3 | --- 4 | > network.vprint("Removing copy of " + m + " at " + this.parent.getName()); 5 | > // ACKed or delivered to final destination. 6 | 312c313,314 7 | < parent.getNetwork().vprint("DROPPED epidemic " + m + " to free buffer space for " + forMsg); 8 | --- 9 | > parent.getNetwork().vprint("DROPPED epidemic " + m + " to free buffer space for " + forMsg + 10 | > " at " + parent.getName()); 11 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/F_bus.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (2552951.6016982887 6671978.96947831, 2552883.7245106613 6672239.799346303, 2552821.9107324784 6672739.764102663, 2552599.255738062 6672877.725768852, 2552478.6805102592 6673256.062608091, 2552288.5451893513 6673519.573091362, 2552063.959803357 6673790.795344708, 2551861.5739205102 6674198.388899207, 2551681.816516719 6674680.479552944, 2551335.641209913 6675218.222980602, 2 | 2551083.634364065 6675615.144085466, 2550671.0337880836 6675975.426780757, 2550010.88111605 6676239.047289281, 2549500.1028042943 6676330.738335026, 2548940.256248493 6676559.490840337) 3 | -------------------------------------------------------------------------------- /src/report/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Contains all the report classes. Reports can be used to create e.g. statistics 6 | and visualizations of the simulation. All report classes must be in this 7 | package and must extend the {@link report.Report} class so they can be 8 | dynamically loaded to the simulator. The classes to load can be specified 9 | trough {@link core.Settings} class' settings source. See Report class and 10 | classes extending it for details about the settings. 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /data/ParkPOIs.wkt: -------------------------------------------------------------------------------- 1 | POINT (2553143.9097474786 6672121.598159393) 2 | 3 | POINT (2553290.179181832 6672173.0340217315) 4 | 5 | POINT (2553205.4575377535 6672050.908441204) 6 | 7 | POINT (2553015.3458680497 6672745.815491632) 8 | 9 | POINT (2553072.3655058085 6672628.625246054) 10 | 11 | POINT (2552990.331251769 6672620.934534737) 12 | 13 | POINT (2553248.9572028136 6671937.993476591) 14 | 15 | POINT (2553249.4343082923 6672094.541162056) 16 | 17 | POINT (2552785.543273026 6673249.298489128) 18 | 19 | POINT (2552729.0506920097 6673245.719605062) 20 | 21 | POINT (2552841.676618883 6673253.251878758) 22 | -------------------------------------------------------------------------------- /example_settings/ping_app_settings.txt: -------------------------------------------------------------------------------- 1 | # This configuration file adds Ping application for all the nodes and 2 | # a report module that counts the number of pings & pongs sent & received 3 | 4 | # Define new application 5 | pingApp.type = PingApplication 6 | pingApp.interval = 500 7 | pingApp.destinationRange = 0,125 8 | pingApp.pingSize = 5 9 | pingApp.pongSize = 5 10 | pingApp.passive = false 11 | 12 | # Set Ping app for all nodes 13 | Group.nrofApplications = 1 14 | Group.application1 = pingApp 15 | 16 | # Add report for Ping app 17 | Report.nrofReports = 2 18 | Report.report2 = PingAppReporter 19 | 20 | -------------------------------------------------------------------------------- /example_settings/wlan-interface.txt: -------------------------------------------------------------------------------- 1 | 2 | wlanInterface.type = DistanceCapacityInterface 3 | 4 | # values from http://www.xirrus.com/cdn/pdf/wifi-demystified/documents_posters_range_plotter 5 | # 0-50ft:54Mbps, 75-100ft:48 Mbps, 125ft:36Mbps, 150ft:24 Mbps, 175ft:18Mbps, 6 | # 200ft:12Mbps, 225ft:9Mbps, 250ft:6Mbps, 275ft:2Mbps, 300ft:1Mbps 7 | 8 | wlanInterface.transmitSpeeds = 6750k, 6750k, 6750k, 6000k, 6000k, 4500k, 3000k, 2250k, 1500k, 1125k, 750k, 250k, 125k 9 | wlanInterface.transmitRange = 91 10 | 11 | # dummy speed 12 | wlanInterface.transmitSpeed = 0 13 | 14 | Group.interface1 = wlanInterface 15 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/B_bus.wkt: -------------------------------------------------------------------------------- 1 | LINESTRING (2549711.7116691247 6672521.834081425, 2549326.1448247735 6672446.546800818, 2548919.9211406293 6672451.737992347, 2548857.076170364 6672141.0166728245, 2549038.92070693 6671689.052934085, 2549125.4665960157 6671310.466037451, 2548826.6848773137 6671777.543245168, 2548721.940510359 6672165.17221722, 2548776.5689421124 6672470.202230424, 2548598.576939166 6672504.560116551, 2 | 2548409.3490672903 6672539.118048595, 2548204.9172993526 6672577.186786471, 2547920.50627351 6672635.070072358, 2547945.8323510517 6672417.580152135, 2548008.8175634407 6672181.105874455, 2547895.0977006014 6671978.22930842) 3 | -------------------------------------------------------------------------------- /src/input/ExternalEventsReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Aalto University, ComNet 3 | * Released under GPLv3. See LICENSE.txt for details. 4 | */ 5 | package input; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Interface for external event readers. 11 | */ 12 | public interface ExternalEventsReader { 13 | 14 | /** 15 | * Read events from the reader 16 | * @param nrof Maximum number of events to read 17 | * @return Events in a List 18 | */ 19 | public List9 | * Interface for classes that want to be informed about messages 10 | * between hosts. 11 | *
12 | * 13 | *14 | * Report classes wishing to receive application events should implement this 15 | * interface. Note that the application event names are defined by the 16 | * applications so any class wishing to interpret them must know the 17 | * application. 18 | *
19 | * 20 | * @author teemuk 21 | * @author mjpitka 22 | */ 23 | public interface ApplicationListener { 24 | 25 | /** 26 | * Application has generated an event. 27 | * 28 | * @param event Event name. 29 | * @param params Additional parameters for the event 30 | * @param app Application instance that generated the event. 31 | * @param host The host this application instance is running on. 32 | */ 33 | public void gotEvent(String event, Object params, Application app, 34 | DTNHost host); 35 | } 36 | -------------------------------------------------------------------------------- /src/report/InterContactTimesReport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Aalto University, ComNet 3 | * Released under GPLv3. See LICENSE.txt for details. 4 | */ 5 | package report; 6 | 7 | import core.DTNHost; 8 | 9 | /** 10 | * Reports the inter-contact time (i.e., the time between the end of previous 11 | * contact and the beginning of a new contact between two hosts) distribution. 12 | * The syntax of the report file is the same as in {@link ContactTimesReport}. 13 | */ 14 | public class InterContactTimesReport extends ContactTimesReport { 15 | 16 | @Override 17 | public void hostsConnected(DTNHost host1, DTNHost host2) { 18 | ConnectionInfo ci = this.removeConnection(host1, host2); 19 | 20 | if (ci != null) { // connected again 21 | newEvent(); 22 | ci.connectionEnd(); 23 | increaseTimeCount(ci.getConnectionTime()); 24 | } 25 | } 26 | 27 | @Override 28 | public void hostsDisconnected(DTNHost host1, DTNHost host2) { 29 | if (isWarmup()) { 30 | return; 31 | } 32 | // start counting time to next connection 33 | this.addConnection(host1, host2); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/D_offices.wkt: -------------------------------------------------------------------------------- 1 | POINT (2553394.2553363172 6675336.7501860205) 2 | 3 | POINT (2553062.029996001 6675431.351899847) 4 | 5 | POINT (2553052.246045524 6675578.855756246) 6 | 7 | POINT (2553218.944432785 6676004.253397298) 8 | 9 | POINT (2553362.2306350083 6676160.339223506) 10 | 11 | POINT (2553258.8721902124 6676270.974617526) 12 | 13 | POINT (2553108.3923920225 6676400.944449359) 14 | 15 | POINT (2553363.6083076303 6676465.00915406) 16 | 17 | POINT (2553496.8795723505 6676603.560955702) 18 | 19 | POINT (2553370.8101531332 6676594.448864214) 20 | 21 | POINT (2553458.708966231 6676375.618636353) 22 | 23 | POINT (2553520.0360217514 6676177.143080477) 24 | 25 | POINT (2553447.770080622 6676247.48922695) 26 | 27 | POINT (2553113.0533802346 6676122.790605012) 28 | 29 | POINT (2553020.4605807783 6676178.553404187) 30 | 31 | POINT (2552477.071850611 6676504.3081743205) 32 | 33 | POINT (2552841.833363509 6675831.963851868) 34 | 35 | POINT (2553890.89394224 6675364.116467373) 36 | 37 | POINT (2554326.5684722555 6675869.682509391) 38 | 39 | POINT (2553932.7438417096 6677359.32442526) 40 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/C_offices.wkt: -------------------------------------------------------------------------------- 1 | POINT (2551376.426919153 6674304.123168278) 2 | 3 | POINT (2550967.0766606154 6675000.773069562) 4 | 5 | POINT (2550697.3498100247 6675261.432898526) 6 | 7 | POINT (2550544.1476647374 6675483.043764625) 8 | 9 | POINT (2551431.6740661557 6675050.304438443) 10 | 11 | POINT (2551206.618456572 6675407.336387593) 12 | 13 | POINT (2551000.2975447397 6675718.547819612) 14 | 15 | POINT (2550689.6034951024 6675859.940273265) 16 | 17 | POINT (2550394.3855762365 6676057.865702871) 18 | 19 | POINT (2550193.3443678655 6676346.541962416) 20 | 21 | POINT (2550170.1466707815 6676695.852139196) 22 | 23 | POINT (2549568.351221071 6676074.7895873925) 24 | 25 | POINT (2548866.5796365947 6676319.20568795) 26 | 27 | POINT (2548591.7710714224 6676574.744341456) 28 | 29 | POINT (2548387.5455419016 6677245.3982759155) 30 | 31 | POINT (2549190.6544346926 6676779.691382726) 32 | 33 | POINT (2550699.494689556 6674935.358054927) 34 | 35 | POINT (2550826.0508314357 6675180.984433278) 36 | 37 | POINT (2550853.835270902 6674980.93851696) 38 | 39 | POINT (2550585.040617954 6675171.722307353) 40 | -------------------------------------------------------------------------------- /src/gui/playfield/MessageGraphic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Aalto University, ComNet 3 | * Released under GPLv3. See LICENSE.txt for details. 4 | */ 5 | package gui.playfield; 6 | 7 | import java.awt.Color; 8 | import java.awt.Graphics2D; 9 | import java.awt.Polygon; 10 | 11 | import core.DTNHost; 12 | 13 | /** 14 | * Visualization of a message 15 | * 16 | */ 17 | public class MessageGraphic extends PlayFieldGraphic { 18 | private Color msgColor = Color.RED; 19 | 20 | private DTNHost from; 21 | private DTNHost to; 22 | 23 | public MessageGraphic(DTNHost from, DTNHost to) { 24 | this.to = to; 25 | this.from = from; 26 | } 27 | 28 | @Override 29 | public void draw(Graphics2D g2) { 30 | g2.setColor(msgColor); 31 | 32 | int fromX = scale(from.getLocation().getX()); 33 | int fromY = scale(from.getLocation().getY()); 34 | int toX = scale(to.getLocation().getX()); 35 | int toY = scale(to.getLocation().getY()); 36 | 37 | // line from "from host" to "to host" 38 | Polygon p = new Polygon(new int[] {fromX, toX}, 39 | new int[] {fromY,toY}, 2); 40 | 41 | g2.draw(p); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /data/HelsinkiMedium/E_offices.wkt: -------------------------------------------------------------------------------- 1 | POINT (2553785.2338767163 6673218.283936794) 2 | 3 | POINT (2552971.7305677356 6673425.081402789) 4 | 5 | POINT (2552065.320976905 6672790.54575852) 6 | 7 | POINT (2551613.0318800593 6673913.813580948) 8 | 9 | POINT (2551164.661313126 6671899.611263307) 10 | 11 | POINT (2551217.6480870843 6672787.2850100845) 12 | 13 | POINT (2553277.4088990847 6674161.500432238) 14 | 15 | POINT (2552270.379709629 6672251.59205307) 16 | 17 | POINT (2550839.241840553 6672755.957819589) 18 | 19 | POINT (2552844.266976823 6672450.797776541) 20 | 21 | POINT (2548291.694175465 6671876.545969155) 22 | 23 | POINT (2548973.5431289105 6672751.016685456) 24 | 25 | POINT (2548291.694175465 6671876.545969155) 26 | 27 | POINT (2548973.5431289105 6672751.016685456) 28 | 29 | POINT (2547971.0181864705 6672303.113878818) 30 | 31 | POINT (2552924.1307412153 6672763.979660833) 32 | 33 | POINT (2552892.741254229 6673220.99455896) 34 | 35 | POINT (2552952.212164001 6673697.553943111) 36 | 37 | POINT (2553376.452836208 6673806.188877968) 38 | 39 | POINT (2551923.44544545 6672987.520970024) 40 | 41 | POINT (2551768.7088863445 6672875.395233927) 42 | 43 | POINT (2552330.7745675067 6672982.3197762) 44 | -------------------------------------------------------------------------------- /src/movement/ModifiedRandomDirection.java: -------------------------------------------------------------------------------- 1 | package movement; 2 | 3 | import core.Settings; 4 | 5 | /** 6 | *7 | * Modified Random Direction movement model as described in: 8 | * Elizabeth M. Royer, P. Michael Melliar-Smith, and Louise E. Moser, 9 | * "An Analysis of the Optimum Node Density for Ad hoc Mobile Networks" 10 | *
11 | * 12 | *13 | * Similar to {@link RandomDirection}, except nodes will not move all the way 14 | * to the edge. Instead they will pick a random direction and move in that 15 | * direction for a random distance before pausing and picking another 16 | * direction. 17 | *
18 | * 19 | * @author teemuk 20 | */ 21 | public class ModifiedRandomDirection 22 | extends RandomDirection { 23 | 24 | public ModifiedRandomDirection( Settings settings ) { 25 | super( settings ); 26 | } 27 | 28 | public ModifiedRandomDirection( ModifiedRandomDirection other ) { 29 | super( other ); 30 | } 31 | 32 | @Override 33 | protected double getTravelFraction() { 34 | // Move a random fraction in the picked direction instead of all the 35 | // way to the edge. 36 | return MovementModel.rng.nextDouble(); 37 | } 38 | 39 | @Override 40 | public MovementModel replicate() { 41 | return new ModifiedRandomDirection( this ); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/gui/playfield/MapGraphic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Aalto University, ComNet 3 | * Released under GPLv3. See LICENSE.txt for details. 4 | */ 5 | package gui.playfield; 6 | 7 | import java.awt.Color; 8 | import java.awt.Graphics2D; 9 | 10 | import movement.map.MapNode; 11 | import movement.map.SimMap; 12 | import core.Coord; 13 | 14 | /** 15 | * PlayfieldGraphic for SimMap visualization 16 | * 17 | */ 18 | public class MapGraphic extends PlayFieldGraphic { 19 | private SimMap simMap; 20 | private final Color PATH_COLOR = Color.LIGHT_GRAY; 21 | private final Color BG_COLOR = Color.WHITE; 22 | 23 | public MapGraphic(SimMap simMap) { 24 | this.simMap = simMap; 25 | 26 | } 27 | 28 | // TODO: draw only once and store to buffer 29 | @Override 30 | public void draw(Graphics2D g2) { 31 | Coord c,c2; 32 | 33 | if (simMap == null) { 34 | return; 35 | } 36 | 37 | g2.setColor(PATH_COLOR); 38 | g2.setBackground(BG_COLOR); 39 | 40 | // draws all edges between map nodes (bidirectional edges twice) 41 | for (MapNode n : simMap.getNodes()) { 42 | c = n.getLocation(); 43 | 44 | // draw a line to adjacent nodes 45 | for (MapNode n2 : n.getNeighbors()) { 46 | c2 = n2.getLocation(); 47 | g2.drawLine(scale(c2.getX()), scale(c2.getY()), 48 | scale(c.getX()), scale(c.getY())); 49 | } 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/util/ParetoRNG.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Aalto University, ComNet 3 | * Released under GPLv3. See LICENSE.txt for details. 4 | */ 5 | package util; 6 | 7 | import java.util.Random; 8 | 9 | /** 10 | * A random number generator for a Pareto distribution 11 | * @author Frans Ekman 12 | */ 13 | public class ParetoRNG { 14 | private Random rng; 15 | private double xm; // min value (Xm) 16 | private double k; // coefficient 17 | private double maxValue; 18 | 19 | /** 20 | * Creates a new Pareto random number generator that makes use of a normal 21 | * random number generator 22 | * @param rng 23 | * @param k 24 | * @param minValue 25 | * @param maxValue 26 | */ 27 | public ParetoRNG(Random rng, double k, double minValue, double maxValue) { 28 | this.rng = rng; 29 | this.xm = minValue; 30 | this.k = k; 31 | if (maxValue == -1) { 32 | this.maxValue = Double.POSITIVE_INFINITY; 33 | } else { 34 | this.maxValue = maxValue; 35 | } 36 | } 37 | 38 | /** 39 | * Returns a Pareto distributed double value 40 | * @return a Pareto distributed double value 41 | */ 42 | public double getDouble() { 43 | if (xm == -1) { 44 | return Double.POSITIVE_INFINITY; 45 | } 46 | double x; 47 | do { 48 | x = xm * Math.pow((1 - rng.nextDouble()), (-1/k)); 49 | } while (x > maxValue); 50 | return x; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/gui/playfield/PathGraphic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Aalto University, ComNet 3 | * Released under GPLv3. See LICENSE.txt for details. 4 | */ 5 | package gui.playfield; 6 | 7 | import java.awt.Color; 8 | import java.awt.Graphics2D; 9 | import java.util.List; 10 | 11 | import movement.Path; 12 | import core.Coord; 13 | 14 | /** 15 | * Visualization of a Path 16 | * 17 | */ 18 | public class PathGraphic extends PlayFieldGraphic { 19 | private final static Color PATH_COLOR = Color.RED; 20 | private ListPingApplication. Counts the number of pings
15 | * and pongs sent and received. Calculates success probabilities.
16 | *
17 | * @author teemuk
18 | */
19 | public class PingAppReporter extends Report implements ApplicationListener {
20 |
21 | private int pingsSent=0, pingsReceived=0;
22 | private int pongsSent=0, pongsReceived=0;
23 |
24 | public void gotEvent(String event, Object params, Application app,
25 | DTNHost host) {
26 | // Check that the event is sent by correct application type
27 | if (!(app instanceof PingApplication)) return;
28 |
29 | // Increment the counters based on the event type
30 | if (event.equalsIgnoreCase("GotPing")) {
31 | pingsReceived++;
32 | }
33 | if (event.equalsIgnoreCase("SentPong")) {
34 | pongsSent++;
35 | }
36 | if (event.equalsIgnoreCase("GotPong")) {
37 | pongsReceived++;
38 | }
39 | if (event.equalsIgnoreCase("SentPing")) {
40 | pingsSent++;
41 | }
42 |
43 | }
44 |
45 |
46 | @Override
47 | public void done() {
48 | write("Ping stats for scenario " + getScenarioName() +
49 | "\nsim_time: " + format(getSimTime()));
50 | double pingProb = 0; // ping probability
51 | double pongProb = 0; // pong probability
52 | double successProb = 0; // success probability
53 |
54 | if (this.pingsSent > 0) {
55 | pingProb = (1.0 * this.pingsReceived) / this.pingsSent;
56 | }
57 | if (this.pongsSent > 0) {
58 | pongProb = (1.0 * this.pongsReceived) / this.pongsSent;
59 | }
60 | if (this.pingsSent > 0) {
61 | successProb = (1.0 * this.pongsReceived) / this.pingsSent;
62 | }
63 |
64 | String statsText = "pings sent: " + this.pingsSent +
65 | "\npings received: " + this.pingsReceived +
66 | "\npongs sent: " + this.pongsSent +
67 | "\npongs received: " + this.pongsReceived +
68 | "\nping delivery prob: " + format(pingProb) +
69 | "\npong delivery prob: " + format(pongProb) +
70 | "\nping/pong success prob: " + format(successProb)
71 | ;
72 |
73 | write(statsText);
74 | super.done();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/movement/BusMovement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010 Aalto University, ComNet
3 | * Released under GPLv3. See LICENSE.txt for details.
4 | */
5 | package movement;
6 |
7 | import java.util.LinkedList;
8 | import java.util.List;
9 |
10 | import movement.map.MapNode;
11 | import core.Coord;
12 | import core.Settings;
13 |
14 | /**
15 | * This class controls the movement of busses. It informs the bus control system
16 | * the bus is registered with every time the bus stops.
17 | *
18 | * @author Frans Ekman
19 | */
20 | public class BusMovement extends MapRouteMovement {
21 |
22 | private BusControlSystem controlSystem;
23 | private int id;
24 | private static int nextID = 0;
25 | private boolean startMode;
26 | private List