1 / 14

REAL

REAL. An Engineering Approach to Computer Networking. Basics. REAL: globals and simulation engine. thread. UNIX. Threads. Thread = infinite loop for (;;) Share a single address space can read and write all globals but not another thread’s stack

Download Presentation

REAL

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. REAL An Engineering Approach to Computer Networking

  2. Basics • REAL: globals and simulation engine thread UNIX

  3. Threads • Thread = infinite loop • for (;;) • Share a single address space • can read and write all globals • but not another thread’s stack • Communication is through sendm(dest, key, packet) and recvm(&dest, &key, &pkt) • Only pointers to packets are exchanged • sender must not free a packet - receivers do this

  4. REAL functions • sendm(dest, key, pkt) • recvm(&dest, &key, &pkt) • blocking • get_node_id() • runtime() • struct timeval { long tv_sec, long tv_usec} • abs_advance() • make_pkt() • pkt type is DATA • make_float() • pr_error()

  5. A simple node function #include "../kernel/real.h" ecn_dummy() { PKT_PTR pkt; int node, num_pkts_sent = 0; ident destn, sender, sink; long key; timev now; int seq_no = 0; node = get_node_id(); /* find out local id */ sink = assigned_sink[node]; /* find out sink (from .l file ) */ abs_advance(node_start_time[node]); /* advance time to start time */ now = runtime();

  6. Contd. /* send the request packet */ if(node is 1) { make_pkt(pkt); pkt->dest = sink; /* use num_pkts field to store command (0 or 1) */ pkt->data[0] = num_pkts[node]; sendm(sink, 0, pkt); printf("Node 1 sent request packet\n"); }

  7. Contd. for (ever) { sender = recvm(&destn, &key, &pkt); now = runtime(); switch (pkt->type){ case ACK: /* just free acks for now */ free(pkt); break; case INT: /* when the line goes free */ free(pkt); break; case DATA: /* convert the request packet to reply packet and send * it right back */ pkt->type = ACK; pkt->dest = pkt->source; pkt->source= node; sendm(pkt->dest, 0, pkt); break;

  8. How it works • Simulator simulates a topology given to it in an input file • described in NetLanguage • parameters, nodes, edges • defaults • node function = C function implementing a thread is part of node description • Simulator parses the file and starts the threads • Same C function may run at multiple nodes • At each instant, run the thread which has the earliest packet to serve • Preemption only during recvm() • Details in sim/src

  9. Things to watch out for • Globals can be modified by any thread • need to synchronize access • For non-shared global, index by node ID (from get_node_id()) • Debugging: can land up at the same statement many times! • Threads are serial, but programming abstraction is that they run in parallel • I/O by a thread blocks all others • Nodes exchange pointers to packets

  10. Adding a new function • Write the function • Modify sim/sources/makefile and sim/makefile

  11. Adding a new parameter • Change lang/lang.lex to add the name • Change lang/lang.yacc to read the value into a variable • Change kernel/parameters.h to make it a global • Recompile

  12. Useful files • sim/kernel/types.h • the packet type • sim/ kernel/config.h • configuration parameters • sim/ kernel/parameters.h • globals • sim/ lang/lang.lex; sim/ lang/lang.yacc • NetLanguage scanner and parser • src/defs.h • additions to C syntax • src/nest.a • simulation engine

  13. RealEdit • Java based GUI for creating input files and simulating them on a server • http://real.cs.cornell.edu:80

  14. More information • http://www.cs.cornell.edu/home/skeshav/real/overview.html • Also contains online manual pages • Searchable archive of REAL mailing list is at http://minnie.cs.odfa.oz.au/cgi-bin/real.cgi

More Related