Receive at specific wifi interface

11 views
Skip to first unread message

Durgesh Kshirsagar

unread,
Nov 30, 2021, 2:48:52 AM11/30/21
to ns-3-users

Hello everyone!
I am working on a simulation where my need is as below:

1. There are some normal nodes and special nodes (Contains one base station).
2. Normal nodes have 802.11n wifi interface with 10.0.0.0 network
3. Special nodes and Base station have 802.11n (10.0.0.0)and 802.11ac (192.168.0.0) wifi interfaces
4. Special nodes collect data from normal nodes over 802.11n and send it to the Base station through 802.11ac
5. How can I send data from Special node to the Base station on 802.11ac.
Below is my code snippet where node 0,1 are special nodes and node 2 is Base station.
Ptr<UniformRandomVariable> x = CreateObject<UniformRandomVariable>();
TypeId udp_tid = TypeId::LookupByName("ns3::UdpSocketFactory");
Ptr<DtnApp> app[nodeNum];

for (uint32_t i = 0; i < nodeNum; ++i) { app[i] = CreateObject<DtnApp>(); app[i]->Setup(nodes.Get(i)); nodes.Get(i)->AddApplication(app[i]); app[i]->SetStartTime(Seconds(0.5 + 0.00001 * i)); app[i]->SetStopTime(Seconds(duration - 10)); Ptr<Socket> dst = Socket::CreateSocket(nodes.Get(i), udp_tid); char dststring[1024] = ""; sprintf(dststring, "10.0.0.%d", (i + 1)); InetSocketAddress dstlocaladdr(Ipv4Address(dststring), 50000); dst->Bind(dstlocaladdr); dst->SetRecvCallback(MakeCallback(&DtnApp::ReceiveBundle, app[i])); if(i==0||i==1||i==2) { Ptr<Socket> dst1 = Socket::CreateSocket(nodes.Get(i), udp_tid); char dststring1[1024] = ""; sprintf(dststring1, "192.168.0.%d", (i + 1)); InetSocketAddress dstlocaladdr1(Ipv4Address(dststring1), 50000); dst1->Bind(dstlocaladdr1); dst1->SetRecvCallback(MakeCallback(&DtnApp::ReceiveBundle, app[i])); } Ptr<Socket> source = Socket::CreateSocket(nodes.Get(i), udp_tid); InetSocketAddress remote(Ipv4Address("255.255.255.255"), 80); source->SetAllowBroadcast(true); source->Connect(remote); app[i]->SendHello(source, duration, Seconds(0.1 + 0.00085 * i), 1); char srcip[1024] = ""; sprintf(srcip, "192.168.0.%d", (i + 1)); Ptr<Socket> recvSink = Socket::CreateSocket(nodes.Get(i), udp_tid); InetSocketAddress local(Ipv4Address(srcip), 80); recvSink->Bind(local); recvSink->SetRecvCallback(MakeCallback(&DtnApp::ReceiveHello, app[i])); }

Output is like:

