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

Side by Side Diff: src/routing/click/examples/nsclick-routing-node0.click

Issue 3988043: NS-3 Click Integration (Closed)
Patch Set: Incorporates Tom's comments Created 13 years, 1 month 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 // nsclick-lan-single-interface.click
2 //
3 // Copyright (c) 2011, Deutsche Telekom Laboratories
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License version
7 // 2 as published by the Free Software Foundation;
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 //
18 // Author: Ruben Merz <ruben@net.t-labs.tu-berlin.de>
19 //
20 // This is a single host Click configuration for a LAN.
21 // The node broadcasts ARP requests if it wants to find a destination
22 // address, and it responds to ARP requests made for it.
23
24 elementclass LanSimHost {
25 $ipaddr, $hwaddr |
26
27 cl::Classifier(12/0806 20/0001,12/0806 20/0002, -);
28 forhost::IPClassifier(dst host $ipaddr,-);
29 arpquerier::ARPQuerier(eth0);
30 arpresponder::ARPResponder(eth0);
31
32 ethout::Queue·········
33 -> ToDump(out_eth0.pcap,PER_NODE 1)
34 -> ToSimDevice(eth0);
35
36 // All packets received on eth0 are silently
37 // dropped if they are destined for another location
38 FromSimDevice(eth0,4096)
39 -> ToDump(in_eth0.pcap,PER_NODE 1,ENCAP ETHER)
40 -> cl;
41
42 // ARP queries from other nodes go to the ARP responder element
43 cl[0] -> arpresponder;
44
45 // ARP responses go to our ARP query element
46 cl[1] -> [1]arpquerier;
47
48 // All other packets get checked whether they are meant for us
49 cl[2]·························
50 -> Strip(14)
51 -> CheckIPHeader2
52 -> MarkIPHeader
53 -> GetIPAddress(16) // Sets destination IP address annotation from packet da ta
54 -> forhost;·
55
56 // Packets for us are pushed outside
57 forhost[0]
58 ->[0]output;
59
60 // Packets for other folks or broadcast packets get sent to output 1
61 forhost[1]
62 -> ToDump(discard.pcap,2000,PER_NODE 1,ENCAP IP)
63 -> [1]output;
64
65 // Incoming packets get pushed into the ARP query module
66 input[0]
67 -> arpquerier;
68
69 // Both the ARP query and response modules send data out to
70 // the simulated network device, eth0.
71 arpquerier
72 -> ToDump(out_arpquery.pcap,PER_NODE 1)
73 -> ethout;
74
75 arpresponder
76 -> ToDump(out_arprespond.pcap,PER_NODE 1)
77 -> ethout;
78
79 }
80
81 elementclass TapSimHost {
82 $dev |
83
84 // It is mandatory to use an IPRouteTable element with ns-3-click
85 rt :: LinearIPLookup (172.16.1.0/24 0.0.0.0 1, 172.16.2.0/24 172.16.1.2 1);
86
87 // Packets go to "tap0" which sends them to the kernel
88 input[0]
89 -> ToDump(tokernel.pcap,2000,IP,PER_NODE 1)·
90 -> ToSimDevice($dev,IP);
91
92 // Packets sent out by the "kernel" get pushed outside
93 FromSimDevice($dev,4096)
94 -> CheckIPHeader2
95 -> ToDump(fromkernel.pcap,2000,IP,PER_NODE 1)
96 -> GetIPAddress(16)
97 -> rt
98 -> [0]output;
99
100 rt[1] -> [0] output;
101 }
102
103 // Instantiate elements
104 lan::LanSimHost(eth0:ip,eth0:eth);
105 kernel::TapSimHost(tap0);
106
107 // Users can do some processing between the two elements
108 lan[0] -> kernel;
109 kernel -> lan;
110 // Packets for others or broadcasts are discarded
111 lan[1] -> Discard;
112
OLDNEW
« no previous file with comments | « src/routing/click/examples/nsclick-routing.cc ('k') | src/routing/click/examples/nsclick-routing-node2.click » ('j') | no next file with comments »

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