1 / 20

PARSEC/Glomosim Tutorial

PARSEC/Glomosim Tutorial. Vlasios Tsiatsis EE206 UCLA, 5/1/02. PARSEC Entities. Discrete-event simulation language Basically C with extensions parallel executing ENTITIES entity Sort (int n , int a [20]) { sorting (); finalize{ } } //entity declaration, creation

blythe
Download Presentation

PARSEC/Glomosim Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PARSEC/Glomosim Tutorial Vlasios Tsiatsis EE206 UCLA, 5/1/02

  2. PARSEC Entities • Discrete-event simulation language • Basically C with extensions • parallel executing ENTITIES entity Sort (int n, int a[20]) { sorting(); finalize{ } } //entity declaration, creation ename s1; ... sl = new Sort(20, a[20]); ... useful for statistics collection entity body entity handle Vlasios Tsiatsis

  3. PARSEC Messages • Entities communicate via message passing • Each entity has one built-in message queue • time-stamped, typed, MESSAGES like C structs messageRequest { int units; ename id; }; /* declaration - initialization*/ messageRequest myrequest; myrequest.units =20; myrequest.id = self; handle of current entity Vlasios Tsiatsis

  4. Entity Communication • Entities exchange messages using the send and receive primitives • send – send a typed message to an entity messageRequest myrequest; sendRequest{10, self} to E2; send oldrequest to E2; send oldrequest to E2 after 5; This modifier changes the message timestamp Vlasios Tsiatsis

  5. Entity Communication (cont’d) • receive – process message from the internal queue (blocking call) /* complex receive */ receive (Request r) { req = r; } orreceive (Release r) { units = r.units; } ortimeoutin (5) { ... } messageRequest req; int units; /* simple receive */ receive (Request r) { req = r; } • Two semantics: • in – timeout has highest priority • after – receive has highest priority Vlasios Tsiatsis

  6. Timing considerations • PARSEC keeps track of the simulation time by using an internal discretesimulation clock • Only a few statements can advance this clock: • send M1 to E1 after T with T>0 • timeoutwith non-zero timeovalue • hold(T) with T>0 (like a delay function) • …so if you don’t have any of these statements in your code the simulation time is going to be zero! • send statements deposit the message asynchronously in the receiving entity queue time-stamping it with the current or modified time Vlasios Tsiatsis

  7. Timing considerations (cont’d) • receive statements take the earliest message from queue (according to timestamps) and if there are multiple messages with the same timestamp the order is NOT deterministic! • The user can get the value of simulation clock by the simclock()function • The user can set the maximum value of simulation clock by the setmaxclock()function Vlasios Tsiatsis

  8. Development Cycle • Your equivalent main()function is the entity driver() • Use this entity to create all the other entities and setup the simulation environment • Also use this entity to collect all the statistics from all other entities by sending them request messages • If you need to connect entities together use messages with the entity reference (self) in the message • If an entity A needs some information from another entity B create a dummy request message: send DummyReq to B; // no delay receive(DummyRep rep){ needed_info = rep.info } Vlasios Tsiatsis

  9. Example • How would we simulate a wireless sensor network under PARSEC ? • First thought- one entity per physical node • What about node communication ? How do you model the wireless channel? • The solution follows a layered approach • 1 entity type for the channel • 1 entity type for the physical layer • 1 entity type for link layer • and so on… Vlasios Tsiatsis

  10. Example – NESL Code Organization* • To keep things simple we only have 3 types of “networking” entity types: • Channel • Radio (physical and MAC layer) • Node (network and application layer) • And one entity responsible for setting up the simulation environment (driver entity) and gathering the simulation results * The author of the first version of this code is Curt Schurgers Vlasios Tsiatsis

  11. Architecture MAIN Node 1 Node N Radio 1 Radio N Channel One physical sensor node Statistics messages Network messages Each building block corresponds to 4 files • <entity_name>.pc – Implementation • <entity_name>.h – Declarations • <entity_name>_functions.h – Functions • <entity_name>_parameters.h – Parameters Vlasios Tsiatsis

  12. PARSEC Implementation main.pc code entity driver(int argc,char** argv) { ... // Topology (xcoord, ycoord) creation ... channel = (ename*)malloc(sizeof(ename)); channel = new Channel(self,num_nodes,BER); ... for (i=0;i<num_nodes;i++) { node[i]=new SensorNode(i,xcoord[i],ycoord[i],TX_RANGE, self, channel, num_nodes); } ... while(TRUE){ receive (StatisticsMessage){ ... } ... } MAIN SensorNodes Vlasios Tsiatsis

  13. Main entity • Read the command line arguments • Create the topology • Create the Channel • Create the individual Nodes and pass a reference to the Channel • Wait for statistics collection messages from nodes (when nodes finish they send all the desired statistics to the main entity) Vlasios Tsiatsis

  14. PARSEC Implementation node.pc code entity SensorNode(int node_ID,float xcoord,float ycoord, floatTxrange, ename top,ename channel, intnum_nodes) { ... // inform the channel about the node location ... radio= new Radio(node_ID,self,channel,top,num_nodes,1); // connect the channel with the radio by sending a // message to the channel channelmsg.radio = radio; send channelmsg to channel; ... while(1){ receive(NMsg_1) {...} or receive (NMsg_2) {...} ... or receive (NMsg_N) {...} } MAIN Node 1 Radio Vlasios Tsiatsis

  15. PARSEC Implementation radio.pc code entity Radio(int id, ename node, ename channel, ename top, int num_nodes, int radio_mode) { ... while(1){ receive(RMsg_1) {...} or receive (RMsg_2) {...} ... or receive (RMsg_N) {...} }} Node MAIN Radio 1 Channel channel.pc code entity Channel(ename top,int num_nodes,float ber) {... while(1){ receive(CMsg_1) { //topology maintenance here } or receive (CMsg_2) {...} ... or receive (CMsg_N) {...} }} Radio Channel Vlasios Tsiatsis

  16. Radio/Channel Entity • The Radio entity has 3 modes: • Ideal Radio – No collisions • Collisions, no channel sensing, no TX buffer • Collision Detection, radio buffers • Radio entity sends a message to the node entity every time a packet transmission ends because the TX time is not deterministic due to buffering and backoff delays (mode 3) • Channel entity maintains a neighborhood matrix updated whenever a new node entity is created • Channel entity routes packets from one node to it radio neighbors Vlasios Tsiatsis

  17. GlomoSim Model • GlomoSim uses PARSEC • All nodes are aggregated into PARSEC aggregation entities for: • Scalability • ease of neighborhood calculations (remember this model was created for mobile ad-hoc networks) • Current release supports only 1 partition • Node state is maintained in a global data structure BUT simulation code for one node does not access other nodes’ state GLOMOPartition Vlasios Tsiatsis

  18. Application Transport Network Link(MAC) Physical GlomoSim Model (cont’d) • Follows a layered approach for a network protocol architecture • Uses one entity for all the communication layers for ease of inter-layer communication • Neighboring layers exchange messages by fixed APIs Vlasios Tsiatsis

  19. Protocol Layer Functions Each layer has 3 major functions: • Initialization Function void NetworkLar1Init(GlomoNode *node, GlomoNetworkLar1** lar1, const GlomoNodeInput *nodeInput); • Finalization Function – statistics void NetworkLar1Finalize(GlomoNode *node); • Message Dispatcher Function void NetworkLar1HandleProtocolPacket( GlomoNode* node, Message* msg); • Data structures: • GlomoNode – State of a node (handle of a node) • Message – Message or packet • GlomoNetworkLar1 – Protocol Specific information (e.g. statistics variables) • GlomoNodeInput –configuration options from command line Vlasios Tsiatsis

  20. If everything else fails… • Read the manuals (they are relatively small!): • PARSEC http://pcl.cs.ucla.edu/projects/parsec/ • GlomoSim http://pcl.cs.ucla.edu/projects/glomosim/ • Read the source code: • You may need to modify it • You may need to watch the flow of packets from one layer to another Vlasios Tsiatsis

More Related