Simulation and Modeling
Lecture #2
Practical Activity: MaRS Programmer’s Manual (Replaces Chapter 2 in Textbook)
By
Ihab Ali, Ph.D., SMIEEE
Professor of Networks and Security
Helwan University
MaRS Directory Structure
• comps: Source Files for Components.
• doc: User’s and Programmer’s Manuals.
• etc: Example Network Files.
• Include: Header Files.
• papers: Papers published by Simulator Development Team.
• sim: Simulator’s Main Source Files.
• Other Folders are out of scope of this course.
Network File
param 'node1' # node1
param 1000 # Delay to process a packet (uSec): 1000
param -1 # Buffer space in bytes (-1=inf): -1
param -1 # Mean time btw failures (sec): -1
param 0 # Interfailure dist (0=>EXP, 1=>UNIF): 0
param 0 # Enter standard deviation if UNIF: 0
param 1200 # Mean time to repair (sec): 1200
param 0 # Repair time dist (0=>EXP, 1=>UNIF): 0
param 0 # Enter standard deviation if UNIF: 0
component 'lk1-3' LINK 457 338
param 'lk1-3' # lk1-3
param 10000 # Link propagation delay (USECS): 10000
param 187500 # Link bandwidth (bytes/sec): 187500
param -1 # Mean time btw failures (msecs): -1
param 0 # Interfailure dist (0=>EXP, 1=>UNIF): 0
param 0 # Enter standard deviation if UNIF: 0
param 10 # Mean time to repair (msecs): 10
param 0 # Repair time dist (0=>EXP, 1=>UNIF): 0
param 0 # Enter standard deviation if UNIF: 0
Network File
component 'spf1' SPF 602 310
param 'spf1' # spf1
param 1000 # Time btw topology broad
(msec): 1000
param 1000 # Standard deviation: 1000
component 'CostFcn' LINK_COST_FUNC 443 74
param 1 # Cost fcn 1:hndl 2:dly 3:util 4:hop: 1
(hndl: Hop Normalized Delay)
param 100000 # Delay cost fcn max delay:
100000
param 10 # Delay cost fcn min delay: 10
param 10 # Maximum Cost: 10
param 1 # Minimum Cost: 1
Network File
component 'ftp_node2-node3_so_3' FTP_SOURCE 145 565
param 'ftp_node2-node3_so_3' # ftp_node2-node3_so_3
param 0 # Not select(0), select(1) : 0
param 'On' # Initial Connection status: On
param -1 # How many connections (-1 inf): -1
param -1 # Ave packets per conn. (-1 inf): -1
param 512 # Ave Packet length (byte): 512
param 0 # Ave delay btw conns (mSec): 0
param 20000 # Delay btw packets (uSec): 20000
param -1 # Max Produce w size (-1 inf): -1
param 8 # Max Send w size (-1 inf): 8
component 'ftp_node2-node3_si_3' FTP_SINK 343 409
param 'ftp_node2-node3_si_3' # ftp_node2-node3_si_3
Network File
component 'Monitor' PERF_MON 443 94
neighbor1 'node1' 'lk1-3'
neighbor1 'node1' 'lk1-6'
neighbor1 'node1' 'spf1'
neighbor1 'node1' 'lk7-1'
neighbor1 'node1' 'ftp_node1-node3_so_1'
neighbor1 'node1' 'ftp_node1-node4_so_2'
peer 'ftp_node1-node3_so_1' 'ftp_node1-
node3_si_1'
Event Queue
• typedef struct _event { • /* add ev to the event queue,
preserving time order */
• struct _event *ev_next;
• static inline
• Evtype ev_type;
• ev_adda(ev)
• tick_t ev_time;
• register Event *ev;
• PFP ev_rtn;
• {
• Component *ev_src;
• heap_insert(event_queue, ev-
• Component *ev_dest;
>ev_time, (caddr_t)ev);
• Packet *ev_pkt;
• caddr_t ev_arg;
• return(TRUE);
• } Event;
• }
Example Component Structure: Node
typedef struct _Nodee {
typedef struct _Component { struct _Nodee *nd_next, *nd_prev;
struct _Component *co_next, *co_prev; short nd_class; /* = OTHER_CLASS */
short nd_type; /* =NODE */
short co_class; /* Class of component */
char nd_name[40];
short co_type; /* Type of component that I am. */
PFP nd_action; /* Main function of node */
char co_name[40];/* Name of component */
COMP_OBJECT nd_picture;/* Graphics object that displays this thing */
PFP co_action; /* Main function of component */
list *nd_neighbors;/* List of neighbors of this thing */
COMP_OBJECT co_picture; /* Graphics
short nd_menu_up;/* If true, then the text window is up */
object that displays this thing */
queue *nd_params;/* Variable-length queue of parameters */
list *co_neighbors;
Param *nd_delay; /* USECS it takes to process a packet */
short co_menu_up; /* If true,
then the text window is up */ Param *nd_buffer_space;/* Max node buffer space (in bytes)
*/
queue *co_params; /* Variable- Param *max_occupied_space; /* Max occupied buffer space */
length queue of parameters */
Param *nd_pq;/* Input packet queue for received routing */
/* Any other info that component needs to keep--
will vary. Param *nd_status; /* State of node : up or down */
. Param *nd_time_btw_fails; /* Avg time between failures in
secs */
. Param *nd_time_for_repair; /* Time for repair in secs */
. */ Param *dist_chosen_fail;
} Component; Param *dist_chosen_repair;
Param *sd_fail; /* Standard deviations for unif dist */
Param *sd_repair;
} Nodee;