Simulate Mobility of UE Node in 5G Network
Incorporate mobility for an instance of a user equipment (UE) in a simple 5G wireless network. Create a base station (gNB) and a UE, and specify a mobility model for the UE directly in the code. Select either random walk, random waypoint, or constant velocity as the mobility model. Then, run the simulation, and obtain the statistics for the gNB and UE nodes.
Initialize the wireless network simulator.
networkSimulator = wirelessNetworkSimulator.init;
Create a gNB node with default settings
gnb = nrGNB(Name="gnb1");Create a UE node.
ue = nrUE(Name="ue1");Initialize the wireless network viewer.
visualizer = wirelessNetworkViewer;
Add the gNB and UE nodes to the wireless network viewer.
addNodes(visualizer,{gnb ue})Select the mobility model for the UE node. Create the selected mobility model and assign it to the UE node.
mobilityModel ="Random Walk"; switch mobilityModel case "Random Walk" mobilityModel = nodeMobilityRandomWalk( ... BoundaryShape= "circle", ... Bounds=[0 0 20], ... % Center at (0,0), radius 20 SpeedRange=[1 2], ... % Speed range between 1 and 2 (Units are in meters per second) WalkMode="distance", ... % Change direction after a fixed distance Distance= 0.6, ... % Change direction every 0.6 meters RefreshInterval= 0.1); % Refresh every 0.1 seconds case "Random Waypoint" mobilityModel = nodeMobilityRandomWaypoint( ... BoundaryShape= "circle", ... Bounds=[0 0 20], ... % Center at (0,0), radius 20 SpeedRange=[1 2], ... % Speed range between 1 and 2 RefreshInterval= 0.1); % Refresh every 0.1 seconds; case "Constant Velocity" mobilityModel = nodeMobilityConstantVelocity( ... Velocity=[2 1 0], ... % velocity vector in m/s along x, y, z axes RefreshInterval= 0.1); % Refresh every 0.1 seconds; end addMobility(ue,MobilityModel=mobilityModel)
Establish a connection between the UE and gNB nodes.
connectUE(gnb,ue)
Create a voice over Internet protocol (VoIP) application traffic pattern object
traffic = networkTrafficVoIP;
Add the data traffic source to the gNB node. Set the UE node as the destination node.
addTrafficSource(gnb,traffic,DestinationNode=ue)
Add the gNB and UE nodes to the wireless network simulator.
addNodes(networkSimulator,gnb) addNodes(networkSimulator,ue)
Set the simulation time.
simulationTime = 1;
Run the simulation.
run(networkSimulator,simulationTime)

Obtain the statistics for the gNB and UE nodes.
gnbStats = statistics(gnb); gnbAPPStats=gnbStats.App
gnbAPPStats = struct with fields:
TransmittedPackets: 50
TransmittedBytes: 1800
ReceivedPackets: 0
ReceivedBytes: 0
ueStats = statistics(ue); ueAPPStats=ueStats.App
ueAPPStats = struct with fields:
TransmittedPackets: 0
TransmittedBytes: 0
ReceivedPackets: 50
ReceivedBytes: 1800
See Also
Objects
nrUE|nodeMobilityRandomWalk(Wireless Network Toolbox) |nodeMobilityRandomWaypoint(Wireless Network Toolbox) |nodeMobilityConstantVelocity(Wireless Network Toolbox)
Classes
wnet.Mobility(Wireless Network Toolbox)
