Difference between revisions of "Private:psim"
From NMSL
Line 56: | Line 56: | ||
// XXX TODO XXX | // XXX TODO XXX | ||
+ | |||
+ | class SimException { | ||
+ | |||
+ | } | ||
+ | |||
+ | Interface EventHandler { | ||
+ | void handle() throws SimException; // callback function | ||
+ | } | ||
+ | |||
class Event { | class Event { | ||
long time; // when this event happens | long time; // when this event happens | ||
− | int type; // see below | + | Peer src; // which peer generates this event |
+ | Peer dst; // whom is destinate of this event | ||
+ | Vector<EventHandler> handlers; //process an event and update states accordingly | ||
+ | int type; // enum, see below | ||
// 1. connect: peer 1 makes a connection to peer 2, and add each other into neighbors | // 1. connect: peer 1 makes a connection to peer 2, and add each other into neighbors | ||
// 2. requestSent: a receiver sends a high-priority request message to a sender | // 2. requestSent: a receiver sends a high-priority request message to a sender | ||
Line 64: | Line 76: | ||
// 4. dataSent: a sender sends a data segment | // 4. dataSent: a sender sends a data segment | ||
// 5. dataArrived: a data segment arrives to a receiver | // 5. dataArrived: a data segment arrives to a receiver | ||
+ | |||
+ | void addHandler(Interface EventHandler); // add an additional event handler | ||
+ | void rmvHandler(Interface EventHandler); // remove an additional event handler | ||
} | } | ||
class EventQueue { | class EventQueue { | ||
SortedMap<Long, Event> queue; // events sorted on its time | SortedMap<Long, Event> queue; // events sorted on its time | ||
− | void | + | void dispatch(Event event); // sequentially invoke even handlers |
} | } | ||
+ | class Simulator { | ||
+ | long simTime; // elapsed simulation time in msec | ||
+ | EventQueue events; // pending events that will be processed | ||
+ | void dispatchEvent(); // forever loop to process the next event | ||
+ | } | ||
</pre> | </pre> |
Revision as of 07:59, 5 March 2009
This page documents the development of a discrete event simulator for P2P video streaming applications. This simulator captures important features of data-driven video streaming systems. In particular, it is designed to evaluate: (i) the performance of various segment scheduling algorithms; (ii) the potential of network coding in multi-layer P2P video streaming systems.
Class Diagrams
- use long for time/offset in msec, which has a rollover time 24.85 days
class Frame { // video frame, a layer of it, read from trace file int no; // serial number int layer; // layer number it belongs to, set to zero for nonscalable frame long deadlineOffset; // deadline offset compared to the start of the video, in msec int size; // frame size in bytes } class Segment { // packetized frames int no; // serial number Vector<Frame> frames; // reference to included frame int totalSize; // aggregate size in bytes } class Video { // a media file, shared by a group of peers String filename; // video trace file path and name Hashtable<int, Frame> frameTrace; // frames read from the trace file Hashtable<int, Segment> segmentTrace; // segments generated by the prepareSegments(...) void prepareSegments(int noFrame); // packetize frames into segment, // noFrame indicates how many frames should we put in one segment; // we might implement other packtization schemes later. } class Neighbor { // keep track of what my neighbor has done Peer peer; // peer instance, for accessing availability info int estimateRate; // estimated rate (maybe historical) } class Peer { // represent a running peer int ingressBW; // incoming bandwidth in bps int egressBW; // outgoing bandwidth in bps BitSet avail; // availability bufmap Vector<Neighbor> neighbors; // peers that we may send requests to } class Group { // peers that have downloaded or want to download a Video Video video; // media shared among peers Vector<Peer> peers; // peers in this group void join(Peer peer); // adding a new peer into this group void leave(Peer peer); // removing a peer from this group } class Connection { // end to end network link between two peers Peer peer1; // one end Peer peer2; // the other long delay; // transmission delay in msec int e2eBW; // end-to-end bandwidth in bps } // XXX TODO XXX class SimException { } Interface EventHandler { void handle() throws SimException; // callback function } class Event { long time; // when this event happens Peer src; // which peer generates this event Peer dst; // whom is destinate of this event Vector<EventHandler> handlers; //process an event and update states accordingly int type; // enum, see below // 1. connect: peer 1 makes a connection to peer 2, and add each other into neighbors // 2. requestSent: a receiver sends a high-priority request message to a sender // 3. requestArrived: a request message gets to a sender // 4. dataSent: a sender sends a data segment // 5. dataArrived: a data segment arrives to a receiver void addHandler(Interface EventHandler); // add an additional event handler void rmvHandler(Interface EventHandler); // remove an additional event handler } class EventQueue { SortedMap<Long, Event> queue; // events sorted on its time void dispatch(Event event); // sequentially invoke even handlers } class Simulator { long simTime; // elapsed simulation time in msec EventQueue events; // pending events that will be processed void dispatchEvent(); // forever loop to process the next event }