LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2011 Universita' di Firenze, Italy | 3 * Copyright (c) 2013 Universita' di Firenze, Italy |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
(...skipping 29 matching lines...) Expand all Loading... |
43 #include "ns3/internet-module.h" | 43 #include "ns3/internet-module.h" |
44 #include "ns3/csma-module.h" | 44 #include "ns3/csma-module.h" |
45 #include "ns3/applications-module.h" | 45 #include "ns3/applications-module.h" |
46 #include "ns3/ipv6-static-routing-helper.h" | 46 #include "ns3/ipv6-static-routing-helper.h" |
47 | 47 |
48 #include "ns3/ipv6-routing-table-entry.h" | 48 #include "ns3/ipv6-routing-table-entry.h" |
49 #include "ns3/sixlowpan-module.h" | 49 #include "ns3/sixlowpan-module.h" |
50 | 50 |
51 using namespace ns3; | 51 using namespace ns3; |
52 | 52 |
53 NS_LOG_COMPONENT_DEFINE ("ExampleSixlowpan"); | 53 NS_LOG_COMPONENT_DEFINE ("ExampleSixlowpan") |
| 54 ; |
54 | 55 |
55 int main (int argc, char** argv) | 56 int main (int argc, char** argv) |
56 { | 57 { |
57 bool verbose = false; | 58 bool verbose = false; |
58 | 59 |
59 CommandLine cmd; | 60 CommandLine cmd; |
60 cmd.AddValue ("verbose", "turn on some relevant log components", verbose); | 61 cmd.AddValue ("verbose", "turn on some relevant log components", verbose); |
61 cmd.Parse (argc, argv); | 62 cmd.Parse (argc, argv); |
62 | 63 |
63 if (verbose) | 64 if (verbose) |
(...skipping 28 matching lines...) Expand all Loading... |
92 NetDeviceContainer d1 = csma.Install (net1); | 93 NetDeviceContainer d1 = csma.Install (net1); |
93 | 94 |
94 SixLowPanHelper sixlowpan; | 95 SixLowPanHelper sixlowpan; |
95 sixlowpan.SetDeviceAttribute ("ForceEtherType", BooleanValue (true) ); | 96 sixlowpan.SetDeviceAttribute ("ForceEtherType", BooleanValue (true) ); |
96 NetDeviceContainer six1 = sixlowpan.Install (d1); | 97 NetDeviceContainer six1 = sixlowpan.Install (d1); |
97 | 98 |
98 NS_LOG_INFO ("Create networks and assign IPv6 Addresses."); | 99 NS_LOG_INFO ("Create networks and assign IPv6 Addresses."); |
99 Ipv6AddressHelper ipv6; | 100 Ipv6AddressHelper ipv6; |
100 ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64)); | 101 ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64)); |
101 Ipv6InterfaceContainer i1 = ipv6.Assign (six1); | 102 Ipv6InterfaceContainer i1 = ipv6.Assign (six1); |
102 i1.SetRouter (1, true); | 103 i1.SetForwarding (1, true); |
| 104 i1.SetDefaultRouteInAllNodes (1); |
| 105 |
103 ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64)); | 106 ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64)); |
104 Ipv6InterfaceContainer i2 = ipv6.Assign (d2); | 107 Ipv6InterfaceContainer i2 = ipv6.Assign (d2); |
105 i2.SetRouter (0, true); | 108 i2.SetForwarding (0, true); |
| 109 i2.SetDefaultRouteInAllNodes (0); |
106 | 110 |
107 /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r
*/ | 111 /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r
*/ |
108 uint32_t packetSize = 200; | 112 uint32_t packetSize = 200; |
109 uint32_t maxPacketCount = 50; | 113 uint32_t maxPacketCount = 50; |
110 Time interPacketInterval = Seconds (1.); | 114 Time interPacketInterval = Seconds (1.); |
111 Ping6Helper ping6; | 115 Ping6Helper ping6; |
112 | 116 |
113 ping6.SetLocal (i1.GetAddress (0, 1)); | 117 ping6.SetLocal (i1.GetAddress (0, 1)); |
114 ping6.SetRemote (i2.GetAddress (1, 1)); | 118 ping6.SetRemote (i2.GetAddress (1, 1)); |
115 | 119 |
(...skipping 10 matching lines...) Expand all Loading... |
126 csma.EnableAsciiAll (ascii.CreateFileStream ("example-sixlowpan.tr")); | 130 csma.EnableAsciiAll (ascii.CreateFileStream ("example-sixlowpan.tr")); |
127 csma.EnablePcapAll (std::string ("example-sixlowpan"), true); | 131 csma.EnablePcapAll (std::string ("example-sixlowpan"), true); |
128 | 132 |
129 Simulator::Stop (Seconds (100)); | 133 Simulator::Stop (Seconds (100)); |
130 NS_LOG_INFO ("Run Simulation."); | 134 NS_LOG_INFO ("Run Simulation."); |
131 Simulator::Run (); | 135 Simulator::Run (); |
132 Simulator::Destroy (); | 136 Simulator::Destroy (); |
133 NS_LOG_INFO ("Done."); | 137 NS_LOG_INFO ("Done."); |
134 } | 138 } |
135 | 139 |
LEFT | RIGHT |