Waf: Entering directory `/opt/ns-allinone-3.25/ns-3.25/build'
Waf: Leaving directory `/opt/ns-allinone-3.25/ns-3.25/build'
Build commands will be stored in build/compile_commands.json
'build' finished successfully (0.909s)
Creating 11 nodes.
Starting simulation for 300s, seed value 10 Protocol: GPSR
192.168.0.1 sending 842 bundle to 192.168.0.3 at time 6.7016
192.168.0.3 Receiving bundle 842 from: 10.0.0.1
10.0.0.1 Receiving bundle 1079 from: 10.0.0.3
192.168.0.1 sending 1108 bundle to 192.168.0.3 at time 8.7544
192.168.0.2 sending 1323 bundle to 192.168.0.3 at time 10.453
192.168.0.3 Receiving bundle 1108 from: 10.0.0.1
10.0.0.1 Receiving bundle 1338 from: 10.0.0.3
10.0.0.7 sending 1478 bundle to 10.0.0.1 at time 11.699
192.168.0.1 sending 2092 bundle to 192.168.0.3 at time 16.521
192.168.0.2 sending 2157 bundle to 192.168.0.3 at time 17.092
192.168.0.3 Receiving bundle 2092 from: 10.0.0.1
10.0.0.1 Receiving bundle 2348 from: 10.0.0.3
10.0.0.7 sending 3162 bundle to 10.0.0.1 at time 24.974
192.168.0.1 sending 3185 bundle to 192.168.0.3 at time 25.146
192.168.0.1 sending 3237 bundle to 192.168.0.3 at time 25.581
192.168.0.2 sending 3275 bundle to 192.168.0.3 at time 25.852
192.168.0.2 sending 3276 bundle to 192.168.0.3 at time 25.854
192.168.0.3 Receiving bundle 3185 from: 10.0.0.1
10.0.0.1 Receiving bundle 3365 from: 10.0.0.3
192.168.0.3 Receiving bundle 3237 from: 10.0.0.1
10.0.0.1 Receiving bundle 3368 from: 10.0.0.3
192.168.0.2 sending 3371 bundle to 192.168.0.3 at time 26.6
192.168.0.2 sending 4304 bundle to 192.168.0.3 at time 33.914
192.168.0.1 sending 4708 bundle to 192.168.0.3 at time 37.156
10.0.0.11 sending 4819 bundle to 10.0.0.1 at time 38.088
192.168.0.3 Receiving bundle 4708 from: 10.0.0.1
10.0.0.1 Receiving bundle 4831 from: 10.0.0.3
10.0.0.7 sending 5482 bundle to 10.0.0.1 at time 43.24
192.168.0.2 sending 5586 bundle to 192.168.0.3 at time 44.1
192.168.0.2 sending 6326 bundle to 192.168.0.3 at time 49.932
192.168.0.2 sending 6657 bundle to 192.168.0.3 at time 52.563
192.168.0.2 sending 7286 bundle to 192.168.0.3 at time 57.553
10.0.0.10 sending 7480 bundle to 10.0.0.1 at time 59.092
192.168.0.1 sending 7834 bundle to 192.168.0.3 at time 61.847
192.168.0.3 Receiving bundle 7834 from: 10.0.0.1
10.0.0.1 Receiving bundle 7927 from: 10.0.0.3
192.168.0.2 sending 8031 bundle to 192.168.0.3 at time 63.393
10.0.0.6 sending 8707 bundle to 10.0.0.1 at time 68.748
192.168.0.1 sending 9494 bundle to 192.168.0.3 at time 74.953
10.0.0.8 sending 9606 bundle to 10.0.0.1 at time 75.818
192.168.0.3 Receiving bundle 9494 from: 10.0.0.1
10.0.0.1 Receiving bundle 9696 from: 10.0.0.3
192.168.0.2 sending 10030 bundle to 192.168.0.3 at time 79.136
192.168.0.2 sending 10170 bundle to 192.168.0.3 at time 80.235
10.0.0.6 sending 10425 bundle to 10.0.0.1 at time 82.211
192.168.0.2 sending 10952 bundle to 192.168.0.3 at time 86.439
192.168.0.1 sending 11181 bundle to 192.168.0.3 at time 88.289
192.168.0.3 Receiving bundle 11181 from: 10.0.0.1
10.0.0.1 Receiving bundle 11472 from: 10.0.0.3
192.168.0.1 sending 11475 bundle to 192.168.0.3 at time 90.573
192.168.0.3 Receiving bundle 11475 from: 10.0.0.1
10.0.0.1 Receiving bundle 11724 from: 10.0.0.3
10.0.0.11 sending 11849 bundle to 10.0.0.1 at time 93.586
192.168.0.2 sending 12197 bundle to 192.168.0.3 at time 96.258
192.168.0.1 sending 13149 bundle to 192.168.0.3 at time 103.82
192.168.0.2 sending 13221 bundle to 192.168.0.3 at time 104.34
192.168.0.3 Receiving bundle 13149 from: 10.0.0.1
10.0.0.1 Receiving bundle 13245 from: 10.0.0.3
10.0.0.5 sending 13451 bundle to 10.0.0.1 at time 106.18
192.168.0.1 sending 14022 bundle to 192.168.0.3 at time 110.66
192.168.0.2 sending 14175 bundle to 192.168.0.3 at time 111.89
192.168.0.2 sending 14254 bundle to 192.168.0.3 at time 112.5
10.0.0.10 sending 14354 bundle to 10.0.0.1 at time 113.24
192.168.0.1 sending 14431 bundle to 192.168.0.3 at time 113.84
192.168.0.1 sending 14511 bundle to 192.168.0.3 at time 114.46
192.168.0.1 sending 14825 bundle to 192.168.0.3 at time 116.97
192.168.0.1 sending 15006 bundle to 192.168.0.3 at time 118.38
192.168.0.1 sending 15186 bundle to 192.168.0.3 at time 119.8
10.0.0.5 sending 15272 bundle to 10.0.0.1 at time 120.42
192.168.0.2 sending 15462 bundle to 192.168.0.3 at time 121.95
192.168.0.2 sending 15920 bundle to 192.168.0.3 at time 125.58
192.168.0.1 sending 16506 bundle to 192.168.0.3 at time 130.17
10.0.0.9 sending 17162 bundle to 10.0.0.1 at time 135.35
192.168.0.2 sending 17690 bundle to 192.168.0.3 at time 139.53
192.168.0.2 sending 17757 bundle to 192.168.0.3 at time 140.01
10.0.0.8 sending 18588 bundle to 10.0.0.1 at time 146.69
192.168.0.1 sending 19746 bundle to 192.168.0.3 at time 155.86
192.168.0.3 Receiving bundle 19746 from: 10.0.0.1
10.0.0.1 Receiving bundle 19835 from: 10.0.0.3
10.0.0.10 sending 20062 bundle to 10.0.0.1 at time 158.38
10.0.0.5 sending 21064 bundle to 10.0.0.1 at time 166.23
10.0.0.9 sending 21609 bundle to 10.0.0.1 at time 170.51
192.168.0.2 sending 21689 bundle to 192.168.0.3 at time 171.2
192.168.0.2 sending 21726 bundle to 192.168.0.3 at time 171.48
192.168.0.1 sending 22979 bundle to 192.168.0.3 at time 181.37
192.168.0.3 Receiving bundle 22979 from: 10.0.0.1
10.0.0.1 Receiving bundle 23076 from: 10.0.0.3
192.168.0.2 sending 23104 bundle to 192.168.0.3 at time 182.26
192.168.0.2 sending 23274 bundle to 192.168.0.3 at time 183.66
192.168.0.1 sending 23525 bundle to 192.168.0.3 at time 185.62
192.168.0.1 sending 23539 bundle to 192.168.0.3 at time 185.78
192.168.0.3 Receiving bundle 23525 from: 10.0.0.1
10.0.0.1 Receiving bundle 23618 from: 10.0.0.3
192.168.0.3 Receiving bundle 23539 from: 10.0.0.1
10.0.0.1 Receiving bundle 23621 from: 10.0.0.3
192.168.0.2 sending 23651 bundle to 192.168.0.3 at time 186.59
192.168.0.1 sending 23677 bundle to 192.168.0.3 at time 186.76
192.168.0.3 Receiving bundle 23677 from: 10.0.0.1
10.0.0.1 Receiving bundle 23765 from: 10.0.0.3
10.0.0.11 sending 23895 bundle to 10.0.0.1 at time 188.47
192.168.0.1 sending 24023 bundle to 192.168.0.3 at time 189.44
192.168.0.3 Receiving bundle 24023 from: 10.0.0.1
10.0.0.1 Receiving bundle 24115 from: 10.0.0.3
192.168.0.2 sending 24277 bundle to 192.168.0.3 at time 191.5
192.168.0.1 sending 24730 bundle to 192.168.0.3 at time 195.06
192.168.0.3 Receiving bundle 24730 from: 10.0.0.1
10.0.0.1 Receiving bundle 24816 from: 10.0.0.3
10.0.0.10 sending 25209 bundle to 10.0.0.1 at time 198.88
10.0.0.10 sending 25596 bundle to 10.0.0.1 at time 202
192.168.0.2 sending 26156 bundle to 192.168.0.3 at time 206.33
192.168.0.1 sending 26519 bundle to 192.168.0.3 at time 209.25
192.168.0.3 Receiving bundle 26519 from: 10.0.0.1
10.0.0.1 Receiving bundle 26608 from: 10.0.0.3
10.0.0.9 sending 26881 bundle to 10.0.0.1 at time 212.03
192.168.0.1 sending 27094 bundle to 192.168.0.3 at time 213.73
192.168.0.3 Receiving bundle 27094 from: 10.0.0.1
10.0.0.1 Receiving bundle 27182 from: 10.0.0.3
192.168.0.1 sending 27524 bundle to 192.168.0.3 at time 217.14
192.168.0.3 Receiving bundle 27524 from: 10.0.0.1
10.0.0.1 Receiving bundle 27614 from: 10.0.0.3
192.168.0.1 sending 28223 bundle to 192.168.0.3 at time 222.64
192.168.0.3 Receiving bundle 28223 from: 10.0.0.1
10.0.0.1 Receiving bundle 28313 from: 10.0.0.3
10.0.0.10 sending 28665 bundle to 10.0.0.1 at time 226.13
10.0.0.9 sending 30163 bundle to 10.0.0.1 at time 237.93
10.0.0.8 sending 30872 bundle to 10.0.0.1 at time 243.56
10.0.0.9 sending 32315 bundle to 10.0.0.1 at time 254.98
10.0.0.4 sending 33442 bundle to 10.0.0.1 at time 263.99
10.0.0.4 sending 34705 bundle to 10.0.0.1 at time 273.94
10.0.0.9 sending 36074 bundle to 10.0.0.1 at time 284.72
Finished the simulation!


I am not able find the error in above code. And it is clearly visible that 192.168.0.0 is receiving fron 10.0.0.0 where 192.168.0.0 should receive from 192.168.0.0 network.
Reply all
Reply to author
Forward
0 new messages