Forum Discussion
LB for SMPP / SMSCs in NFV environment
when CLIENT_ACCEPTED { set seq_index 1 set bind_context 0
set unbind_context 0TCP::collect
}
when CLIENT_DATA { while { [TCP::payload length] > 16 } { binary scan [TCP::payload] IH8IIa* RQTLen RQTOper RQTStatus RQTSeq p if { [TCP::payload length] < $RQTLen } { TCP::collect $RQTLen return }
switch -glob $RQTOper {
00000001 -
00000002 -
00000009 {
bind
log local0.info "SMPP:BindRequest Data: LEN:$RQTLen Command:$RQTOper Satus:$RQTStatus Seqence:$RQTSeq"
set bind_message [TCP::payload $RQTLen]
set bind_context 1
foreach smsc_node [active_members -list pool_smsc] {
set node [lindex [split $smsc_node " "] 0]:[lindex [split $smsc_node " "] 1]
set smsc($smsc_node) "0 0 0"
foreach {smsc_node_1} [array get smsc]
{
log local0.info "ARRAY_ELEMENT_1 ==> $smsc_node_1"
}
}
}
00000006 {
unbind
log local0.info "SMPP:UnbindRequest Data:LEN:$RQTLen Command:$RQTOper Satus:$RQTStatus Seqence:$RQTSeq"
set unbind_message [TCP::payload $RQTLen]
set unbind_context 1
}
00000015 {
enquire_link
log local0.info "SMPP:enquireLinkRequest Data:LEN:$RQTLen Command:$RQTOper Satus:$RQTStatus Seqence:$RQTSeq"
set enquire_message [TCP::payload $RQTLen]
foreach {smsc_node b_status u_status el_status} [array get smsc] {
array set smsc {$smsc_node "$b_status $u_status 0"}
}
}
00000004 {
submit_sm
log local0.info "SMPP:SubmitSMRequest Data:LEN:$RQTLen Command:$RQTOper Satus:$RQTStatus Seqence:$RQTSeq"
Load balance SMS AO
LB::detach
}
8* {
Response from client (deliver_sm_resp, ...)
log local0.info "SMPP:CommandResponse Data:LEN:$RQTLen Command:$RQTOper Satus:$RQTStatus Seqence:$RQTSeq"
Rewrite RQTSeq and set the correct SMS-C to respond
if { [info exists s_seq_map($RQTSeq)] } {
set old_RQTSeq [lindex $s_seq_map($RQTSeq) 0]
TCP::payload replace 12 4 [binary format I $seq_index]
use pool or node command
pool [LB::server pool] member [lindex $s_seq_map($RQTSeq) 1] [lindex $s_seq_map($RQTSeq) 2]
unset s_seq_map($RQTSeq)
} else {
Cannot route response
log local0.info "SMPP:Unkown sequence [$RQTSeq] Data:LEN:$RQTLen Command:$RQTOper Satus:$RQTStatus Seqence:$RQTSeq"
}
}
}
TCP::release $RQTLen
TCP::notify request
}
TCP::collect
}
when SERVER_CONNECTED {
TCP::collect }when SERVER_DATA { while { [TCP::payload length] > 16 } { binary scan [TCP::payload] IH8II RQTLen RQTOper RQTStatus RQTSeq p if { [TCP::payload length] < $RQTLen } { TCP::collect $RQTLen return } switch -glob $RQTOper {
0* { Deliver_sm, ... Rewrite seq TCP::payload replace 12 4 [binary format I $seq_index] set s_seq_map($seq_index) "$RQTSeq [IP::remote_addr] [TCP::remote_port]" incr seq_index } 80000001 -
80000002 -
80000009 {
Bind_resp
if { $bind_context } {
switch -glob $RQTStatus {
00000000 -
0 -
00000005 {
No Error or ESME Already in Bound State
log local0.info "Bind:ResponseOK Data: Status:$RQTStatus Node: [IP::remote_addr] [TCP::remote_port] "
Added by YOSSI
set smsc("[IP::remote_addr]:[TCP::remote_port]") "1 0 0"
foreach {smsc_node b_status} [array get smsc] {
log local0.info "smsc_node_res $smsc_node"
if { $b_status eq "0 0 0" } {
log local0.info "Bind:OneMoreSMSCToBind Data:\[Node: $smsc_node \]"
log local0. " node [lindex [split $smsc_node " "] 0] port [lindex [split $smsc_node " "] 1]"
set a [lindex [split $smsc_node " "] 0]:[lindex [split $smsc_node " "] 1]
log local0.info "a $a"
pool pool_smsc member $a
TCP::collect -all
TCP::respond $bind_message
set smsc("$a") "1 0 0"
log local0.info "smsc("$a")"
return
}
}
log local0.info "Bind:NoMoreSMSCToBind Data:\[SMSC: $smsc_node \]"
}
*
{
Else - Respond back to client
log local0.info "Bind:ResponseFailed Data: Status:$RQTStatus Node: [IP::remote_addr] [TCP::remote_port] ]"
}
}
set bind_context 0
} else {
log local0.info "Bind:UnknownContext Data:Status:$RQTStatus Node: [IP::remote_addr] [TCP::remote_port] "
TCP::payload replace 0 [TCP::payload length] ""
set RQTLen 0
}
}
80000006 {
Unbind_resp
if { $unbind_context } {
log local0.info "Unbind:Response Data: Status:$RQTStatus Node: [IP::remote_addr] [TCP::remote_port] "
set memb "[IP::remote_addr] [TCP::remote_port]"
array set smsc {$memb "1 1 0"}
foreach {smsc_node b_status u_status el_status} [array get smsc] {
if {$u_status eq 0} {
log local0.info "Unbind:OneMoreSMSCToUnbind Data:\[Node: $smsc_node \]"
pool pool_smsc member $smsc_node
TCP::collect -all
TCP::respond $unbind_message
return
}
}
log local0.info "Unbind:NoMoreSMSCToUnbind Data"
} else {
log local0.info "Unbind:UnknownContext Data:Status:$RQTStatus Node: [IP::remote_addr] [TCP::remote_port] "
TCP::payload replace 0 [TCP::payload length] ""
set RQTLen 0
}
set unbind_context 0
unset smsc;
}
80000015 {
Enquire_link_resp
log local0.info "Enquire_link:Response Data: Status:$RQTStatus Node: [IP::remote_addr] [TCP::remote_port] "
set memb "[IP::remote_addr] [TCP::remote_port]"
array set smsc {$memb "1 1 0"}
foreach {smsc_node b_status u_status el_status} [array get smsc] {
if {$el_status eq 0} {
log local0.info "Enquire_link:OneMoreSMSCToEnquireLink Data:\[Node: $smsc_node \]"
pool pool_smsc member $smsc_node
TCP::collect -all
TCP::respond $enquire_message
return
}
}
log local0.info "Enquire_link:NoMoreSMSCToEnquireLink Data"
}
}
TCP::release $RQTLen
TCP::notify response
}
TCP::collect
}
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com