Changes between Version 2 and Version 3 of PTVS_Ideas

Dec 27, 2009, 9:28:20 AM (14 years ago)



  • PTVS_Ideas

    v2 v3  
    11[wiki:ParallelTrafficViewSimulator << Home]
    3 //TODO :P
     3'''Analysis of simulator components and implementation vs. performance'''
     5After analyzing the performance of the simulator, we’ve concluded that we don’t need to use threads in the processing of GPS events and CleanupEvents, because these operations are not computationally intensive. Another important reason for taking this decision is that are these events are not directly linked to an event coming from a certain location, so the location is irrelevant.
     6The GPS events are used to find out the new position of a vehicle. The GPS Event is scheduled at a regular time interval for each node thus accurately simulating the way a real VANET application collects GPS data periodically.
     7The Cleanup events have the role of cleaning the database of records. Every car holds a trafficDB with records of the type CarInfo. Each CarInfo has an expiration time and the processing of a CleanupEvent iterates through the database and deletes the old records.
     8These events are processed by the main thread in the engine of the simulator.
     9For the other 2 types of events we use separate processing threads. These are the most numerous events and the time spent to process these events is the biggest. 
     10The engine first starts with an empty event queue. At the moment zero a GPS event is added to the queue: eventQueue.add(new GPSEvent(0)); At the moment one a Cleanup event: eventQueue.add(new CleanupEvent(1)); Then some standard Send events are scheduled. This is done in the initialization area so when we start the simulator there will be events to process and while processing these events new ones are generated and scheduled.
     11In the method playEvent the events corresponding to the current time are extracted from the queue (e = eventQueue.remove(0) ;) and then processed. The type of event is determined and specific processing is done.
     12For example for a GPSEvent we must update the information for each car and then create and schedule the next event:
     13Iterator<SimulatedCarInfo> it = cars.iterator();
     14        while (it.hasNext()) {
     15                SimulatedCarInfo r =;
     16                r.update();
     17        }
     18        GPSEvent newEvent = new GPSEvent(crtTime + fps);
     19        schedEvent(newEvent);
     21Another example: when the method simulateCommunication() is called for a send event, receive events are created and scheduled for all the vehicles in the wireless range of the sender.
     22Generally the processing of an event consists in the determination of its type and then the execution of specific actions, followed by the creation and planning of the next events (method schedEvent).