diff --git a/scratch/example-sixlowpanTest.cc b/scratch/example-sixlowpanTest.cc new file mode 100644 index 000000000..f7bcaa65e --- /dev/null +++ b/scratch/example-sixlowpanTest.cc @@ -0,0 +1,114 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2013 Universita' di Firenze, Italy + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Tommaso Pecorella + */ + + +#include +#include "ns3/core-module.h" +#include "ns3/internet-module.h" +#include "ns3/applications-module.h" +#include "ns3/ipv6-static-routing-helper.h" +#include "ns3/mobility-module.h" +#include "ns3/spectrum-module.h" +#include "ns3/propagation-loss-model.h" +#include "ns3/log.h" +#include "ns3/ipv6-routing-table-entry.h" +#include "ns3/sixlowpan-module.h" +#include "ns3/lr-wpan-module.h" + +using namespace ns3; + + + +int main (int argc, char** argv) +{ +#if 0 + LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("LrWpanMac",LOG_LEVEL_ALL); + LogComponentEnable("LrWpanPhy",LOG_LEVEL_ALL); + LogComponentEnable ("LrWpanNetDevice", LOG_LEVEL_ALL); + LogComponentEnable("SixLowPanNetDevice", LOG_LEVEL_ALL); +#endif + + NodeContainer nodes; + nodes.Create(2); + + LrWpanHelper lrWpanHelper; + // Add and install the LrWpanNetDevice for each node + NetDeviceContainer lrwpanDevices = lrWpanHelper.Install(nodes); + + // Fake PAN association and short address assignment. + lrWpanHelper.AssociateToPan (lrwpanDevices, 0); + + MobilityHelper mobility; + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.SetPositionAllocator ("ns3::GridPositionAllocator", + "MinX", DoubleValue (0.0), + "MinY", DoubleValue (0.0), + "DeltaX", DoubleValue (20), + "DeltaY", DoubleValue (20), + "GridWidth", UintegerValue (3), + "LayoutType", StringValue ("RowFirst")); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (nodes); + + + InternetStackHelper internetv6; + internetv6.Install (nodes); + + SixLowPanHelper sixlowpan; + NetDeviceContainer devices = sixlowpan.Install (lrwpanDevices); + + Ipv6AddressHelper ipv6; + ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64)); + Ipv6InterfaceContainer deviceInterfaces; + deviceInterfaces = ipv6.Assign (devices); + // check if adresses are assigned + //std::cout<< deviceInterfaces.GetAddress(0,1)<