To develop the Voice over IP (VoIP) Project using NS3 involves the Voice over IP (VoIP) is real-time communication technology which permit the voice transmission over IP networks. In NS3, VoIP replication contains the Session Initiation Protocol (SIP) for call setup and RTP (Real-Time Transport Protocol) for audio transmission.
Steps to Develop a VoIP Project in NS3
- Setup NS3 Environment
Assure the NS3 is installed:
sudo apt update
sudo apt install git
git clone
cd ns-3-dev
./ns3 configure
./ns3 build
- Define VoIP Network Topology
A VoIP network normally consists of:
- VoIP Clients for instance SIP Phones, Softphones
- SIP Server (manage the call setting using SIP)
- RTP Media Server (Maintain the voice transmission)
- Routers & Links (Designed for network communication)
Example Topology
[VoIP Client 1] —- [Router] —- [SIP Server] —- [VoIP Client 2]
- SIP is used for signaling (Call setup, teardown)
- RTP is used for voice transmission (Real-time audio packets)
- Implement VoIP Protocols in NS3
Since NS3 cannot have built-in VoIP models, we replicate a SIP signaling over UDP/TCP and RTP for voice streaming.
(a) Define SIP Signaling
SIP uses:
- Port 5060 (intended for standard SIP signaling)
- Port 5061 (designed for secure SIP over TLS)
(b) Define RTP Streaming
RTP uses:
- Port 5004 (used for standard voice transmission)
- NS3 Code Implementation for VoIP
(a) Setting the Network Topology in VoIP
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
int main () {
NodeContainer nodes;
nodes.Create (3); // VoIP Client 1, SIP Server, VoIP Client 2
PointToPointHelper p2p;
p2p.SetDeviceAttribute (“DataRate”, StringValue (“10Mbps”));
p2p.SetChannelAttribute (“Delay”, StringValue (“2ms”));
NetDeviceContainer devices;
devices = p2p.Install(nodes.Get(0), nodes.Get(1)); // Client 1 to Server
devices = p2p.Install(nodes.Get(1), nodes.Get(2)); // Server to Client 2
InternetStackHelper internet;
internet.Install(nodes);
Ipv4AddressHelper ipv4;
ipv4.SetBase (“192.168.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = ipv4.Assign(devices);
// Define SIP Server Application
uint16_t sipPort = 5060; // SIP Server Port
Address sipServerAddress(InetSocketAddress(interfaces.GetAddress(1), sipPort));
PacketSinkHelper sipServer (“ns3::UdpSocketFactory”, sipServerAddress);
ApplicationContainer serverApp = sipServer.Install(nodes.Get(1));
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
// Define VoIP Client 1 (SIP Request)
UdpClientHelper sipClient1(sipServerAddress, sipPort);
sipClient1.SetAttribute (“MaxPackets”, UintegerValue (10));
sipClient1.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));
sipClient1.SetAttribute (“PacketSize”, UintegerValue (512));
ApplicationContainer clientApp1 = sipClient1.Install(nodes.Get(0));
clientApp1.Start(Seconds(2.0));
clientApp1.Stop(Seconds(9.0));
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Simulate RTP for Voice Transmission
SIP maintains the call setting, although RTP (Real-time Transport Protocol) is used for actual voice communication.
(a) Configure RTP Flow
- Used for RTP congestion in OnOffApplication.
- State the audio packet transmission over UDP.
(b) NS-3 Code for RTP Traffic
uint16_t rtpPort = 5004; // RTP Port
Address rtpServerAddress (InetSocketAddress(interfaces.GetAddress(2), rtpPort));
OnOffHelper rtpStream (“ns3::UdpSocketFactory”, rtpServerAddress);
rtpStream.SetConstantRate(DataRate(“64kbps”)); // Simulate voice bitrate
ApplicationContainer rtpApp = rtpStream.Install(nodes.Get(0));
rtpApp.Start(Seconds(3.0)); // RTP starts after SIP setup
rtpApp.Stop(Seconds(9.0));
- Performance Analysis
FlowMonitor used to calculate the performance of metrices such as:
- Call Setup Delay (SIP)
- Packet Loss (RTP)
- Jitter and Latency (RTP)
- End-to-End Delay
FlowMonitorHelper flowmon;
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
monitor->SerializeToXmlFile(“voip-results.xml”, true, true);
- Visualization & Analysis
- NetAnim to use for envision the VoIP call flow.
- Distribute the data to MATLAB/Python for further analysis.
- Advanced Extensions
- VoIP over LTE/Wi-Fi Replication in NS3.
- VoIP Performance over High Latency Networks.
- SIP by Secure the RTP (SRTP) Replication.
- VoIP Quality Analysis through Adaptive Jitter Buffer.
These project ideas discover numerous aspects of VoIP performance, security, and optimization via different types of networks and environments using NS3. Additional queries concerning this project will be addressed in another document.