freeDiameter使用教程

安装

  1. 从github克隆freeDiameter源码

    git clone https://github.com/freeDiameter/freeDiameter.git
    
  2. 安装所需环境

    阅读INSTALL.Ubuntu文件,根据提示安装所需环境

    sudo apt-get -y install mercurial cmake make gcc bison flex libsctp-dev libgnutls-dev libgcrypt-dev libpq-dev libmysqlclient-dev ssl-cert debhelper fakeroot
    

    不同的系统可能需要找到组件对应的版本才能正确安装

  3. 编译和安装

    阅读INSTALL.Ubuntu文件,根据提示进行编译和安装

    Create a build directory, and enter it
    # mkdir fDbuild
    # cd fDbuild
    
    Configure and generate the Makefiles
    # cmake ../freeDiameter
    # make edit_cache
    
    Compile all files:
    # make
    
    (OPTION) See available targets:
    # make help
    
    (OPTION) Check the software has a correct basic behavior on your environment. -- only if you did not disable the tests in step 6
    # make test
    
    (OPTION) Install the software in configured locations:
    # sudo make install
    
  4. 运行

    正确安装之后,使用freeDiameterd命令就能运行程序,详细的参数如下

    Usage:  freeDiameterd [OPTIONS]...
      -h, --help              Print help and exit
      -V, --version           Print version and exit
      -c, --config=filename   Read configuration from this file instead of the 
                              default location (/usr/local/etc/freeDiameter/freeDiameter.conf)
      -D, --daemon            Start program in background
      -p, --pidfile=filename  Write PID to filename
      -s, --syslog            Write log output to syslog (instead of stdout)
      -t, --datelogger        Write log output to stdout prefixed with date
    
    Debug:
      These options are mostly useful for developers
      -d, --debug             Increase verbosity of log messages if default logger is used
      -f, --dbg_func <func>   Enable all traces within the function <func>
      -F, --dbg_file <file.c> Enable all traces within the file <file.c> (basename match)
      -g, --dbg_gnutls <int>  Enable GNU TLS debug at level <int>
      -l, --dbglocale         Set the locale for error messages
      -q, --quiet             Decrease verbosity of log messages if default logger is used
    

运行测试用例test_app

配置文件

test_appserverclient两种模式,因此需要运行两个freeDiameterd进程,配置两个freeDiameter.conf文件,以及两个扩展文件test_ser.conftest_cli.conf,此外还需要test_app.fdx文件和一些密钥文件。

test_app.fdx

test_app.fdx的生成需要在extensionsCMakeLists.txt中将OFF置为ON,然后再进行编译,安装

FD_EXTENSION_SUBDIR(test_app        "Testing application to send dummy message to another peer, like a Diameter 'ping'" OFF)
密钥文件

运行doc/sigle_host中的make_certs.sh生成

freeDiameter-1.conf
Identity = "peer1.localdomain";
Realm = "localdomain";
Port = 3868;
SecPort = 3869;

TLS_Cred = "peer1.cert.pem",
           "peer1.key.pem";
TLS_CA = "cacert.pem";

LoadExtension = "/usr/local/lib/freeDiameter/test_app.fdx" : "test_ser.conf";

