1 // +-----+ +-----+ +-----+ |
|
2 // | UE0 | | UE1 | | UE2 | |
|
3 // +-----+ +-----+ +-----+ |
|
4 // 10.1.1.1 10.1.1.2 10.1.1.3 |
|
5 // -------- -------- ------- |
|
6 // ((*)) ((*)) ((*)) |
|
7 // |
|
8 // 10.1.1.4 |
|
9 // +------------+ |
|
10 // |eNB | ==((*)) |
|
11 // +------------+ |
|
12 |
|
13 #include "ns3/core-module.h" |
|
14 #include "ns3/network-module.h" |
|
15 #include "ns3/applications-module.h" |
|
16 #include "ns3/mobility-module.h" |
|
17 #include "ns3/config-store-module.h" |
|
18 #include "ns3/internet-module.h" |
|
19 #include "ns3/lte-module.h" |
|
20 #include <iostream> |
|
21 #include "ns3/global-route-manager.h" |
|
22 |
|
23 NS_LOG_COMPONENT_DEFINE ("lte-device"); |
|
24 |
|
25 using namespace ns3; |
|
26 |
|
27 |
|
28 int main (int argc, char *argv[]) |
|
29 { |
|
30 // default values |
|
31 int nbUE = 3; |
|
32 |
|
33 LteHelper lte; |
|
34 |
|
35 //lte.EnableLogComponents (); |
|
36 LogComponentEnable ("UdpClient", LOG_LEVEL_INFO); |
|
37 LogComponentEnable ("UdpServer", LOG_LEVEL_INFO); |
|
38 |
|
39 |
|
40 // CREATE NODE CONTAINER AND CREATE LTE NODES |
|
41 NodeContainer ueNodes; |
|
42 NodeContainer enbNodes; |
|
43 ueNodes.Create (nbUE); |
|
44 enbNodes.Create (1); |
|
45 |
|
46 |
|
47 // CREATE DEVICE CONTAINER, INSTALL DEVICE TO NODE |
|
48 NetDeviceContainer ueDevs, enbDevs; |
|
49 ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT); |
|
50 enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB); |
|
51 |
|
52 |
|
53 |
|
54 // INSTALL INTERNET STACKS |
|
55 InternetStackHelper stack; |
|
56 stack.Install (ueNodes); |
|
57 stack.Install (enbNodes); |
|
58 Ipv4AddressHelper address; |
|
59 address.SetBase ("10.1.1.0", "255.255.255.0"); |
|
60 Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs); |
|
61 Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs); |
|
62 |
|
63 |
|
64 |
|
65 // MANAGE LTE NET DEVICES |
|
66 Ptr<EnbNetDevice> enb; |
|
67 enb = enbDevs.Get (0)->GetObject<EnbNetDevice> (); |
|
68 |
|
69 std::vector<Ptr<UeNetDevice> > ue (nbUE); |
|
70 for (int i = 0; i < nbUE; i++) |
|
71 { |
|
72 ue.at (i) = ueDevs.Get (i)->GetObject<UeNetDevice> (); |
|
73 lte.RegisterUeToTheEnb (ue.at (i), enb); |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 // CONFIGURE DL and UL SUB CHANNELS |
|
79 // Define a list of sub channels for the downlink |
|
80 std::vector<int> dlSubChannels; |
|
81 for (int i = 0; i < 25; i++) |
|
82 { |
|
83 dlSubChannels.push_back (i); |
|
84 } |
|
85 // Define a list of sub channels for the uplink |
|
86 std::vector<int> ulSubChannels; |
|
87 for (int i = 50; i < 100; i++) |
|
88 { |
|
89 ulSubChannels.push_back (i); |
|
90 } |
|
91 |
|
92 enb->GetPhy ()->SetDownlinkSubChannels (dlSubChannels); |
|
93 enb->GetPhy ()->SetUplinkSubChannels (ulSubChannels); |
|
94 |
|
95 for (int i = 0; i < nbUE; i++) |
|
96 { |
|
97 ue.at (i)->GetPhy ()->SetDownlinkSubChannels (dlSubChannels); |
|
98 ue.at (i)->GetPhy ()->SetUplinkSubChannels (ulSubChannels); |
|
99 } |
|
100 |
|
101 |
|
102 // CONFIGURE MOBILITY |
|
103 Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> (); |
|
104 enbMobility->SetPosition (Vector (0.0, 0.0, 0.0)); |
|
105 lte.AddMobility (enb->GetPhy (), enbMobility); |
|
106 |
|
107 for (int i = 0; i < nbUE; i++) |
|
108 { |
|
109 Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> (); |
|
110 ueMobility->SetPosition (Vector (30.0, 0.0, 0.0)); |
|
111 ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0)); |
|
112 |
|
113 lte.AddMobility (ue.at (i)->GetPhy (), ueMobility); |
|
114 |
|
115 lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue.at (i)->GetPhy ()); |
|
116 } |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 // CONGIFURE CLIENT SERVER APPLICATION |
|
126 UdpServerHelper udpServer; |
|
127 ApplicationContainer serverApp; |
|
128 UdpClientHelper udpClient; |
|
129 ApplicationContainer clientApp; |
|
130 |
|
131 udpServer = UdpServerHelper (100); |
|
132 serverApp = udpServer.Install (ueNodes.Get (0)); |
|
133 serverApp.Start (Seconds (0.02)); |
|
134 serverApp.Stop (Seconds (2)); |
|
135 |
|
136 udpClient = UdpClientHelper (UEinterfaces.GetAddress (0), 100); |
|
137 udpClient.SetAttribute ("MaxPackets", UintegerValue (1200)); |
|
138 udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12))); |
|
139 udpClient.SetAttribute ("PacketSize", UintegerValue (800)); |
|
140 clientApp = udpClient.Install (enbNodes.Get (0)); |
|
141 clientApp.Start (Seconds (0.01)); |
|
142 clientApp.Stop (Seconds (2)); |
|
143 |
|
144 |
|
145 //CREATE RADIO BEARER |
|
146 Ptr<RadioBearerInstance> bearer = CreateObject<RadioBearerInstance> (); |
|
147 bearer->SetBearerDirection (RadioBearerInstance::DIRECTION_TYPE_DL); |
|
148 bearer->SetBearerType (RadioBearerInstance::BEARER_TYPE_DRB); |
|
149 |
|
150 IpcsClassifierRecord *ipcs = new IpcsClassifierRecord (UEinterfaces.GetAddress (0), |
|
151 "255.255.255.0", |
|
152 ENBinterface.GetAddress (0), |
|
153 "255.255.255.0", |
|
154 100, 100, 0, 10000, 17, 1); |
|
155 bearer->SetIpcsClassifierRecord (ipcs); |
|
156 |
|
157 enb->GetRrcEntity ()->AddDownlinkNgbrBearer (bearer); |
|
158 |
|
159 bearer = 0; |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 std::cout << "Starting simulation....." << std::endl; |
|
170 Simulator::Stop (Seconds (2.0)); |
|
171 |
|
172 |
|
173 Simulator::Run (); |
|
174 |
|
175 Simulator::Destroy (); |
|
176 |
|
177 delete ipcs; |
|
178 |
|
179 std::cout << "Done." << std::endl; |
|
180 |
|
181 return 0; |
|
182 } |
|