Friday, November 28, 2008

A simple queuing system

I have 3 nodes, each one of them send a message, then relay messages until it sees its own message. When it sees its own message, it sends another one.

Need a way to buffer messages into a Priority Queue. This queue is a heap, look at PrioHeap.C in common

At Time 0, a node insert a message into the PrioHeap. At time 0+Latency, the destination node is waken up and then it look at the event, if it is its own message, it increase a counter of received. If it is not its own message, it sends this message to the next node.

Data Structures:
1. Event queue
Event queue is a priority queue of events. Each event is put on the queue and then removed from the queue at its wake up time. The queue uses the wake up time of each event as the priority.
Event queue is an array of event object. We arrange the queue using the priority of the event, or in other words, the time to wakeup.
2. Event
Event has the source node, destination node, message, time of wake up
3. Message
Message is an array of characters of size 1024.
5. Node
left node, right node, latency, message send queue, message received queue, message relayed queue.
6. Priority Queue
standard Priority Queue

No comments: