From 6f9dada4303eb1b853065053887923d6f684f527 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Thu, 2 Jul 2009 21:57:00 -0700 Subject: [PATCH 1/3] some fixes to the manual for IPv4 refactoring --- doc/manual/node.texi | 135 +++++++++++++++++----------------------- doc/manual/routing.texi | 16 +++-- 2 files changed, 69 insertions(+), 82 deletions(-) diff --git a/doc/manual/node.texi b/doc/manual/node.texi index 61fbf727f..a79694df6 100644 --- a/doc/manual/node.texi +++ b/doc/manual/node.texi @@ -121,86 +121,74 @@ ARP, UDP, TCP, and other related protocols. Internet Nodes are not subclasses of class Node; they are simply Nodes that have had a bunch of IPv4-related objects aggregated to them. They can be put together by hand, or -via a helper function @code{AddInternetStack ()} which does the -following: +via a helper function @code{InternetStackHelper::Install ()} which does the +following to all nodes passed in as arguments: @verbatim -void AddInternetStack (Ptr node) +void +InternetStackHelper::Install (Ptr node) const { - // Create layer-3 protocols - Ptr ipv4 = CreateObject (); - Ptr arp = CreateObject (); - ipv4->SetNode (node); - arp->SetNode (node); + if (node->GetObject () != 0) + { + NS_FATAL_ERROR ("InternetStackHelper::Install(): Aggregating " + "an InternetStack to a node with an existing Ipv4 object"); + return; + } - // Create an L4 demux - Ptr ipv4L4Demux = CreateObject (); + CreateAndAggregateObjectFromTypeId (node, "ns3::ArpL3Protocol"); + CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv4L3Protocol"); + CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv4L4Protocol"); + CreateAndAggregateObjectFromTypeId (node, "ns3::UdpL4Protocol"); + node->AggregateObject (m_tcpFactory.Create ()); + Ptr factory = CreateObject (); + node->AggregateObject (factory); + // Set routing + Ptr ipv4 = node->GetObject (); + Ptr ipv4Routing = m_routing->Create (node); + ipv4->SetRoutingProtocol (ipv4Routing); +} +@end verbatim - // Create transport protocols and insert them into the demux - Ptr udp = CreateObject (); - Ptr tcp = CreateObject (); - - ipv4L4Demux->SetNode (node); - udp->SetNode (node); - tcp->SetNode (node); - - ipv4L4Demux->Insert (udp); - ipv4L4Demux->Insert (tcp); - - // Add factories for instantiating transport protocol sockets - Ptr udpFactory = CreateObject (); - Ptr tcpFactory = CreateObject (); - Ptr ipv4Impl = CreateObject (); - - udpFactory->SetUdp (udp); - tcpFactory->SetTcp (tcp); - ipv4Impl->SetIpv4 (ipv4); - - // Aggregate all of these new objects to the node - node->AggregateObject (ipv4); - node->AggregateObject (arp); - node->AggregateObject (ipv4Impl); - node->AggregateObject (udpFactory); - node->AggregateObject (tcpFactory); - node->AggregateObject (ipv4L4Demux); +Note that the Ipv4 routing protocol is configured and set outside this +function. By default, the following protocols are added to Ipv4: +@verbatim +InternetStackHelper::InternetStackHelper () +{ + SetTcp ("ns3::TcpL4Protocol"); + static Ipv4StaticRoutingHelper staticRouting; + static Ipv4GlobalRoutingHelper globalRouting; + static Ipv4ListRoutingHelper listRouting; + listRouting.Add (staticRouting, 0); + listRouting.Add (globalRouting, -10); + SetRoutingHelper (listRouting); } @end verbatim @subsection Internet Node structure -The Internet Node (an ns-3 Node augmented by aggregation to have one or more +An IPv4-capable Node (an ns-3 Node augmented by aggregation to have one or more IP stacks) has the following internal structure. @subsubsection Layer-3 protocols At the lowest layer, sitting above the NetDevices, are the "layer 3" -protocols, including IPv4, IPv6, and ARP. These protocols provide -the following key methods and data members: +protocols, including IPv4, IPv6 (in the future), and ARP. The +@code{class Ipv4L3Protocol} is an +implementation class whose public interface is +typically @code{class Ipv4} (found in src/node directory), but the +Ipv4L3Protocol public API is also used internally in the +src/internet-stack directory at present. +In class Ipv4L3Protocol, one method described below is @code{Receive ()}: @verbatim -class Ipv4L3Protocol : public Object -{ -public: - // Add an Ipv4 interface corresponding to the provided NetDevice - uint32_t AddInterface (Ptr device); - - // Receive function that can be bound to a callback, for receiving - // packets up the stack - void Receive( Ptr device, Ptr p, uint16_t protocol, - const Address &from); - - // Higher-level layers call this method to send a packet - // down the stack to the MAC and PHY layers - // - void Send (Ptr packet, Ipv4Address source, - Ipv4Address destination, uint8_t protocol); - -private: - Ipv4InterfaceList m_interfaces; - - // Protocol handlers -} + /** + * Lower layer calls this method after calling L3Demux::Lookup + * The ARP subclass needs to know from which NetDevice this + * packet is coming to: + * - implement a per-NetDevice ARP cache + * - send back arp replies on the right device + */ + void Receive( Ptr device, Ptr p, uint16_t protocol, const Address &from, + const Address &to, NetDevice::PacketType packetType); @end verbatim -There are many more functions (such as @code{Forward ()}) but we will -focus on the above four items from an architectural perspective. First, note that the @code{Receive ()} function has a matching signature to the ReceiveCallback in the @code{class Node}. This function pointer @@ -228,24 +216,15 @@ to send down to the Ipv4L3Protocol object can call This class nicely demonstrates two techniques we exploit in ns-3 to bind objects together: callbacks, and object aggregation. -Once IPv4 has determined that a packet is for the local node, it +Once IPv4 routing has determined that a packet is for the local node, it forwards it up the stack. This is done with the following function: @verbatim void -Ipv4L3Protocol::ForwardUp (Ptr p, Ipv4Header const&ip, - Ptr incomingInterface) -{ - NS_LOG_FUNCTION (this << p << &ip); - - Ptr demux = m_node->GetObject (); - Ptr protocol = demux->GetProtocol (ip.GetProtocol ()); - protocol->Receive (p, ip.GetSource (), ip.GetDestination (), incomingInterface); -} +Ipv4L3Protocol::LocalDeliver (Ptr packet, Ipv4Header const&ip, uint32_t iif) @end verbatim -The first step is to find the aggregated Ipv4L4Demux object. Then, this -object is consulted to look up the right Ipv4L4Protocol, based on IP protocol +The first step is to find the right Ipv4L4Protocol object , based on IP protocol number. For instance, TCP is registered in the demux as protocol number 6. Finally, the @code{Receive()} function on the Ipv4L4Protocol (such as @code{TcpL4Protocol::Receive} is called. @@ -321,10 +300,10 @@ addressing tuple (local port, local address, destination port, destination address) associated with the socket, and a receive callback for the socket. @end itemize -@subsection Internet Node interfaces +@subsection Ipv4-capable node interfaces Many of the implementation details, or internal objects themselves, -of Internet Node objects are not exposed at the simulator public +of Ipv4-capable Node objects are not exposed at the simulator public API. This allows for different implementations; for instance, replacing the native ns-3 models with ported TCP/IP stack code. diff --git a/doc/manual/routing.texi b/doc/manual/routing.texi index b96998fd1..733989df5 100644 --- a/doc/manual/routing.texi +++ b/doc/manual/routing.texi @@ -106,18 +106,26 @@ reduce computations and runtime performance. Presently, global centralized IPv4 unicast routing over both point-to-point and shared (CSMA) links is supported. +By default, when using the ns-3 helper API and the default InternetStackHelper, +global routing capability will be added to the node, and global routing +will be inserted as a routing protocol with lower priority than the +static routes (i.e., users can insert routes via Ipv4StaticRouting API +and they will take precedence over routes found by global routing). + @subsection Global Unicast Routing API The public API is very minimal. User scripts include the following: @verbatim -#include "ns3/global-route-manager.h" +#include "ns3/helper-module.h" @end verbatim +If the default InternetStackHelper is used, then an instance of +global routing will be aggregated to each node. After IP addresses are configured, the following function call will cause all of the nodes that have an Ipv4 interface to receive forwarding tables entered automatically by the GlobalRouteManager: @verbatim - GlobalRouteManager::PopulateRoutingTables (); + Ipv4GlobalRoutingHelper::PopulateRoutingTables (); @end verbatim @emph{Note:} A reminder that the wifi NetDevice will work but does not @@ -127,7 +135,7 @@ OLSR dynamic routing described below. It is possible to call this function again in the midst of a simulation using the following additional public function: @verbatim - GlobalRouteManager::RecomputeRoutingTables (); + Ipv4GlobalRoutingHelper::RecomputeRoutingTables (); @end verbatim which flushes the old tables, queries the nodes for new interface information, and rebuilds the routes. @@ -135,7 +143,7 @@ and rebuilds the routes. For instance, this scheduling call will cause the tables to be rebuilt at time 5 seconds: @verbatim - Simulator::Schedule (Seconds (5),&GlobalRouteManager::RecomputeRoutingTables); + Simulator::Schedule (Seconds (5),&Ipv4GlobalRoutingHelper::RecomputeRoutingTables); @end verbatim @subsection Global Routing Implementation From 3ce8fe78e71fafcab6b927325d6359bf57f4896c Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Thu, 2 Jul 2009 22:36:44 -0700 Subject: [PATCH 2/3] fix internet-stack figures --- doc/manual/figures/internet-node-recv.dia | Bin 3427 -> 3597 bytes doc/manual/figures/internet-node-send.dia | Bin 3352 -> 3206 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/manual/figures/internet-node-recv.dia b/doc/manual/figures/internet-node-recv.dia index 9343476177461ffab68b06c5faf4057e79638d25..5f9bdfc2f3e0760804ab5829a481e38718448a16 100644 GIT binary patch literal 3597 zcmV+o4)XCIiwFP!000001MOXHbK5o&{;praac6Gq83iT)f&}e4H@(aCnwdP^5;W?YJNAx8E*ES#OjriG&h0aFfQOKszT^evz^YeB8DX8 z(`+NjmVEI4OKIv<1tdzxZ-4m7`=KgQ{a}$-Q$e?al+!35$LS^xv`tbq1S66$28|&? z8M=WN(0QBe4>ve2Tyk8v{J3y&aXZWMGLPbN6LOGciHgz+wao9;;W))GN+Jurn5Lb&gKNfFYK3g@Uo|Z2>it_~Qw2Cf=Z*764s+q3S&T2w zl@Cxo;?d37f85npTCW%62?V&&OtWkuOO%8G5BpRQSFYE8lRdV93!`tW`b#Uy*YZBV*j z*C_UGtD<~L)H;Al@26Gn-Ug>N&Tf0PUlPx5Cs`ifFYqAK!fd7X4U8rD|YM+Ll2%3Hl!Kg+cPrv9q1~5H<6xCyg>AQ zLfZkY+Cw{z+CzY%Bp#YID-XMX?4&)wL_CV}5gKARo;NiJ)>eb? zh+LJu&J_qmfN57;OF{ukeEXdD(`=SNAD7V5mi|oB--ZDG70AyuKz{Ab4c^||@R{g` z#N|c}4gvF_B%uV8g8?3;#Fu8xj&{|uhKDsgtl?n|kJB?e`qU+!w1$T@JoYs_y!M6% zg=rq-PjI8g2cm?iOh^(i4S1-7AU&AL8Vg~HJkK}5fuk+6#?(yn6G7O}R7wMDEga(cE1(4I#mx5kJyM)oyE{PxBO z4=VYSMvajg1@sA7X`F&E`R()H``Lr{uXOYqHkjo?^TtSnFj`~8lra)?;}xOu7;X_7 zEc_zOJ&IqXMa8T!VvP}Nj96pj6dfa>b&ObBSVbbK(kN+#o?1SJV~>7bI|nd6T3~-K{RBF{h=2Sexxgf*^k#c6H-e5a=OUo4@R zCX{WWX({E!Q8LWZ6oww~M6oe8=HECIV3t~x%1p;Gbr#>=oCTY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M@@QeeGQ$c~ ze450g2^KL+B{s}7gMzNqYh80?udLv!2!m>&c{dKGwk}YmFOUEXs4PZS7)8ZEz00$r z8uTJrR?S287N1^X8&(TjDOd7csadNwLMSD)ea~$ge{qH2N=3Y%)x*FVP2}iv+589N z&P9B`T&Y^)t{5_Sr%`5^#}MH7vc16@BatF@4Z&U F004S#f~Nog diff --git a/doc/manual/figures/internet-node-send.dia b/doc/manual/figures/internet-node-send.dia index 602a4bf31b71b110e796f3c156eff33174c391cd..3ab41e6547314435cb9a23783eae6a9fbef35d36 100644 GIT binary patch literal 3206 zcmV;140-b(iwFP!000001MOYkbK5o&e%D`tQD4#-l_mj#KkO!*+~qp;OzxVwB+njL zf+b!kl1D;z)Q9`qZx^I2OQLK^6x1k%XVNJt5FZxUUF^pNz@LBlI!(#FEUP5XUiUr6 z?Gu>|^HGwGU-v(M`t_%%|I3@+&!a?K!oP7TrUahID!h8#pD0yaUR*ppJUHpR5-Km9 zG?_V-y!f9;Q*i->F8XhJggmWaB$U8=&0V2XncU8lB$=4X*Zo^D{4y@{SvKm|rJ8cX zJk3jTFVffjAMW&D|DvhpVx^vE>Mq1s-j-5)*CqWScn9H)-7w)QKpi&>1|AVmI_d zZ_y|F!`+@1E@PzO2so0_>;CWVYTv9& z12uu$+vuDkf7Br6gah9R_`1NG?qXa0x3}xnm(Y5VjZ?XR2smO~#SR;U4m%7=rgC~S z%*$*u7&w|Z8bdpcO_3H3gFD=hpZrB}2ds%q#uK$2j5<7C`3nvMgDFYAB$(@X?&_b{ z0Sv8wwlPxcA*1Ua26309=?)O90q=eg)g*toX^E;|4jK0Dt4hsNxeg$+*|Zs$4X4#Q zeeDCQyVS-pIv#pzSM7>gOE%@FNdOtH?Z5#AFQ*A(apWKOQlFp$$BCGmD_o()g z^`pPZ^j@lDD4urZ{w>%r*H$x%*38K72D<9M+niqD_#qzzj@J!nbq?RrY7YT|2zi`M zW&3C@^?p}zT4(4z{Yjb>H9fYZ7GLiT19LcPVt0`GW*sb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e(hgLnWo z5%rhU<(GrjS713=@~i*2`0K*|oa9#aq=v1n0V$7oo^`s From 4884b6da1f8dbd55063d827ae2de60a60e1d2dba Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 3 Jul 2009 11:17:38 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Fix=20the=20virtual-net-device.cc=20example?= =?UTF-8?q?;=20thanks=20Antti=20M=C3=A4kel=C3=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/virtual-net-device.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/examples/virtual-net-device.cc b/examples/virtual-net-device.cc index aa65a13bf..cde18bc7e 100644 --- a/examples/virtual-net-device.cc +++ b/examples/virtual-net-device.cc @@ -78,23 +78,29 @@ class Tunnel bool - N0N1VirtualSend (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) + N0VirtualSend (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) { - m_n3Socket->SendTo (packet, 0, InetSocketAddress (m_n3Address, 667)); + m_n0Socket->SendTo (packet, 0, InetSocketAddress (m_n3Address, 667)); + return true; + } + + bool + N1VirtualSend (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) + { + m_n1Socket->SendTo (packet, 0, InetSocketAddress (m_n3Address, 667)); return true; } bool N3VirtualSend (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) { - if (m_rng.GetValue () < 0.25) { - m_n0Socket->SendTo (packet, 0, InetSocketAddress (m_n0Address, 667)); + m_n3Socket->SendTo (packet, 0, InetSocketAddress (m_n0Address, 667)); } else { - m_n1Socket->SendTo (packet, 0, InetSocketAddress (m_n1Address, 667)); + m_n3Socket->SendTo (packet, 0, InetSocketAddress (m_n1Address, 667)); } return true; } @@ -144,7 +150,7 @@ public: // n0 tap device m_n0Tap = CreateObject (); m_n0Tap->SetAddress (Mac48Address ("11:00:01:02:03:01")); - m_n0Tap->SetSendCallback (MakeCallback (&Tunnel::N0N1VirtualSend, this)); + m_n0Tap->SetSendCallback (MakeCallback (&Tunnel::N0VirtualSend, this)); n0->AddDevice (m_n0Tap); Ptr ipv4 = n0->GetObject (); uint32_t i = ipv4->AddInterface (m_n0Tap); @@ -154,7 +160,7 @@ public: // n1 tap device m_n1Tap = CreateObject (); m_n1Tap->SetAddress (Mac48Address ("11:00:01:02:03:02")); - m_n1Tap->SetSendCallback (MakeCallback (&Tunnel::N0N1VirtualSend, this)); + m_n1Tap->SetSendCallback (MakeCallback (&Tunnel::N1VirtualSend, this)); n1->AddDevice (m_n1Tap); ipv4 = n1->GetObject (); i = ipv4->AddInterface (m_n1Tap);