ConnectPeer = "peer2.localdomain" { ConnectTo = "127.0.0.1"; No_TLS; port = 30868; };

  1. Identity = "peer1.localdomain"; - 设置了服务的标识(Identity),通常是服务的主机名或域名。
  2. Realm = "localdomain"; - 定义了服务的域名(Realm)。
  3. Port = 3868; - 这行设置了服务监听的端口号,用于非加密的通信。
  4. SecPort = 3869; - 这行设置了服务的加密端口号,用于TLS加密通信。
  5. TLS_Cred = "peer1.cert.pem", "peer1.key.pem"; - 这行定义了服务使用的TLS证书和私钥文件的路径。peer1.cert.pem 是证书文件,peer1.key.pem 是私钥文件。
  6. TLS_CA = "cacert.pem"; - 这行指定了信任的证书颁发机构(CA)的证书文件,用于TLS通信中的证书验证。
  7. LoadExtension = "/usr/local/lib/freeDiameter/test_app.fdx" : "test_ser.conf"; - 这行指定了一个扩展模块的路径和配置文件,test_app.fdx 是扩展模块文件,test_ser.conf 是该模块的配置文件。
  8. ConnectPeer = "peer2.localdomain" { ConnectTo = "127.0.0.1"; No_TLS; port = 30868; }; - 定义了一个要连接的对等体(ConnectPeer),并提供了以下参数:
    • ConnectTo = "127.0.0.1"; - 指定了对等体的IP地址,这里是本地回环地址。
    • No_TLS; - 表示与这个对等体的连接不使用TLS加密。
    • port = 30868; - 指定了连接到该对等体使用的端口号。
freeDiameter-2.conf
Identity = "peer2.localdomain";
Realm = "localdomain";
Port = 30868;
SecPort = 30869;

TLS_Cred = "peer2.cert.pem",
           "peer2.key.pem";
TLS_CA = "cacert.pem";

LoadExtension = "/usr/local/lib/freeDiameter/test_app.fdx" : "test_cli.conf";

ConnectPeer = "peer1.localdomain" { ConnectTo = "127.0.0.1"; No_TLS; };

test_ser.conf
# This application is defined as a Vendor-Specific application. 
# Since freeDiameter does not have a IANA-assigned Vendor ID, we let a configurable value here:
 vendor-id = 999999;

# The application id. Same remark as previously.
 appli-id = 999999;

# The command code for Test-Request and Test-Answer. The range 0xfffffe-ffffff (dec: 16777215) is reserved for experimental use.
 cmd-id = 16777214;

# The AVP id for the test.
 avp-id = 345678;

# Another AVP id for long payload test. default to value 0, meaning this is not used.
 long-avp-id = 1;

# Define the payload length of the long-avp. Default 5000 bytes.
 long-avp-len = 5000;


#######################
# Configuration of the extension behavior

# The mode for the extension.
# - server: Answer incoming requests. The signal is ignored.
# - client: Send a request when the signal is received, and measure the time to receiving answer.
# - both: acts as client and server
 mode = server;

test_cli.conf
# Configuration of the test message

# This application is defined as a Vendor-Specific application. 
# Since freeDiameter does not have a IANA-assigned Vendor ID, we let a configurable value here:
 vendor-id = 999999;

# The application id. Same remark as previously.
 appli-id = 999999;

# The command code for Test-Request and Test-Answer. The range 0xfffffe-ffffff (dec: 16777215) is reserved for experimental use.
 cmd-id = 16777214;

# The AVP id for the test.
 avp-id = 345678;

# Another AVP id for long payload test. default to value 0, meaning this is not used.
 long-avp-id = 1;

# Define the payload length of the long-avp. Default 5000 bytes.
 long-avp-len = 5000;


#######################
# Configuration of the extension behavior

# The mode for the extension.
# - server: Answer incoming requests. The signal is ignored.
# - client: Send a request when the signal is received, and measure the time to receiving answer.
# - both: acts as client and server
 mode = client;

# The behavior can be changed by specifying additional "benchmark;" keyword.
# When this keyword appears, it changes the behavior as follow:
#  - server is silent on message reception, only the activity summary is displayed every 30 seconds
#  - client attempts to send as many messages as possible during 10 seconds and counts them.
# The benchmark keyword can be followed optionally by two integers:
#   duration is the time for the measurement, in seconds (default 10).
#   concurrency is the number of messages that can be on the wire before waiting for an answer (default 100).
# benchmark;
#######################
# Client-specific configuration

# The Destination-Realm for the message
# (default is sending to same realm as local peer).
 dest-realm = "localdomain";

