isabelgh

Routy

Sep 20th, 2018
760
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. % module for running the program
  2.  
  3. -module(test1).
  4. -compile(export_all).
  5.  
  6.  
  7. start() ->
  8.  
  9.   Com1 = 'sweden@127.0.0.1',
  10.  
  11.     % start the routers
  12.  
  13.     routy:start(r1, stockholm),
  14.     routy:start(r2, lund),
  15.     routy:start(r3, malmo),
  16.     routy:start(r4, lulea),
  17.     routy:start(r5, boras),
  18.     routy:start(r6, broo),
  19.  
  20.     timer:sleep(100),
  21.  
  22.     % connect them to each other
  23.  
  24.     %add sthlm to malmö
  25.     r1 ! {add, malmo, {r3, Com1}},
  26.     timer:sleep(100),
  27.     r3 ! {add, stockholm, {r1, Com1}},
  28.     timer:sleep(100),
  29.  
  30.     %add malmö to borås
  31.     r3 ! {add, boras, {r5, Com1}},
  32.     timer:sleep(100),
  33.     r5 ! {add, malmo, {r3, Com1}},
  34.     timer:sleep(100),
  35.  
  36.     %add luleå to borås
  37.     r5 ! {add, lulea, {r4, Com1}},
  38.     timer:sleep(100),
  39.     r4 ! {add, boras, {r5, Com1}},
  40.     timer:sleep(100),
  41.  
  42.     %add lund to luleå
  43.     r2 ! {add, lulea, {r4, Com1}},
  44.     timer:sleep(100),
  45.     r4 ! {add, lund, {r2, Com1}},
  46.     timer:sleep(100),
  47.  
  48.     %add lund to stockholm),
  49.     r2 ! {add, stockholm, {r1, Com1}},
  50.     timer:sleep(100),
  51.     r1 ! {add, lund, {r2, Com1}},
  52.     timer:sleep(100),
  53.  
  54.     %add lund to broo
  55.     r2 ! {add, broo, {r6, Com1}},
  56.     timer:sleep(100),
  57.     r6 ! {add, lund, {r2, Com1}},
  58.     timer:sleep(100),
  59.  
  60.     %add broo to stockholm
  61.     r1 ! {add, broo, {r6, Com1}},
  62.     timer:sleep(100),
  63.     r6 ! {add, stockholm, {r1, Com1}},
  64.     timer:sleep(100),
  65.  
  66.     %broadcast and update
  67.  
  68.     r1 ! broadcast,
  69.     timer:sleep(100),
  70.     r2 ! broadcast,
  71.     timer:sleep(100),
  72.     r3 ! broadcast,
  73.     timer:sleep(100),
  74.     r4 ! broadcast,
  75.     timer:sleep(100),
  76.     r5 ! broadcast,
  77.     timer:sleep(100),
  78.     r6 ! broadcast,
  79.     timer:sleep(100),
  80.  
  81.     r1 ! update,
  82.     timer:sleep(100),
  83.     r2 ! update,
  84.     timer:sleep(100),
  85.     r3 ! update,
  86.     timer:sleep(100),
  87.     r4 ! update,
  88.     timer:sleep(100),
  89.     r5 ! update,
  90.     timer:sleep(100),
  91.     r6 ! update.
  92.  
  93. stop() ->
  94.     routy:stop(r1),
  95.     routy:stop(r2),
  96.     routy:stop(r3),
  97.     routy:stop(r4),
  98.     routy:stop(r5),
  99.     routy:stop(r6).
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×