Gabrielcarvfer / ns3_for_education

Repository of educational examples using ns-3
5 stars 4 forks source link

UE cannot receive the data with UDP application in a basic LTE model from python bindings #2

Closed liyang19960201 closed 6 months ago

liyang19960201 commented 6 months ago

Dear Gabrielcarvfer

I appreciate your instruction and it helps me out with the mobility challenge for my racing car simulation.

Now, I am working on LTE model, because my starting point was wifi and now everything works out except for animation part, but I get approval from my supervisor for that and I should focus on LTE case now.

However, I get stuck already from the fundamental case since you show me to build a basic connection between 2 node, I started trying to set UDP connection for two node and they are connected to Base Station Node. But now the thing is that only UDPClient sends out package, but nothing happens from server side.

I assume I do not have proper configuration on channels, but it seems like user manual has them in C++,could you please share some instruction about LTE physical, MAC with python bindings since you are an expert in this field.

I will attach my code downbelow:

from ns import ns

import sys

bsnodes=ns.network.NodeContainer() uenodes=ns.network.NodeContainer()

bsnodes.Create(1) uenodes.Create(2)

Mobility Module

mobilityHelper = ns.MobilityHelper()

mobilityHelper.SetMobilityModel ("ns3::WaypointMobilityModel")

mobilityHelper.SetPositionAllocator( "ns3::GridPositionAllocator", "MinX", ns.core.DoubleValue(0.0), "MinY", ns.core.DoubleValue(0.0), "DeltaX", ns.core.DoubleValue(10.0), "DeltaY", ns.core.DoubleValue(20.0), "GridWidth", ns.core.UintegerValue(3), "LayoutType", ns.core.StringValue("RowFirst"), )

Configure a grid-based position allocator for nodes,the

parameters are minimum of X and Y coordinates, grid spacing

and layout type, it can be tunned later accordingly

mobilityHelper.SetPositionAllocator (randomBoxPositions)

mobilityHelper.SetMobilityModel("ns3::ConstantPositionMobilityModel") mobilityHelper.Install(uenodes)

Configue a constant position model for access point nodes

mobilityHelper.Install(bsnodes)

Connect constatnt model to ap wifi nodes

lteHelper = ns.CreateObject("LteHelper") bsDevs = lteHelper.InstallEnbDevice(bsnodes) ueDevs = lteHelper.InstallUeDevice(uenodes) lteHelper.Attach(ueDevs, bsDevs.Get(0))

EPS bearer, carrying guarantee bit rate

qci = ns.lte.EpsBearer.GBR_CONV_VOICE bearer=ns.lte.EpsBearer(qci) lteHelper.ActivateDataRadioBearer(ueDevs, bearer)

stack = ns.internet.InternetStackHelper()

Create an internetstack helper object to configure and install

internet protocol stacks on nodes

stack.Install(csmaNodes)

stack.Install(bsnodes) stack.Install(uenodes)

ns.internet.Ipv4GlobalRoutingHelper.PopulateRoutingTables()

tcp

Addressing

address = ns.internet.Ipv4AddressHelper()

address.SetBase(ns.network.Ipv4Address("10.1.3.0"), ns.network.Ipv4Mask("255.255.255.0"))

Ser the base IPv4 address and subnet mask(for wifi)

ueinterface=address.Assign(ueDevs)

connect address to station wifi interfaces(decvies)

bsinterface=address.Assign(bsDevs)

TCP section-1

TCP Traffic Generator

port = 5002 # Use any unused port number maxBytes = 1024102410 # Set to 0 for unlimited data transfer

Source node (node 0) will send TCP traffic to the destination node (node 1)

source = ns.applications.BulkSendHelper('ns3::TcpSocketFactory', ns.network.InetSocketAddress(ueinterface.GetAddress(1), port).ConvertTo())

Source node (node 0) will send TCP traffic to the destination node (node 1)

source.SetAttribute("MaxBytes", ns.core.UintegerValue(maxBytes))

sourceApps = source.Install(uenodes.Get(0)) sourceApps.Start(ns.core.Seconds(2.0)) # Start sending TCP traffic after 1 second sourceApps.Stop(ns.core.Seconds(10.0)) # Stop after 10 seconds

Create a TCP receiver on the destination node

sink = ns.applications.PacketSinkHelper('ns3::TcpSocketFactory', ns.network.InetSocketAddress(ueinterface.GetAddress(1), port).ConvertTo()) sinkApps = sink.Install(uenodes.Get(1)) sinkApps.Start(ns.core.Seconds(1.0)) # Start receiving TCP traffic immediately sinkApps.Stop(ns.core.Seconds(10.0)) # Stop after 10 seconds

Set LTE bandwidth to public (default is private)

lteHelper.SetAttribute("UsePublicBandwidth", ns.core.BooleanValue(True))

ns.core.Simulator.Stop(ns.core.Seconds(10.0)) ns.core.Simulator.Run()

ns.core.Simulator.Destroy()

liyang19960201 commented 6 months ago

Hello, dear Gabrielcarvfer

I terribly apologize for leaving excessive questions in your repository for same questions across all the platforms, I didn't know I must follow the appropriate regulations to get through this question.

I will not complain about the no-response for a while, but I also made some process for LTE model in python bindings, and it would be grateful if I can contact you after a while since I plan to share my project to NS-3 group and I think you are the one who can turn them in to next release.

I will only post question in NS-3 group from now on. Once again, I apologize for inconvenience and rudeness, have a lovely day.

Br Yang Li