@startuml "TD_VoLTE_EMC_INT_DTC_02.png"
!include etsi-style.iuml
!pragma teoz true
'
'
'Figure : UE Emergency Initiated Network Detachment with Previously Established Emergency Registration & Emergency Session
'
''title Figure : UE Emergency Initiated Network Detachment with Previously Established Emergency Registration & Emergency Session
'
participant "UE A"
box "EPC A" #LightBlue
  participant MME
  participant PGw
  participant PCRF
end box
box "IMS A" #LightBlue
	participant "P-CSCF"
  participant "E-CSCF"
  participant "IBCF"
  participant "BGCF"
end box
participant "PSAP"

rnote right  "UE A"         : Gm
& rnote right "PGw"         : Gx
& rnote right "PCRF"        : Rx
& rnote right "P-CSCF"      : Mw
& rnote right "E-CSCF"      : Mm\nMx\nMi
& rnote left  "IBCF"        : \nMx\n
& rnote right "IBCF"        : Ici
& rnote left "BGCF"        : \n\nMi
& rnote left "PSAP"        : Mm\n\n


'
"UE A"     <---> "PSAP"     : Active emergency session, media exchange
rnote over "UE A"  #FFAAAA: Deattachment triggered
"UE A"     ->   "P-CSCF"    : BYE
"P-CSCF"   ->   "PCRF"      : STR
&"PCRF"    ->   "PGw"       : RAR
"PGw"      ->   "PCRF"      : RAA
&"PCRF"    ->   "P-CSCF"    : STA
&"P-CSCF"  ->   "E-CSCF"    : BYE
rnote over "P-CSCF","E-CSCF"  #FFAAAA: Termination of Emergency session
alt PSAP in IMS A network (option 1)
"E-CSCF"   ->   "PSAP"      : BYE
else PSAP not in IMS A network (option 2)\n
"E-CSCF"   ->   "IBCF"      : BYE
&"IBCF"    -->   "PSAP"     : BYE
else PSAP in PSTN network (option 3)\n
"E-CSCF"   ->   "BGCF"      : BYE
&"BGCF"    -->   "PSAP"     : 
end
alt PSAP in IMS A network (option 1)
"PSAP"     ->   "E-CSCF"    : 200 OK
else PSAP not in IMS A network (option 2)\n
"PSAP"     -->   "IBCF"     : 200 OK
&"IBCF"    ->   "E-CSCF"    : 200 OK
else PSAP in PSTN network (option 3)\n
"PSAP"     -->   "BGCF"     : 
&"BGCF"    ->   "E-CSCF"    : 200 OK
end
"E-CSCF"   ->   "P-CSCF"    : 200 OK
& "P-CSCF" ->   "UE A"      : 200 OK
rnote over "UE A", PGw #FFAAAA: Removal of emergency Bearer
"PGw"      ->   "PCRF"      : CCR
"PCRF"     ->   "PGw"       : CCA
@enduml