120 likes | 351 Views
GloMoSim. Editing the Code…. Basic Structure. /application contains code for the application layer /bin for executable and input/output files /doc contains the documentation /include contains common include files /mac contains the code for the mac layer
E N D
GloMoSim Editing the Code…
Basic Structure /application contains code for the application layer /bin for executable and input/output files /doc contains the documentation /include contains common include files /mac contains the code for the mac layer /main contains the basic framework design /network contains the code for the network layer /radio contains the code for the physical layer /transport contains the code for the transport layer /scenarios contains directories of various sample configuration topologies
In the Directory • All Code is in C • Find the protocol you want to edit • For Example: ODMRP • Network Layer • ODMRP.H and ODMRP.PC • Header File • Basic Definition of all your functions and data objects • PC File • Actual Functions
Layers • Code is very layered • Pass messages between layers • Usually a general Layer library interfaces with a specific library • Network.pc • ODMRP.pc • ZRP.PC • In between layer communication done by • Glomo_**** Functions
Sample code typedef struct{ unsigned char query; NODE_ADDR lastAddr; unsigned char seqNumber; unsigned char hopCount; } OdmrpIpOptionType; • Read code along with IETF Documentation • Do a google search for protocol spec that you are studying
Obtaining the Data • Data is Printed to Glomo.Stat • Select what layer you want the statistics for • Config.in APPLICATION-STATISTICS YES TCP-STATISTICS NO UDP-STATISTICS NO ROUTING-STATISTICS NO NETWORK-LAYER-STATISTICS NO MAC-LAYER-STATISTICS NO RADIO-LAYER-STATISTICS NO CHANNEL-LAYER-STATISTICS NO MOBILITY-STATISTICS NO
Sifting through the Data • Sample Output from 1 node: Glomo.stat Node: 0, Layer: RoutingOdmrp, Number of Join Queries Txed = 91 Node: 0, Layer: RoutingOdmrp, Number of Join Replies Txed = 0 Node: 0, Layer: RoutingOdmrp, Number of Acks Txed = 0 Node: 0, Layer: RoutingOdmrp, Number of CTRL Packets Txed = 91 Node: 0, Layer: NetworkIp, Number of Packet Attepted to be Sent to MAC: 91 Node: 0, Layer: NetworkIp, Number of Packets Routed For Another Node: 1595 Node: 0, Layer: NetworkIp, Number of Packets Delivered To this Node: 0 • Stats Printed for Each Node • You’ll Probably need to add Statistics
Adding Stats • Go through Header and search for Stat /* Total number of join query txed. */ int numQueryTxed; • Add your counter here • Edit the initialize function in the code • Search for InitStats in .PC • Initialize your extra stat to zero • Add code to increment your counter • Edit the “Finalize” function • Add a print statement in there.
Scheduling Events • Two type of Messages • Packets/ Cell Messages • Inter-node packets • Inter-layer packets • Non-Packet Messages • Inter-layer event messages • Self scheduled (timer) events
Message Parameters • Message Destination: • Node ID • Layer in that node • Protocol in that layer (optional) • Instance (Interface) optional • Message Event Type • Event Specific Parameters called info • Both packets and non-packet messages • Packet payload • Current header position
Message Functions • GLOMO_MsgAlloc(node, destId, layer, protocol, event_type); • GLOMOsgAddHeader(node, msg, header_size) • GLOMO_MsgSend(node, msg, delay); • GLOMO_MsgFree(node,msg); • GLOMO_MsgCopy(node,msg);
Layer Interaction With Events • Packets going through layers are annotated with information that simulate inter-layer parameter passing • Likewise for Non packets and self events • Packets are sent to event handler • C structures are used to define set of parameters for simulated API function call: typedef struct { NODE_ID sourceID; } PacketMacToRadio; • Each event type must be given its unique (within its context) “Event Type ID” number.