A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tgax-voip-example.cc File Reference

A simple VoIP traffic generator example over Wi-Fi. More...

#include "ns3/applications-module.h"
#include "ns3/core-module.h"
#include "ns3/internet-module.h"
#include "ns3/mobility-module.h"
#include "ns3/network-module.h"
#include "ns3/wifi-module.h"
Include dependency graph for tgax-voip-example.cc:

Go to the source code of this file.

Functions

void PacketReceived (std::string context, Ptr< const Packet > packet, const Address &address)
 Callback invoked when the PacketSink receives a packet.
void VoipPacketSent (Ptr< const Packet > packet, Time jitter)
 Callback invoked when a VoIP packet is transmitted.
void VoipStateChanged (TgaxVoipTraffic::VoiceActivityState state, Time duration)
 Callback invoked when the VoIP application state changes (active/silence).

Detailed Description

A simple VoIP traffic generator example over Wi-Fi.

This example demonstrates how to set up a basic ns-3 simulation with VoIP traffic over a Wi-Fi network. It includes three configurations:

  1. IPv4/UDP: VoIP traffic over IPv4 using UDP sockets
  2. IPv6/UDP: VoIP traffic over IPv6 using UDP sockets
  3. PacketSocket: VoIP traffic using raw packet sockets

The simulation consists of:

  • A simple Wi-Fi network with one AP (Access Point) and one STA (Station)
  • VoIP traffic flowing from the STA to the AP
  • Application-level tracing to observe VoIP packets being sent
  • State change tracing to see voice activity transitions

To run with IPv4/UDP (default): ./ns3 run tgax-voip-example To run with IPv6/UDP: ./ns3 run "tgax-voip-example --socketType=ipv6" To run with PacketSocket: ./ns3 run "tgax-voip-example --socketType=packet"

To disable verbose logging: ./ns3 run "tgax-voip-example --verbose=false"

Definition in file tgax-voip-example.cc.

Function Documentation

◆ PacketReceived()

void PacketReceived ( std::string context,
Ptr< const Packet > packet,
const Address & address )

Callback invoked when the PacketSink receives a packet.

Parameters
contextThe context string
packetThe received packet
addressThe sender's address

Definition at line 344 of file tgax-voip-example.cc.

References NS_LOG_INFO.

◆ VoipPacketSent()

void VoipPacketSent ( Ptr< const Packet > packet,
Time jitter )

Callback invoked when a VoIP packet is transmitted.

Parameters
packetThe transmitted packet
jitterThe jitter applied to the packet

Definition at line 328 of file tgax-voip-example.cc.

References ns3::Time::As(), NS_LOG_INFO, and ns3::Time::US.

Here is the call graph for this function:

◆ VoipStateChanged()

void VoipStateChanged ( TgaxVoipTraffic::VoiceActivityState state,
Time duration )

Callback invoked when the VoIP application state changes (active/silence).

Parameters
stateThe new voice activity state
durationThe expected duration in this state

Definition at line 335 of file tgax-voip-example.cc.

References ns3::TgaxVoipTraffic::ACTIVE_TALKING, ns3::Time::As(), ns3::Time::MS, and NS_LOG_INFO.

Here is the call graph for this function: