Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(623)

Side by Side Diff: examples/click/nsclick-routing-node2.click

Issue 1690056: NS-3 Click Integration Code Review (Closed)
Patch Set: Created 13 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 //
2 // Copyright 2002, Univerity of Colorado at Boulder.························
3 //············································································
4 // All Rights Reserved································
5 //············································································
6 // Permission to use, copy, modify, and distribute this software and its····
7 // documentation for any purpose other than its incorporation into a········
8 // commercial product is hereby granted without fee, provided that the······
9 // above copyright notice appear in all copies and that both that···········
10 // copyright notice and this permission notice appear in supporting·········
11 // documentation, and that the name of the University not be used in········
12 // advertising or publicity pertaining to distribution of the software······
13 // without specific, written prior permission.······························
14 //············································································
15 // UNIVERSITY OF COLORADO DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS······
16 // SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND········
17 // FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT SHALL THE UNIVERSITY····
18 // OF COLORADO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL·········
19 // DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA······
20 // OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER·······
21 // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR·········
22 // PERFORMANCE OF THIS SOFTWARE.············································
23 //
24
25 // nsclick-simple-lan.click
26 //
27 // This is a simple and stupid flat routing mechanism.
28 // It broadcasts ARP requests if it wants to find a destination
29 // address, and it responds to ARP requests made for it.
30
31 elementclass DumbRouter {
32 $myaddr, $myaddr_ethernet |
33
34 class :: Classifier(12/0806 20/0001,12/0806 20/0002, -);
35 mypackets :: IPClassifier(dst host $myaddr,-);
36 myarpquerier :: ARPQuerier($myaddr,$myaddr_ethernet);
37 myarpresponder :: ARPResponder($myaddr $myaddr_ethernet);
38 ethout :: Queue -> ToSimDevice(eth0);
39
40 // It is mandatory to use a IPRouteTable element with ns-3-click
41 rt :: LinearIPLookup (172.16.2.0/24 0.0.0.0 1,172.16.1.0/24 172.16.1.2 1);
42
43 // All packets received on eth0 are silently
44 // dropped if it is destined for another location
45 FromSimDevice(eth0,4096)
46 -> ToDump(in_eth0,PER_NODE 1)
47 -> HostEtherFilter($myaddr_ethernet)
48 -> class;
49 ········
50 // ARP queries from other nodes go to the ARP responder module
51 class[0] -> myarpresponder;
52
53 // ARP responses go to our query module
54 class[1] -> [1]myarpquerier;
55
56 // All other packets get checked to see if they're meant for us
57 class[2]······························
58 -> Strip(14)
59 -> CheckIPHeader2
60 -> MarkIPHeader
61 -> GetIPAddress(16)
62 -> mypackets;·
63
64 // Packets for us go to "tap0" which sends them to the kernel
65 mypackets[0]
66 -> ToDump(tokernel,2000,IP,PER_NODE 1)·
67 -> ToSimDevice(tap0,IP);
68
69 // Packets for other folks or broadcast packets get discarded
70 mypackets[1]
71 -> ToDump(discard,2000,PER_NODE 1)
72 -> Discard;
73
74 // Packets sent out by the "kernel" get pushed into the ARP query module
75 FromSimDevice(tap0,4096)
76 -> CheckIPHeader2
77 -> ToDump(fromkernel,2000,IP,PER_NODE 1)
78 -> GetIPAddress(16)
79 -> rt
80 -> myarpquerier;
81
82 // Both the ARP query and response modules send data out to
83 // the simulated network device, eth0.
84 myarpquerier
85 -> ToDump(out_arpquery,PER_NODE 1)
86 -> ethout;
87
88 myarpresponder
89 -> ToDump(out_arprespond,PER_NODE 1)
90 -> ethout;
91
92 rt[1]->myarpquerier;
93 }
94
95
96 u :: DumbRouter(eth0,eth0);
Manuel Requena 2010/08/05 10:38:10 Same warning: examples/click/nsclick-routing-node
97
98
99
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b