How to check availability of RTPengine

67 Views Asked by At

I need to check the availability of the RTPengine server from an external network. The server is responsible for ICMP requests (the regular "ping X.X.X.X" command), but the actual RTP traffic is sent over UDP. To correctly check network availability, it is best to check the sending of the UDP packet.

I am successfully able to check SIP availability using a Python script through the socket library:

import socket
import time

def check_sip(host):
    message = 'INVITE sip:[email protected] SIP/2.0\r\nVia: SIP/2.0/UDP 192.168.0.255;branch=z9hG4bKPjeac64b37e16d4397b9f154d3e793ab0b\r\nMax-Forwards: 70\r\nFrom: sip:[email protected];tag=5172fcc1ebc14870ad098c23076da8d7\r\nTo: <sip:[email protected]>\r\nCall-ID: 051e7b318a494efa9e50c272fd43d13a\r\nCSeq: 1 INVITE\r\nUser-Agent: Tester\r\nContact: sip:[email protected]\r\nExpires: 180\r\nContent-Length: 0\r\n\r\n'
    ports = [5060, 60000]
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    res = [host]
    for port in ports:
        time.sleep(1)
        try:
            sock.sendto(bytes(message, "utf-8"), (host, port))
            sock.recv(1024)
            res.append((port, 'Available'))
        except socket.error:
            res.append((port, 'Unavailable'))
    return res

The SIP server responds to INVITE with a 401 response, which means access to the server’s IP is open on the network. RTPengine does not respond to such requests (INVITE and similar).

What request can be sent to RTPengine so that the server responds to it (the content of the response can be anything - the main thing is to see the response itself)? Maybe there is a special method built into RTPengine for such purposes?

0

There are 0 best solutions below