import rosePakcs -------------------------// ARP Mapping table, format: IP -> Eth address mapTable1 = [ ([154,250,159,2],[01,05,09,00,00,02]), ([154,250,159,3],[01,05,09,00,00,03]) ] mapTable2 = [ ([148,208,179,2],[01,07,09,00,00,02]), ([148,208,179,3],[01,07,09,00,00,03]) ] rtable = [ ([154,250,159,1],32,[127,0,0,1],0), ([154,250,159,0],24,[70,71,72,73],1), ([148,208,179,9],32,[127,0,0,1],0), ([148,208,179,0],24,[80,81,82,83],2), ([0,0,0,0],0,[90,91,92,93],2) ] --================ ELEMENTS DECLARATION --------- click router left side elements declaration ffr1 = fromDevice (Eth0: I 3:[]) fclas1 = classifier [Pat [12,8,13,6,21,1,0], Pat [12,8,13,6,21,2,1], Pat [12,8,13,0,2] ] fpt1 = paint [Col 1111] fdrop1 = dropBroadcasts [] fptee1 = paintTee [Col 1111] fipgw1 = ipgwOptions [] ffix1 = fixIPSrc [Ip [154,250,159,1]] fdec1 = decIPTTL [] ffrag1 = ipFragmenter [I 1500] farpq1 = arpQuerier [Ip [154,250,159,1], Eth [1,5,9,0,0,1], Mapt mapTable1] fresp = arpResponder [ Mapt [([154,250,159,1],[01,05,09,00,00,01]), ([148,208,179,1],[01,05,09,00,00,01])] ] fq1 = queue [Queue [] ] ftodev1= toDevice [Eth0] ---------click router right side elements declaration ffr2 = fromDevice (Eth1: I 2:[]) fclas2 = classifier [Pat [12,8,13,6,21,1,0], Pat [12,8,13,6,21,2,1], Pat [12,8,13,0,2] ] fpt2 = paint [Col 2222] fdrop2 = dropBroadcasts [] fptee2 = paintTee [Col 2222] fipgw2 = ipgwOptions [] ffix2 = fixIPSrc [Ip [148,208,179,1]] fdec2 = decIPTTL [] ffrag2 = ipFragmenter [I 1500] farpq2 = arpQuerier [Ip [148,208,179,1], Eth [1,7,9,0,0,1], Mapt mapTable2] fq2 = queue [Queue [] ] ftodev2= toDevice [Eth1] ---------click router center side elements declaration fstr = strip [I 14] fcheck = checkIPHeader [] fgetip = getIPAddress [] flook = lookupIPRoute [RT rtable] flinux = toLinux [] --==================================FINITE CLIK ROUTER ============================ --E1ArpQ rfinite1 n = fromDevice [Eth0, I n] ->- r1a r1a = (fclas1,0) =>- rout r1a = (fclas1,1) =>= (1,rsink) r1a = (fclas1,2) =>- r1b r1b = fpt1 ->- waist rfinite2 n = fromDevice [Eth1,I n] ->- r2a r2a = (fclas2,0) =>- rout2 r2a = (fclas2,1) =>= (1,rsink2) r2a = (fclas2,2) =>- r2b r2b = fpt2->- waist waist = fstr ->- fcheck ->- fgetip ->- branch branch = (flook,0) =>- flinux branch = (flook,1) =>- fdrop1 ->- rpt1 branch = (flook,2) =>- fdrop2 ->- rpt2 --Output branch1 rpt1 = (fptee1,0) =>- ripg rpt1 = (fptee1,1) =>- icmpError [Err [154,250,159,1] 5 0 ] -@- branch ripg = (fipgw1,0) =>- ffix1->- rdec ripg = (fipgw1,1) =>- icmpError [Err [154,250,159,1] 12 0 ] -@- branch rdec = (fdec1 ,0) =>- rfrag rdec = (fdec1 ,1) =>- icmpError [Err [154,250,159,1] 11 0 ] -@- branch rfrag = (ffrag1,0) =>- rsink rfrag = (ffrag1,1) =>- icmpError [Err [154,250,159,1] 3 4 ] -@- branch rsink = farpq1 ->- rout rout = fq1 ->- ftodev1 --Output branch2 rpt2 = (fptee2,0) =>- ripg2 rpt2 = (fptee2,1) =>- icmpError [Err [148,208,179,1] 5 0 ] -@- branch ripg2 = (fipgw2,0) =>- ffix2 ->- rdec2 ripg2 = (fipgw2,1) =>- icmpError [Err [148,208,179,1] 12 0 ] -@- branch rdec2 = (fdec2, 0) =>- rfrag2 rdec2 = (fdec2, 1) =>- icmpError [Err [148,208,179,1] 11 0 ] -@- branch rfrag2= (ffrag2,0) =>- rsink2 rfrag2= (ffrag2,1) =>- icmpError [Err [148,208,179,1] 3 4 ] -@- branch rsink2= farpq2 ->- rout2 rout2 = fq2 ->- ftodev2 --==================================END FINITE CLIK ROUTER SPECIFICATION================== -- INFINITE TEST -- Curry enables more than one rewrite path, look at rA2 -- a complete router ready to test is: -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- rinfiniteA = ( infiniteSource [Eth0] ->- riA2 ) [] -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- with this, the test should be, e.g. (take 3 (rinfiniteA !! 0)) -- Next router can be tested with: simuln 3 rinfiniteA -- rinfiniteA = ( infiniteSource [Eth0] ->- riA2 ) -- remember that operators are riA2 = (fclas1,2) =>- riA3 -- in infix and left associativity riA2 = (fclas1,1) =>- riA3 -- precedence is 5 e.g. 3 +4 ->- 2-1 riA3 = fpt1->- waistin -- is (3+4) ->- (2-1) waistin = fstr ->- fcheck ->- fgetip