|
27 |
#include "tcp-l4-protocol.h" |
27 |
#include "tcp-l4-protocol.h" |
28 |
#include "ipv4-l3-protocol.h" |
28 |
#include "ipv4-l3-protocol.h" |
29 |
#include "arp-l3-protocol.h" |
29 |
#include "arp-l3-protocol.h" |
|
|
30 |
#include "god-arp.h" |
30 |
#include "udp-impl.h" |
31 |
#include "udp-impl.h" |
31 |
#include "tcp-impl.h" |
32 |
#include "tcp-impl.h" |
32 |
#include "ipv4-impl.h" |
33 |
#include "ipv4-impl.h" |
33 |
|
34 |
|
34 |
namespace ns3 { |
35 |
namespace ns3 { |
35 |
|
36 |
|
|
|
37 |
namespace InternetStack { |
38 |
|
39 |
static Ptr<Ipv4L4Demux> |
40 |
AddIpv4L4Demux (Ptr<Node> node) |
41 |
{ |
42 |
|
43 |
Ptr<Ipv4L4Demux> ipv4L4Demux = node->GetObject<Ipv4L4Demux> (); |
44 |
if (ipv4L4Demux != 0) |
45 |
{ |
46 |
return ipv4L4Demux; |
47 |
} |
48 |
ipv4L4Demux = CreateObject<Ipv4L4Demux> (); |
49 |
ipv4L4Demux->SetNode (node); |
50 |
node->AggregateObject (ipv4L4Demux); |
51 |
return ipv4L4Demux; |
52 |
} |
53 |
|
54 |
void |
55 |
AddTcp (Ptr<Node> node) |
56 |
{ |
57 |
Ptr<TcpL4Protocol> tcp = CreateObject<TcpL4Protocol> (); |
58 |
tcp->SetNode (node); |
59 |
Ptr<Ipv4L4Demux> ipv4L4Demux = AddIpv4L4Demux (node); |
60 |
ipv4L4Demux->Insert (tcp); |
61 |
Ptr<TcpImpl> tcpImpl = CreateObject<TcpImpl> (); |
62 |
tcpImpl->SetTcp (tcp); |
63 |
node->AggregateObject (tcpImpl); |
64 |
} |
65 |
|
66 |
void |
67 |
AddUdp (Ptr<Node> node) |
68 |
{ |
69 |
Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> (); |
70 |
udp->SetNode (node); |
71 |
Ptr<Ipv4L4Demux> ipv4L4Demux = AddIpv4L4Demux (node); |
72 |
ipv4L4Demux->Insert (udp); |
73 |
Ptr<UdpImpl> udpImpl = CreateObject<UdpImpl> (); |
74 |
udpImpl->SetUdp (udp); |
75 |
node->AggregateObject (udpImpl); |
76 |
} |
77 |
|
36 |
void |
78 |
void |
37 |
AddInternetStack (Ptr<Node> node) |
79 |
AddIpv4 (Ptr<Node> node) |
38 |
{ |
80 |
{ |
39 |
Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> (); |
81 |
Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> (); |
40 |
Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> (); |
|
|
41 |
ipv4->SetNode (node); |
82 |
ipv4->SetNode (node); |
42 |
arp->SetNode (node); |
|
|
43 |
// XXX remove the PeekPointer below. |
83 |
// XXX remove the PeekPointer below. |
44 |
node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, PeekPointer (ipv4)), |
84 |
node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, PeekPointer (ipv4)), |
45 |
Ipv4L3Protocol::PROT_NUMBER, 0); |
85 |
Ipv4L3Protocol::PROT_NUMBER, 0); |
46 |
node->RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPointer (arp)), |
|
|
47 |
ArpL3Protocol::PROT_NUMBER, 0); |
48 |
|
86 |
|
49 |
|
|
|
50 |
Ptr<Ipv4L4Demux> ipv4L4Demux = CreateObject<Ipv4L4Demux> (); |
51 |
Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> (); |
52 |
Ptr<TcpL4Protocol> tcp = CreateObject<TcpL4Protocol> (); |
53 |
|
54 |
ipv4L4Demux->SetNode (node); |
55 |
udp->SetNode (node); |
56 |
tcp->SetNode (node); |
57 |
|
58 |
ipv4L4Demux->Insert (udp); |
59 |
ipv4L4Demux->Insert (tcp); |
60 |
|
61 |
Ptr<UdpImpl> udpImpl = CreateObject<UdpImpl> (); |
62 |
Ptr<TcpImpl> tcpImpl = CreateObject<TcpImpl> (); |
63 |
Ptr<Ipv4Impl> ipv4Impl = CreateObject<Ipv4Impl> (); |
87 |
Ptr<Ipv4Impl> ipv4Impl = CreateObject<Ipv4Impl> (); |
64 |
|
|
|
65 |
udpImpl->SetUdp (udp); |
66 |
tcpImpl->SetTcp (tcp); |
67 |
ipv4Impl->SetIpv4 (ipv4); |
88 |
ipv4Impl->SetIpv4 (ipv4); |
68 |
|
89 |
|
69 |
node->AggregateObject (ipv4); |
90 |
node->AggregateObject (ipv4); |
70 |
node->AggregateObject (arp); |
|
|
71 |
node->AggregateObject (ipv4Impl); |
91 |
node->AggregateObject (ipv4Impl); |
72 |
node->AggregateObject (udpImpl); |
|
|
73 |
node->AggregateObject (tcpImpl); |
74 |
node->AggregateObject (ipv4L4Demux); |
75 |
} |
92 |
} |
76 |
|
93 |
|
|
|
94 |
void |
95 |
AddGodArp (Ptr<Node> node) |
96 |
{ |
97 |
Ptr<Arp> arp = CreateObject<GodArp> (); |
98 |
node->AggregateObject (arp); |
99 |
} |
100 |
|
101 |
void |
102 |
AddRealArp (Ptr<Node> node) |
103 |
{ |
104 |
// XXX remove the PeekPointer below. |
105 |
Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> (); |
106 |
arp->SetNode (node); |
107 |
node->RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPointer (arp)), |
108 |
ArpL3Protocol::PROT_NUMBER, 0); |
109 |
node->AggregateObject (arp); |
110 |
} |
111 |
|
112 |
void |
113 |
AddAll (Ptr<Node> node) |
114 |
{ |
115 |
AddRealArp (node); |
116 |
AddIpv4 (node); |
117 |
AddUdp (node); |
118 |
AddTcp (node); |
119 |
} |
120 |
|
121 |
|
122 |
} // namespace InternetStack |
123 |
|
77 |
}//namespace ns3 |
124 |
}//namespace ns3 |