Skip to content

Commit

Permalink
Additing MTU supportings
Browse files Browse the repository at this point in the history
  • Loading branch information
DGunasekara committed Aug 25, 2017
1 parent 949d2f8 commit d8d58b3
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
91 changes: 91 additions & 0 deletions fragmentation-ipv6-two-MTU.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include <fstream>
/* #include "core-module.h"
#include "internet-module.h"
#include "csma-module.h"

This comment has been minimized.

Copy link
@DGunasekara

DGunasekara Aug 25, 2017

Author Owner

more helper files have to be uploaded and it is linked only with ipv6-static-routing-helper.h

#include "internet-apps-module.h" */
#include "ipv6-static-routing-helper.h"

// #include "ipv6-routing-table-entry.h"



NS_LOG_COMPONENT_DEFINE ("FragmentationIpv6TwoMtuExample");

int main (int argc, char** argv)
{
bool connection = false;

CommandLine cmd;
cmd.AddValue ("connection", "turn on log components", connection);
cmd.Parse (argc, argv);

if (connection)
{
LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
}

/* NS_LOG_INFO ("Create nodes.");
Ptr<Node> n0 = CreateObject<Node> ();
Ptr<Node> r = CreateObject<Node> ();
Ptr<Node> n1 = CreateObject<Node> ();
NodeContainer net1 (n0, r);
NodeContainer net2 (r, n1);
NodeContainer all (n0, r, n1);
NS_LOG_INFO ("Create IPv6 Internet Stack");
InternetStackHelper internetv6;
internetv6.Install (all);
NS_LOG_INFO ("Create channels.");
CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
NetDeviceContainer d2 = csma.Install (net2);
csma.SetDeviceAttribute ("Mtu", UintegerValue (5000));

This comment has been minimized.

Copy link
@DGunasekara

DGunasekara Aug 25, 2017

Author Owner

this statement should be executed as MTU value is a fact for fragmentations

NetDeviceContainer d1 = csma.Install (net1);
NS_LOG_INFO ("Create networks and assign IPv6 Addresses.");
Ipv6AddressHelper ipv6;
ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
Ipv6InterfaceContainer i1 = ipv6.Assign (d1);
i1.SetForwarding (1, true);
i1.SetDefaultRouteInAllNodes (1);
ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
Ipv6InterfaceContainer i2 = ipv6.Assign (d2);
i2.SetForwarding (0, true);
i2.SetDefaultRouteInAllNodes (0);
Ipv6StaticRoutingHelper routingHelper;
Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> (&std::cout);
routingHelper.PrintRoutingTableAt (Seconds (0), n0, routingStream);*/

/* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r */
uint32_t packetSize = 4096;
uint32_t maxPacketCount = 5;
Time interPacketInterval = Seconds (1.0);
Ping6Helper ping6;

ping6.SetLocal (i1.GetAddress (0, 1));
ping6.SetRemote (i2.GetAddress (1, 1));

ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
ping6.SetAttribute ("Interval", TimeValue (interPacketInterval));
ping6.SetAttribute ("PacketSize", UintegerValue (packetSize));
ApplicationContainer apps = ping6.Install (net1.Get (0));
apps.Start (Seconds (2.0));
apps.Stop (Seconds (20.0));

AsciiTraceHelper ascii;
csma.EnableAsciiAll (ascii.CreateFileStream ("fragmentation-ipv6-two-mtu.tr"));
csma.EnablePcapAll (std::string ("fragmentation-ipv6-two-mtu"), true);

NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
Simulator::Destroy ();
NS_LOG_INFO ("Done.");
}
51 changes: 51 additions & 0 deletions ipv6-static-routing-helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

#define IPV6_STATIC_ROUTING_HELPER_H

#include "ipv6.h"
#include "ipv6-static-routing.h"
#include "ptr.h"
#include "ipv6-address.h"
#include "node.h"
#include "net-device.h"

#include "node-container.h"
#include "net-device-container.h"
#include "ipv6-routing-helper.h"


class Ipv6StaticRoutingHelper : public Ipv6RoutingHelper
{
public:
Ipv6StaticRoutingHelper ();

Ipv6StaticRoutingHelper (const Ipv6StaticRoutingHelper &);

Ipv6StaticRoutingHelper* Copy (void) const;

virtual Ptr<Ipv6RoutingProtocol> Create (Ptr<Node> node) const;

Ptr<Ipv6StaticRouting> GetStaticRouting (Ptr<Ipv6> ipv6) const;
/*
void AddMulticastRoute (Ptr<Node> n, Ipv6Address source, Ipv6Address group,
Ptr<NetDevice> input, NetDeviceContainer output);
void AddMulticastRoute (std::string n, Ipv6Address source, Ipv6Address group,
Ptr<NetDevice> input, NetDeviceContainer output);
void AddMulticastRoute (Ptr<Node> n, Ipv6Address source, Ipv6Address group,
std::string inputName, NetDeviceContainer output);
void AddMulticastRoute (std::string nName, Ipv6Address source, Ipv6Address group,
std::string inputName, NetDeviceContainer output);
*/
#if 0

void SetDefaultMulticastRoute (Ptr<Node> n, Ptr<NetDevice> nd);
void SetDefaultMulticastRoute (Ptr<Node> n, std::string ndName);
void SetDefaultMulticastRoute (std::string nName, Ptr<NetDevice> nd);
void SetDefaultMulticastRoute (std::string nName, std::string ndName);
#endif
private:
Ipv6StaticRoutingHelper &operator = (const Ipv6StaticRoutingHelper &o);
};

0 comments on commit d8d58b3

Please sign in to comment.