New version page

U of I CS 525 - Lecture notes

Documents in this Course
Epidemics

Epidemics

12 pages

LECTURE

LECTURE

7 pages

LECTURE

LECTURE

39 pages

LECTURE

LECTURE

41 pages

P2P Apps

P2P Apps

49 pages

Lecture

Lecture

48 pages

Epidemics

Epidemics

69 pages

GRIFFIN

GRIFFIN

25 pages

Load more
Upgrade to remove ads

This preview shows page 1 out of 4 pages.

Save
View Full Document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Upgrade to remove ads
Unformatted text preview:

1CS 525: Advanced Topics in Distributed SystemsSpring 2007Indranil GuptaStructuring Project Code: “The 1 Line Solution”© November 11, 2004BackgroundDiscussion – Studying YourProtocol• How accurate are mathematical analyses?– Often simplistic, so we resort to simulations, often trace-based…• Simulations easy to do – implement, and run on your machine (or a small cluster)• How accurately can simulations model real-world stresses?• How do we know that we’re accounting for all possible kinds of failure?• All possible kinds of stresses? All possible kinds of traces?Discussion – Studying YourProtocol• Can simulations ever model reality accurately?• Is deployment the ultimate test?• Have you seen any papers that match simulation and real-world running experimental numbers?• Why?• Unfortunately, often “The paper is the system” in researchAs a Result• Rare for someone else to pick up your idea, implement it and run it in the real world (although it does happen, there are too many ideas out there…)Research SpectrumPrefer mathematical analysisCan’t sleep untilFreeBSD/Ciscois running my codeWill simulate for paperWill implement forpaper2Ideal (but difficult) Research CyclePrefer mathematical analysisCan’t sleep untilFreeBSD/Ciscois running my codeWill simulate for paperWill implement forpaperRemember: Real World Code deployment is a cycleMathematical analysisDeploySimulateImplementPresumption• Assumption: Rare for someone else to pick up your idea, implement it and run it in the real world (although it does happen, there are too many ideas out there…)• Deployment is mostly your responsibility• Problem: Design your simulation code so that you can convert your code from simulation  deployable version by changing a single line of code• “1 Line Solution”For Your Project“How do I write code for myDistributed Protocol XYZ so that I can evaluate it with 100, 000 nodes?”The 1 Line SolutionWriting The Code• Simulation engines (ns2, glomosim) etc. are one option• A required standard in some research communities (e.g., ad-hoc networking)• Not so in the p2p or (largely) the sensor net communities (yet)3Writing The Code• Let’s talk about a second option - Basic Custom Evaluation…• Threads – a bad idea! (100K threads on Linux? Try it!)• Ultimate goal – write real deployable code that can run on a socket API/your favorite OS• But also generate numbers for 1000, 10K, 100K nodes• Simulation  structure it so it’s easy to do both of above by changing just one line of code• How?struct node{char nodeid[6]; // ip(4),port(2)...}struct node{char nodeid[6]; // nodeid[0] assigned int value}struct node allnodes[10000];for(i=0;i<=9999;i++)schedule(allnodes[i]);schedule(struct node *n,…){recv();process;send();}node 0000node 0001 node 9999…………...struct node{char nodeid[6];}schedule(struct node *n,…){recv();process;send();}node 0000node 0001 node 9999…………...struct node allnodes[10000];SimulatorAll code for a nodeBuffer1Buffer2struct msg{char src[6];char dest[6];}struct node{char nodeid[6];}node 0000node 0001 node 9999…………...SimulatorAll code for a nodeBuffer1Buffer2101 102 103 104 …for(i=0;i<=9999;i++)schedule(allnodes[i]);swap buffer1 and buffer2;struct msg{char src[6];char dest[6];}struct node{char nodeid[6];}node 0000node 0001 node 9999…………...SimulatorAll code for a nodeBuffer1Buffer2101 102 103 104 …for(i=0;i<=9999;i++)schedule(allnodes[i]);swap buffer1 and buffer2;Feature msgdelays to accountfor topology4The advantage of such an elaborate spread?• Layering gives clean separation of implementation from simulation• Easy debugging (No global variables for the implementation, please!)• And…struct node{char nodeid[6];}recv(); send();node 0000node 0001 node 9999…………...SimulatorAll code for a nodeBuffer1Buffer2101 102 103 104 …for(i=0;i<=9999;i++)schedule(allnodes[i]);swap buffer1 and buffer2;struct node{char nodeid[6];}recv(); send();Socket InterfaceAll code for a nodesocket_send()socket_ recv()Change one line of code toturn a simulation into a deployable versionUsing function pointers,change a single line of codeto switch simulationdeployablecodestruct node{char nodeid[6];}recv(); send();Interface toanotherSimulatorAll code for a nodesim_send()sim_ recv()Change one line of code toplug it into a different simulation engineUsing function pointers,change a single line of codeto switch to a differentsimulation engine• Easier to do above with C or Java or C++• Can put an “Application” layer on top of the “Real Code” layer• Of course, you are free to structure your code in a different way should you so


View Full Document
Download Lecture notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?