# The Destination-Host for the message.
# (default is not providing this AVP).
 dest-host = "peer1.localdomain";

# The User-Name for the message (may be useful for some routing tests).
# (default is not providing this AVP).
# user-name = "usrsname@localdomain";

# The signal that triggers sending the test message
# Note: Symbolic names are not recognized, you must use integers
 signal = 10;

测试消息配置

  • vendor-id = 999999; - 定义了该应用程序的供应商ID。
  • appli-id = 999999; - 定义了应用程序ID。
  • cmd-id = 16777214; - 设置了 Test-Request 和 Test-Answer 命令的代码。
  • avp-id = 345678; - 定义了测试使用的 AVP ID。
  • long-avp-id = 1; - 定义了用于长负载测试的另一个 AVP 的ID,默认值为0,表示不使用。
  • long-avp-len = 5000; - 定义了长 AVP 的负载长度,默认为5000字节。

扩展行为配置

  • mode = client; - 定义了扩展的工作模式。这里是客户端模式,当接收到信号时发送请求并测量接收响应的时间。

  • benchmark;

    如果出现此关键字,将改变行为:

    • 服务器模式下,在消息接收时保持静默,每30秒显示一次活动摘要。
    • 客户端模式下,在10秒内尽可能多地发送消息并计数。
  • durationconcurrency 是可选参数,分别表示测量时间(默认10秒)和在等待响应之前可以在网络上的并发消息数量(默认100)。

客户端特定配置

  • dest-realm = "localdomain"; - 定义了消息的目标领域,默认是发送到与本地对等体相同的领域。
  • dest-host = "peer1.localdomain"; - 定义了消息的目标主机。如果不提供此 AVP,则默认不提供。
  • user-name = "usrsname@localdomain"; - 定义了消息的用户名称,可能对某些路由测试有用。这里被注释掉了,表示默认不提供。
  • signal = 10; - 定义了触发发送测试消息的信号。

运行

freeDiameterd -c ./freeDiameter-1.conf
freeDiameterd -c ./freeDimaeter-2.conf
服务端

在这里插入图片描述

客户端

在这里插入图片描述

在这里插入图片描述

向客户端发送信号10

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

bench测试

在这里插入图片描述
在这里插入图片描述

搭建Open5GS是一个相对较复杂的过程,需要一些基础知识和技能。以下是一个基本的步骤来搭建Open5GS笔记: 1. 首先,确保你的操作系统是支持Open5GS的,推荐使用Linux系统。你可以选择Ubuntu、CentOS等常见的Linux发行版。 2. 安装所需软件:Open5GS需要依赖一些软件,包括MongoDB、FreeDiameter、libssl-dev等。你可以使用包管理工具(如apt、yum等)来安装这些软件。 3. 下载Open5GS:你可以在Open5GS的官方网站上找到最新的版本,并进行下载。 4. 解压缩Open5GS:解压缩下载好的Open5GS压缩包。 5. 编译和安装Open5GS:进入解压缩后的Open5GS目录,使用终端运行make命令来编译Open5GS。编译成功后,运行sudo make install命令来安装Open5GS。 6. 配置Open5GS:在安装完成后,你需要进行一些配置。可以编辑Open5GS的配置文件(位于/etc/open5gs目录下),配置一些网络参数、IP地址等。 7. 启动Open5GS:在完成配置后,你可以使用终端运行sudo open5gs命令来启动Open5GS。如果一切正常,你将会看到Open5GS成功启动的提示信息。 8. 连接到Open5GS:通过连接你的设备(如手机)到Open5GS的网络,你可以使用Open5GS提供的移动网络服务。可以按照手机设置中的网络设置,进行连接。 以上是搭建Open5GS的基本步骤。需要注意的是,由于Open5GS的复杂性,搭建过程中可能会遇到一些问题。你可以通过查阅Open5GS的官方文档、寻求在线支持或参考相应的论坛来解决问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值