---
# System prepended metadata

title: Rincian Konfigurasi Sistem VoIP Menggunakan Asterisk dan PJSIP

---

# Rincian Konfigurasi Sistem VoIP Menggunakan Asterisk dan PJSIP Kelompok 4 

## Daftar Isi
1. [Persiapan Awal](#persiapan-awal)
2. [Instalasi Asterisk dengan PJSIP](#instalasi-asterisk-dengan-pjsip)
3. [Konfigurasi Dasar](#konfigurasi-dasar)
4. [Konfigurasi PJSIP](#konfigurasi-pjsip)
5. [Konfigurasi Extensions](#konfigurasi-extensions)
6. [Konfigurasi Voicemail](#konfigurasi-voicemail)
7. [Konfigurasi Music on Hold](#konfigurasi-music-on-hold)
8. [Konfigurasi TLS](#konfigurasi-tls)
9. [Troubleshooting](#troubleshooting)
10. [Konfigurasi Client](#konfigurasi-client)
11. [Analisis SIP dengan SNGREP](#analisis-sip-dengan-sngrep)
12. [Analisis Protokol dengan Wireshark](#analisis-protokol-dengan-wireshark)
13. [Perhitungan QoS dan MOS](#perhitungan-qos-dan-mos)

## Persiapan Awal

### Instalasi Sistem Ubuntu 22.04
Sistem VoIP dibangun pada VM Ubuntu 22.04 dengan spesifikasi:
- IP Address: 192.168.0.111
- Interface Network: enp0s3
- Netmask: 255.255.255.0

### Instalasi Paket Dasar
```bash
# Update repository
sudo apt update

# Upgrade sistem
sudo apt upgrade -y

# Instalasi paket yang dibutuhkan
sudo apt install -y build-essential git wget libssl-dev libxml2-dev libncurses5-dev uuid-dev sqlite3 libsqlite3-dev pkg-config libjansson-dev libxml2-dev libxslt1-dev libedit-dev
```

## Instalasi Asterisk dengan PJSIP

### Download Source Code Asterisk
```bash
# Buat direktori source
cd /usr/src/
sudo mkdir asterisk
sudo chown $USER:$USER asterisk
cd asterisk

# Download Asterisk 18.26.1
wget https://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-18.26.1.tar.gz

# Ekstrak tarball
tar -xvf asterisk-18.26.1.tar.gz

# Masuk ke direktori hasil ekstraksi
cd asterisk-18.26.1/
```

### Konfigurasi dan Kompilasi
```bash
# Konfigurasi dengan dukungan PJSIP bundled
sudo ./configure --with-pjproject-bundled

# Pilih modul (pastikan res_pjsip dan modul terkait diaktifkan)
sudo make menuselect

# Kompilasi dan instalasi
sudo make
sudo make install
sudo make samples
sudo make config

# Konfigurasi Asterisk untuk start saat boot
sudo systemctl enable asterisk

# Start layanan Asterisk
sudo systemctl start asterisk
```

## Konfigurasi Dasar

### Backup Konfigurasi
```bash
# Buat direktori backup
sudo mkdir -p /etc/asterisk/backup

# Backup konfigurasi asli
sudo cp /etc/asterisk/*.conf /etc/asterisk/backup/
```

### Konfigurasi modules.conf
```bash
sudo nano /etc/asterisk/modules.conf
```

Isi file:
```ini
[modules]
autoload=yes

; Explicitly load the PJSIP channel driver
noload => chan_sip.so
load => res_pjsip.so
load => res_pjsip_session.so
load => res_pjsip_pubsub.so
load => res_pjsip_sdp_rtp.so
load => res_pjsip_notify.so
load => res_pjsip_outbound_publish.so
load => res_pjsip_outbound_registration.so
load => res_pjsip_path.so
load => res_pjsip_registrar.so
load => res_pjsip_endpoint_identifier_ip.so
load => res_pjsip_mwi.so
load => res_pjsip_nat.so
load => res_pjsip_transport_websocket.so
load => res_pjsip_transport_management.so

; Load the RTP engine
load => res_rtp_asterisk.so

; Load SRTP for secure media
load => res_srtp.so

; Load music on hold module (for the additional feature)
load => res_musiconhold.so

; Load voicemail module (for the additional feature)
load => app_voicemail.so

; Load dialplan applications
load => app_dial.so
load => app_playback.so
load => app_stack.so
load => app_verbose.so
load => app_voicemail.so
load => app_directory.so
load => app_confbridge.so
```

### Konfigurasi rtp.conf
```bash
sudo nano /etc/asterisk/rtp.conf
```

Isi file:
```ini
[general]
rtpstart=10000
rtpend=20000
icesupport=yes
dtmfmode=auto
strictrtp=no

; SRTP configuration
srtp_tag_32=yes
```

## Konfigurasi PJSIP

### Konfigurasi pjsip.conf (Versi Final)
```bash
sudo nano /etc/asterisk/pjsip.conf
```

Isi file:
```ini
; Global settings
[global]
type=global
externaddr=192.168.0.111
localnet=192.168.0.0/24
user_agent=Asterisk PBX

; Transport definitions
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060

[transport-tls]
type=transport
protocol=tls
bind=0.0.0.0:5061
cert_file=/etc/asterisk/keys/asterisk.pem
priv_key_file=/etc/asterisk/keys/asterisk.pem
method=tlsv1_2

;====== UDP Endpoints (1 + last 4 digits of NIM) ======

; User 1 - UDP (101012300325)
[10325]
type=endpoint
transport=transport-udp
context=internal
disallow=all
allow=ulaw,alaw,g722
aors=10325
auth=10325
callerid="User1" <10325>
direct_media=no

[10325]
type=auth
auth_type=userpass
username=10325
password=123

[10325]
type=aor
max_contacts=5
remove_existing=yes
qualify_frequency=30

; User 2 - UDP (101012330294)
[10294]
type=endpoint
transport=transport-udp
context=internal
disallow=all
allow=ulaw,alaw,g722
aors=10294
auth=10294
callerid="User2" <10294>
direct_media=no

[10294]
type=auth
auth_type=userpass
username=10294
password=123

[10294]
type=aor
max_contacts=5
remove_existing=yes
qualify_frequency=30

; User 3 - UDP (101012330220)
[10220]
type=endpoint
transport=transport-udp
context=internal
disallow=all
allow=ulaw,alaw,g722
aors=10220
auth=10220
callerid="User3" <10220>
direct_media=no

[10220]
type=auth
auth_type=userpass
username=10220
password=123

[10220]
type=aor
max_contacts=5
remove_existing=yes
qualify_frequency=30

; User 4 - UDP (101012300324)
[10324]
type=endpoint
transport=transport-udp
context=internal
disallow=all
allow=ulaw,alaw,g722
aors=10324
auth=10324
callerid="User4" <10324>
direct_media=no

[10324]
type=auth
auth_type=userpass
username=10324
password=123

[10324]
type=aor
max_contacts=5
remove_existing=yes
qualify_frequency=30

;====== TLS Endpoints (2 + last 4 digits of NIM) ======

; User 1 - TLS (101012300325)
[20325]
type=endpoint
transport=transport-tls
context=internal
disallow=all
allow=ulaw,alaw,g722
aors=20325
auth=20325
callerid="User1-TLS" <20325>
direct_media=no

[20325]
type=auth
auth_type=userpass
username=20325
password=123

[20325]
type=aor
max_contacts=5
remove_existing=yes
qualify_frequency=30

; User 2 - TLS (101012330294)
[20294]
type=endpoint
transport=transport-tls
context=internal
disallow=all
allow=ulaw,alaw,g722
aors=20294
auth=20294
callerid="User2-TLS" <20294>
direct_media=no

[20294]
type=auth
auth_type=userpass
username=20294
password=123

[20294]
type=aor
max_contacts=5
remove_existing=yes
qualify_frequency=30

; User 3 - TLS (101012330220)
[20220]
type=endpoint
transport=transport-tls
context=internal
disallow=all
allow=ulaw,alaw,g722
aors=20220
auth=20220
callerid="User3-TLS" <20220>
direct_media=no

[20220]
type=auth
auth_type=userpass
username=20220
password=123

[20220]
type=aor
max_contacts=5
remove_existing=yes
qualify_frequency=30

; User 4 - TLS (101012300324)
[20324]
type=endpoint
transport=transport-tls
context=internal
disallow=all
allow=ulaw,alaw,g722
aors=20324
auth=20324
callerid="User4-TLS" <20324>
direct_media=no

[20324]
type=auth
auth_type=userpass
username=20324
password=123

[20324]
type=aor
max_contacts=5
remove_existing=yes
qualify_frequency=30
```

## Konfigurasi Extensions

### Konfigurasi extensions.conf
```bash
sudo nano /etc/asterisk/extensions.conf
```

Isi file:
```ini
[general]
static=yes
writeprotect=no
priorityjumping=no
autofallthrough=yes

[globals]

[subscriptions]

[internal]
; Regular extensions for UDP
exten => 10325,1,NoOp(Call to User1)
 same => n,Set(CALLERID(name)=User1)
 same => n,Answer()
 same => n,Set(TIMEOUT(absolute)=3600)
 same => n,Dial(PJSIP/10325,20,tm(default))
 same => n,Voicemail(10325@default,u)
 same => n,Hangup()
 
exten => 10294,1,NoOp(Call to User2)
 same => n,Set(CALLERID(name)=User2)
 same => n,Answer()
 same => n,Set(TIMEOUT(absolute)=3600)
 same => n,Dial(PJSIP/10294,20,tm(default))
 same => n,Voicemail(10294@default,u)
 same => n,Hangup()
 
exten => 10220,1,NoOp(Call to User3)
 same => n,Set(CALLERID(name)=User3)
 same => n,Answer()
 same => n,Set(TIMEOUT(absolute)=3600)
 same => n,Dial(PJSIP/10220,20,tm(default))
 same => n,Voicemail(10220@default,u)
 same => n,Hangup()
 
exten => 10324,1,NoOp(Call to User4)
 same => n,Set(CALLERID(name)=User4)
 same => n,Answer()
 same => n,Set(TIMEOUT(absolute)=3600)
 same => n,Dial(PJSIP/10324,20,tm(default))
 same => n,Voicemail(10324@default,u)
 same => n,Hangup()

; TLS extensions
exten => 20325,1,NoOp(Call to User1-TLS)
 same => n,Set(CALLERID(name)=User1-TLS)
 same => n,Answer()
 same => n,Set(TIMEOUT(absolute)=3600)
 same => n,Dial(PJSIP/20325,20,tm(default))
 same => n,Voicemail(20325@default,u)
 same => n,Hangup()
 
exten => 20294,1,NoOp(Call to User2-TLS)
 same => n,Set(CALLERID(name)=User2-TLS)
 same => n,Answer()
 same => n,Set(TIMEOUT(absolute)=3600)
 same => n,Dial(PJSIP/20294,20,tm(default))
 same => n,Voicemail(20294@default,u)
 same => n,Hangup()
 
exten => 20220,1,NoOp(Call to User3-TLS)
 same => n,Set(CALLERID(name)=User3-TLS)
 same => n,Answer()
 same => n,Set(TIMEOUT(absolute)=3600)
 same => n,Dial(PJSIP/20220,20,tm(default))
 same => n,Voicemail(20220@default,u)
 same => n,Hangup()
 
exten => 20324,1,NoOp(Call to User4-TLS)
 same => n,Set(CALLERID(name)=User4-TLS)
 same => n,Answer()
 same => n,Set(TIMEOUT(absolute)=3600)
 same => n,Dial(PJSIP/20324,20,tm(default))
 same => n,Voicemail(20324@default,u)
 same => n,Hangup()

; Voicemail access
exten => *98,1,Answer()
 same => n,VoiceMailMain(@default)
 same => n,Hangup()

; Music on Hold test
exten => *99,1,Answer()
 same => n,MusicOnHold(default,60)
 same => n,Hangup()

; Call Forwarding example - User1 to User2
exten => *21,1,Answer()
 same => n,Set(DB(CF/${CALLERID(num)})=10294)
 same => n,Playback(call-forwarding-activated)
 same => n,Hangup()

; Deactivate call forwarding
exten => *22,1,Answer()
 same => n,DBDel(CF/${CALLERID(num)})
 same => n,Playback(call-forwarding-deactivated)
 same => n,Hangup()
```

## Konfigurasi Voicemail

### Konfigurasi voicemail.conf
```bash
sudo nano /etc/asterisk/voicemail.conf
```

Isi file:
```ini
[general]
format=wav49|wav
serveremail=voip-server@localhost
attach=yes
skipms=3000
maxsilence=10
silencethreshold=128
maxlogins=3
sendvoicemail=yes
maxmsg=100
maxsecs=300
minsecs=3
maxgreet=60
review=yes
operator=yes
nextaftercmd=yes
emailsubject=New voicemail from ${VM_CALLERID}
emailbody=You have a new voicemail from ${VM_CALLERID} lasting ${VM_DUR} seconds.\n\nThanks,\nAsterisk VoIP Server

[default]
10325 => 1234,User1,user1@example.com
10294 => 1234,User2,user2@example.com
10220 => 1234,User3,user3@example.com
10324 => 1234,User4,user4@example.com
20325 => 1234,User1-TLS,user1@example.com
20294 => 1234,User2-TLS,user2@example.com
20220 => 1234,User3-TLS,user3@example.com
20324 => 1234,User4-TLS,user4@example.com
```

## Konfigurasi Music on Hold

### Konfigurasi musiconhold.conf
```bash
sudo nano /etc/asterisk/musiconhold.conf
```

Isi file:
```ini
[default]
mode=files
directory=/var/lib/asterisk/moh
random=yes
```

### Memastikan File Musik Tersedia
```bash
# Periksa apakah file music on hold ada
ls -la /var/lib/asterisk/moh

# Jika tidak ada file ditemukan, download beberapa sampel
if [ ! "$(ls -A /var/lib/asterisk/moh)" ]; then
    sudo apt install -y sox mpg123
    cd /tmp
    sudo wget -O music.wav https://www.voip-info.org/wp-content/uploads/2019/02/classical-hold-music.wav
    sudo sox music.wav -t raw -r 8000 -c 1 /var/lib/asterisk/moh/music.wav
    sudo chown -R asterisk:asterisk /var/lib/asterisk/moh
fi
```

## Konfigurasi TLS

### Membuat Sertifikat untuk TLS
```bash
# Buat direktori untuk sertifikat
sudo mkdir -p /etc/asterisk/keys

# Generate sertifikat self-signed menggunakan OpenSSL
sudo openssl req -new -x509 -days 3650 -nodes \
    -out /etc/asterisk/keys/asterisk.pem \
    -keyout /etc/asterisk/keys/asterisk.pem \
    -subj "/C=ID/ST=Jakarta/L=Jakarta/O=Asterisk/CN=192.168.0.111"

# Atur permission yang sesuai
sudo chown -R asterisk:asterisk /etc/asterisk/keys 2>/dev/null || sudo chown -R root:root /etc/asterisk/keys
sudo chmod -R 550 /etc/asterisk/keys
```

## Troubleshooting

### Masalah Sertifikat TLS
```bash
# Periksa apakah file sertifikat ada
ls -la /etc/asterisk/keys/

# Cek permission
sudo chmod -R 550 /etc/asterisk/keys
sudo chown -R asterisk:asterisk /etc/asterisk/keys
```

### Masalah Koneksi Client
```bash
# Verifikasi konfigurasi endpoint PJSIP
sudo asterisk -rx "pjsip show endpoints"

# Cek transport yang aktif
sudo asterisk -rx "pjsip show transports"

# Periksa kontak yang terdaftar
sudo asterisk -rx "pjsip show contacts"

# Melihat log Asterisk untuk error
sudo tail -f /var/log/asterisk/full

# Aktifkan debug mode di Asterisk CLI
sudo asterisk -r
*CLI> pjsip set logger on
*CLI> core set verbose 5
```

### Masalah Firewall
```bash
# Periksa status firewall
sudo ufw status

# Nonaktifkan firewall jika diperlukan (untuk testing)
sudo ufw disable
```

## Konfigurasi Client

### Konfigurasi MicroSIP
Untuk koneksi UDP (10xxx):
- Account name: User1 (atau nama yang sesuai)
- SIP Server: 192.168.0.111
- User: 10325 (atau ekstensi yang dipilih)
- Domain: 192.168.0.111
- AuthID: 10325
- Password: 123
- Display Name: User1
- Transport: UDP

Untuk koneksi TLS (20xxx):
- Account name: User1-TLS (atau nama yang sesuai)
- SIP Server: 192.168.0.111
- User: 20325 (atau ekstensi yang dipilih)
- Domain: 192.168.0.111
- AuthID: 20325
- Password: 123
- Display Name: User1-TLS
- Transport: TLS

### Konfigurasi Linphone
Proses konfigurasi Linphone mirip dengan MicroSIP, dengan parameter yang sama.

## Analisis SIP dengan SNGREP

### Instalasi SNGREP
```bash
sudo apt install -y sngrep
```

### Cara Menggunakan SNGREP
```bash
# Capture traffic SIP di port UDP
sudo sngrep -d any port 5060

# Capture traffic SIP di port TLS
sudo sngrep -d any port 5061
```

## Analisis Protokol dengan Wireshark

### Instalasi Wireshark
```bash
sudo apt install -y wireshark tshark
sudo usermod -a -G wireshark $USER
```

### Capture Traffic
```bash
# Capture traffic VoIP
sudo tshark -i any -f "port 5060 or port 5061 or udp portrange 10000-20000" -w /tmp/voip_capture.pcap
```

## Perhitungan QoS dan MOS

Untuk perhitungan QoS, kita dapat menganalisis data Wireshark yang sudah di-capture:

1. Buka file capture di Wireshark
2. Klik Statistics > VoIP Calls
3. Pilih panggilan dan klik "Analyze"
4. Cek tab RTP untuk jitter, packet loss dan metrik lainnya

Untuk perhitungan MOS, gunakan rumus E-model:
- R-value = 93.2 - Id - Ie - Is
  - dimana:
    - Id adalah delay impairment (fungsi dari one-way delay)
    - Ie adalah equipment impairment (tergantung pada codec)
    - Is adalah simultaneous impairment
- MOS = 1 + 0.035*R + 7*10^-6*R*(R-60)*(100-R)

## Restart Asterisk Setelah Konfigurasi

```bash
sudo systemctl restart asterisk
```

## Verifikasi Konfigurasi Final

```bash
# Masuk ke Asterisk CLI
sudo asterisk -rvvv

# Verifikasi endpoint
*CLI> pjsip show endpoints

# Verifikasi transport
*CLI> pjsip show transports

# Verifikasi kontak
*CLI> pjsip show contacts
```

Hasil dari `pjsip show endpoints` dan `pjsip show transports` menunjukkan bahwa konfigurasi bekerja dengan baik, dengan semua ekstensi UDP (10xxx) dan TLS (20xxx) terdaftar dan tersedia. Transport UDP dan TLS juga aktif dan berjalan pada port yang sesuai (5060 untuk UDP dan 5061 untuk TLS).

## Kesimpulan

Konfigurasi VoIP menggunakan Asterisk dengan PJSIP telah berhasil diimplementasikan. Sistem mendukung:

1. Ekstensi UDP (10xxx) dan TLS (20xxx) sesuai nomor NIM
2. Fitur Music on Hold
3. Fitur Voicemail
4. Fitur Call Forwarding

Semua ekstensi dapat saling terhubung dan berkomunikasi melalui softphone (MicroSIP atau Linphone). Protokol komunikasi (UDP, SIP, SRTP, dan TLS) telah dikonfigurasi dengan benar, dan dapat dianalisis menggunakan SNGREP dan Wireshark.