Question:
I'm trying to simulate a 5G network using Mininet, but I'm facing issues with IP addressing and port numbers. I've created a network with 5 nodes (UE, GNB, AMF, SMF, and UPF) and added links between them. I'm trying to simulate the 5G call process flow, including the RACH procedure, by sending messages between nodes using nc commands.
I've tried using private IP addresses (
10.0.0.0/8) and port numbers (2123) for all nodes, but I'm not able to visualize the packet transmission in Wireshark. I've also tried using the IP address of my device (172.17.152.210) and a different port number for each node, but it didn't work.
Here are my questions:
How do I assign IP addresses and port numbers correctly in Mininet to ensure that packets are transmitted between nodes?
Do I need to use a specific range of IP addresses or can I use any private IP address range?
How do I configure Wireshark to capture traffic on a specific interface (e.g., ens33) and filter packets based on port numbers?
I've attached my code snippet for reference. Any help or guidance on resolving these issues would be appreciated.
Code snippet:
from
mininet.net import Mininet
from mininet.node import OVSSwitch, Host
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.util import dumpNodeConnections
from subprocess import Popen, PIPE
# Create a Mininet instance
net = Mininet(topo=None, build=False)
# Add nodes to the network
ue = net.addHost('ue', ip='172.17.152.210', mac='00:00:00:00:00:01', port=2123)
gnb = net.addSwitch('gnb', cls=OVSSwitch, ip='172.17.152.210', mac='00:00:00:00:00:02', dpid='0000000000000001')
amf = net.addHost('amf', ip='172.17.152.210', mac='00:00:00:00:00:03', port=2123)
smf = net.addHost('smf', ip='172.17.152.210', mac='00:00:00:00:00:04', port=2123)
upf = net.addHost('upf', ip='172.17.152.210', mac='00:00:00:00:00:05', port=2123)
# Add links between nodes
net.addLink(ue, gnb, cls=TCLink, bw=10, delay='10ms')
net.addLink(gnb, amf, cls=TCLink, bw=10, delay='10ms')
net.addLink(amf, smf, cls=TCLink, bw=10, delay='10ms')
net.addLink(smf, upf, cls=TCLink, bw=10, delay='10ms')
# Start the network
net.start()
# Start Wireshark capture on the UE-GNB link
wireshark_cmd = 'sudo wireshark -i any -k -f "port 2123" -w /tmp/ue-gnb_capture.pcap'
wireshark_process = Popen(wireshark_cmd, shell=True, stdout=PIPE, stderr=PIPE)
# Simulate the 5G call process flow with RACH procedure
print('Simulating 5G call process flow including RACH procedure...')
# Step 0: RACH Procedure Simulation
# UE sends PRACH (Physical Random Access Channel) preamble to the GNB
ue.cmd('echo "RACH: PRACH Preamble" | nc 172.17.152.210 2123')
#
# GNB sends RAR (Random Access Response) to the UE
gnb.cmd('echo "RACH: RAR (Random Access Response)" | nc 172.17.152.210 2123')
# Step 1: UE sends a NAS (Non-Access Stratum) message to the GNB
ue.cmd('echo "NAS: Registration Request" | nc 172.17.152.210 2123')
# Step 2: GNB sends a NAS message to the AMF
gnb.cmd('echo "NAS: Registration Request" | nc
172.17.152.210/20 2123')
# Step 3: AMF sends a Nsmf_PDUSession_CreateRequest to the SMF
amf.cmd('echo "Nsmf_PDUSession_CreateRequest" | nc 172.17.152.210 2123')
# Step 4: SMF sends a Nsmf_PDUSession_CreateResponse to the AMF
smf.cmd('echo "Nsmf_PDUSession_CreateResponse" | nc 172.17.152.210 2123')
# Step 5: AMF sends a NAS message to the UE
amf.cmd('echo "NAS: Registration Accept" | nc 172.17.152.210 2123')
# Step 6: UE sends a PFCP (Packet Forwarding Control Protocol) message to the UPF
ue.cmd('echo "PFCP: Session Establishment Request" | nc 172.17.152.210 2123')
# Step 7: UPF sends a PFCP message to the UE
upf.cmd('echo "PFCP: Session Establishment Response" | nc 172.17.152.210 2123')
print('5G call process flow simulation including RACH procedure complete.')
# Stop the Wireshark capture
wireshark_process.terminate()
# Stop the network
net.stop()
print('Network stopped.')
please help me out with this issues by suggesting some solutions as soon as possible.