Kamailio Routing logic written in native Kamailio language or using a single monolithic file is neither easily maintainable nor testable. This talk shows a way to maintain a unit tested Kamailio routing configuration, reducing the fear of having your customers discover your bugs.
Cluecon 2015
Use of external controller applications to fetch the next routes and let Kamailio handle the SIP layer.
Example with Node.js external application and evapi+rtjson modules in Kamailio
Fosdem 2016, Brussels, Belgium
A developer perspective of the components in the C code that impact the performances of the signaling servers, applied for Kamailio (https://www.kamailio.org), reflecting how they can be tuned from configuration file to increase the capacity of a SIP server.
Presentation done at Kamailio World 2014, Berlin, Germanu - several methods to do asynchronous SIP routing via Kamailio configuration file. Blend modules such as tm, tmx, mqueue, rtimer, async, evapi, etc. to suspend routing of current SIP request and resume that once processing of additional tasks has finished.
Presentation done at Kamailio World 2013, Berlin, Germany - several options for scalability of SIP routing with Kamailio, from configuration file tricks to stateless and stateful load balancing with dispatcher module.
Devel::NYTProf 2009-07 (OUTDATED, see 201008)Tim Bunce
The slides of my "State-of-the-art Profiling with Devel::NYTProf" talk at OSCON in July 2009.
I'll upload a screencast and give the link in a blog post at http://blog.timbunce.org
Cluecon 2015
Use of external controller applications to fetch the next routes and let Kamailio handle the SIP layer.
Example with Node.js external application and evapi+rtjson modules in Kamailio
Fosdem 2016, Brussels, Belgium
A developer perspective of the components in the C code that impact the performances of the signaling servers, applied for Kamailio (https://www.kamailio.org), reflecting how they can be tuned from configuration file to increase the capacity of a SIP server.
Presentation done at Kamailio World 2014, Berlin, Germanu - several methods to do asynchronous SIP routing via Kamailio configuration file. Blend modules such as tm, tmx, mqueue, rtimer, async, evapi, etc. to suspend routing of current SIP request and resume that once processing of additional tasks has finished.
Presentation done at Kamailio World 2013, Berlin, Germany - several options for scalability of SIP routing with Kamailio, from configuration file tricks to stateless and stateful load balancing with dispatcher module.
Devel::NYTProf 2009-07 (OUTDATED, see 201008)Tim Bunce
The slides of my "State-of-the-art Profiling with Devel::NYTProf" talk at OSCON in July 2009.
I'll upload a screencast and give the link in a blog post at http://blog.timbunce.org
Kamailio 5.0 allows writing full routing logic in Lua scripting language, opening the door for easy integration with external services and increasing the flexibility of optimizing SIP routing.
It is mainly about the multithreading and the multiprocessing in Python, and *in Python's flavor*.
It's also the share at Taipei.py [1].
[1] http://www.meetup.com/Taipei-py/events/220452029/
A status update on JRuby, covering compatibility, Rails, and next-gen performance numbers. JRuby is currently the fastest way to run Rails apps, and we're doing work to make it even faster in the future.
Slides of my talk on Devel::NYTProf and optimizing perl code at YAPC::NA in June 2014. It covers use of NYTProf and outlines a multi-phase approach to optimizing your perl code.
A video of the talk and questions is available at https://www.youtube.com/watch?v=T7EK6RZAnEA&list=UU7y4qaRSb5w2O8cCHOsKZDw
Troubleshooting common oslo.messaging and RabbitMQ issuesMichael Klishin
This talk focuses on troubleshooting of common oslo.messaging and RabbitMQ issues in OpenStack environments. Co-presented at the OpenStack Summit Austin in April 2016.
Roll Your Own API Management Platform with nginx and LuaJon Moore
We recently replaced a proprietary API management solution with an in-house implementation built with nginx and Lua that let us get to a continuous delivery practice in a handful of months. Learn about our development process and the overall architecture that allowed us to write minimal amounts of code, enjoying native code performance while permitting interactive codeing, and how we leveraged other open source tools like Vagrant, Ansible, and OpenStack to build an automation-rich delivery pipeline. We will also take an in-depth look at our capacity management approach that differs from the rate limiting concept prevalent in the API community.
PuppetConf 2017: What's in a Name? Scaling ENC with DNS- Cameron Nicholson, A...Puppet
Are you frustrated with your External Node Classifier performance? Do you have gnarly regexes in your nodes.pp controlling what gets applied where? Maybe you’re just looking to see what others are doing to keep their ENC performant at global scale. Join me to see how Hiera, Facter, and DNS can classify your nodes with easily-understood, highly flexible naming schemes. If you can scale DNS then you can scale your ENC performance for free. I’ll show you how to design and implement name-based classification schemes to work with any existing environment. Anticipating a green field deployment? I’ll cover how to avoid painting yourself into corners with your classification choices. There are two hard problems: Cache invalidation and naming things. This presentation tackles both head-on.
Kamailio 5.0 allows writing full routing logic in Lua scripting language, opening the door for easy integration with external services and increasing the flexibility of optimizing SIP routing.
It is mainly about the multithreading and the multiprocessing in Python, and *in Python's flavor*.
It's also the share at Taipei.py [1].
[1] http://www.meetup.com/Taipei-py/events/220452029/
A status update on JRuby, covering compatibility, Rails, and next-gen performance numbers. JRuby is currently the fastest way to run Rails apps, and we're doing work to make it even faster in the future.
Slides of my talk on Devel::NYTProf and optimizing perl code at YAPC::NA in June 2014. It covers use of NYTProf and outlines a multi-phase approach to optimizing your perl code.
A video of the talk and questions is available at https://www.youtube.com/watch?v=T7EK6RZAnEA&list=UU7y4qaRSb5w2O8cCHOsKZDw
Troubleshooting common oslo.messaging and RabbitMQ issuesMichael Klishin
This talk focuses on troubleshooting of common oslo.messaging and RabbitMQ issues in OpenStack environments. Co-presented at the OpenStack Summit Austin in April 2016.
Roll Your Own API Management Platform with nginx and LuaJon Moore
We recently replaced a proprietary API management solution with an in-house implementation built with nginx and Lua that let us get to a continuous delivery practice in a handful of months. Learn about our development process and the overall architecture that allowed us to write minimal amounts of code, enjoying native code performance while permitting interactive codeing, and how we leveraged other open source tools like Vagrant, Ansible, and OpenStack to build an automation-rich delivery pipeline. We will also take an in-depth look at our capacity management approach that differs from the rate limiting concept prevalent in the API community.
PuppetConf 2017: What's in a Name? Scaling ENC with DNS- Cameron Nicholson, A...Puppet
Are you frustrated with your External Node Classifier performance? Do you have gnarly regexes in your nodes.pp controlling what gets applied where? Maybe you’re just looking to see what others are doing to keep their ENC performant at global scale. Join me to see how Hiera, Facter, and DNS can classify your nodes with easily-understood, highly flexible naming schemes. If you can scale DNS then you can scale your ENC performance for free. I’ll show you how to design and implement name-based classification schemes to work with any existing environment. Anticipating a green field deployment? I’ll cover how to avoid painting yourself into corners with your classification choices. There are two hard problems: Cache invalidation and naming things. This presentation tackles both head-on.
This is story of our journey from SaltStack to Puppet and beyond. This talk will answer following questions:
- why we moved from SaltStack
- why Puppet was chosen
- how to use Puppet OpenSource in painless way
- which orchestration tool to use with Puppet
- what is next
Apache Solr on Hadoop is enabling organizations to collect, process and search larger, more varied data. Apache Spark is is making a large impact across the industry, changing the way we think about batch processing and replacing MapReduce in many cases. But how can production users easily migrate ingestion of HDFS data into Solr from MapReduce to Spark? How can they update and delete existing documents in Solr at scale? And how can they easily build flexible data ingestion pipelines? Cloudera Search Software Engineer Wolfgang Hoschek will present an architecture and solution to this problem. How was Apache Solr, Spark, Crunch, and Morphlines integrated to allow for scalable and flexible ingestion of HDFS data into Solr? What are the solved problems and what's still to come? Join us for an exciting discussion on this new technology.
From Ansible's website: "Ansible is a radically simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs."
This introduction is based on ansible official docs, capturing most important information to make it easy to understand Ansible main concepts.
Why Managed Service Providers Should Embrace Container TechnologySagi Brody
This talk will demonstrate the importance and value for Managed Service Providers (MSPs) and cloud providers of building their business models around the management of containers. It will also explore the various container technologies being used today and why one might be utilized over another. The object is not to give a technical discussion on the subject, but rather to cover the benefits of Linux containers and how their use can be incorporated into strategies for future business planning and development.
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...srisatish ambati
Top 10 Causes for Java Issues in Production and What to Do When Things Go Wrong
JavaOne 2010.
Abstract: It's Friday evening and you hear the first rumble . . . one java node has become slightly unresponsive. You lookup the process, get a thread dump, and for good measure restart it at 8 p.m. Saturday afternoon is when you realize that other nodes have caught the flu and you get the ugly call from the customer. In a matter of hours, you're on that conference bridge with support groups of different packages and Java vendors and one of your uberarchitects. Yes, production instances are up and down, and restarting like there's no tomorrow. Here's an accumulated compendium of the op 10 things that can cause Java production heartburn and what to do when your Java production is on fire. And yes, please have your tools belt on.
Speaker(s):
Cliff Click, Azul Systems, Distinguished Engineer
SriSatish Ambati, Azul Systems, Performance Engineer
Automated Reports with Rstudio Server
Automated KPI reporting with Shiny Server
Process Validation Documentation with Jupyter Notebook
Automated Machine Learning with Dataiku
With employees based in countries around the globe which provide 24x7 services to MySQL users worldwide, Percona provides enterprise-grade MySQL Support, Consulting, Training, Managed Services, and Server Development services to companies ranging from large organizations, such as Cisco Systems, Alcatel-Lucent, Groupon, and the BBC, to recent startups building MySQL-powered solutions for businesses and consumers.
Fault Tolerance in Spark: Lessons Learned from Production: Spark Summit East ...Spark Summit
Spark is by its nature very fault tolerant. However, faults, and application failures, can and do happen, in production at scale.
In this talk, we’ll discuss the nuts and bolts of fault tolerance in Spark.
We will begin with a brief overview of the sorts of fault tolerance offered, and lead into a deep dive of the internals of fault tolerance. This will include a discussion of Spark on YARN, scheduling, and resource allocation.
We will then spend some time on a case study and discussing some tools used to find and verify fault tolerance issues. Our case study comes from a customer who experienced an application outage that was root caused to a scheduler bug. We discuss the analysis we did to reach this conclusion and the work that we did to reproduce it locally. We highlight some of the techniques used to simulate faults and find bugs.
At the end, we’ll discuss some future directions for fault tolerance improvements in Spark, such as scheduler and checkpointing changes.
Similar to Kamailioworld 2018 - Modular and test driven SIP Routing with Lua (20)
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Mind IT Systems
Healthcare providers often struggle with the complexities of chronic conditions and remote patient monitoring, as each patient requires personalized care and ongoing monitoring. Off-the-shelf solutions may not meet these diverse needs, leading to inefficiencies and gaps in care. It’s here, custom healthcare software offers a tailored solution, ensuring improved care and effectiveness.
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
2. Who we are, what we do
• Düsseldorf based VoIP service provider (since 2004)
• Active in Germany and UK
• Full MVNO in the Telefónica network
• Private and Business customers
• VoIP and Mobile products
• Some 100k active customers
• Almost 100 million minutes each month
5. Of course, we use Kamailio
All over our network.
But we have a huge problem!
6. What problem?
at sipgate
• methods of software development have changed:
- Agile, fast cycles, many releases
- small modules
- unit tests, continuous deployment
- permanent refactoring of functions
7. What problem?
at sipgate
• methods of software development have changed:
- Agile, fast cycles, many releases
- small modules
- unit tests, continuous deployment
- permanent refactoring of functions
• telephony side:
- "organically grown" routing logic (since 2004)
- 40 developers, but only 4 people can read/write it
- learnings from software development haven't made it to this part
19. But how do we fix that?
• app_*:
- app_lua
- app_python
- app_jsdt
- app_java, app_mono, app_perl
- missing: app_ruby ;)
20. But how do we fix that?
• app_*:
- app_lua
- app_python
- app_jsdt
- app_java, app_mono, app_perl
- missing: app_ruby ;)
• KEMI
- lua
- python
- jsdt
- sqlang
21. Why Lua?
1. Speed
Interpreter Average Min Max
Native 302.28 6 3824
Lua 308.32 6 3596
Python 393.71 23 3266
All times in Microseconds.
Source: https://www.kamailio.org/wiki/devel/config-engines#interpreters_performances
22. Why Lua?
2. Easy to learn
• None of us had written Lua (production) code before.
• If you've written code before, you'll be able to start right away.
• Less fear of changing something within Kamailio.
23. Why Lua?
3. You can work test-driven
• Impossible with native Kamailio language
• Know if you broke something before you deploy it!
25. Standard way: one big Lua file
Still have to know Kamailio syntax all the time
function ksr_request_route()
-- per request initial checks
ksr_route_reqinit();
-- NAT detection
ksr_route_natdetect();
-- CANCEL processing
if KSR.pv.get("$rm") == "CANCEL" then
if KSR.tm.t_check_trans()>0 then
ksr_route_relay();
end
return 1;
end
-- handle requests within SIP dialogs
ksr_route_withindlg();
-- -- only initial requests (no To tag)
-- handle retransmissions
if KSR.tmx.t_precheck_trans()>0 then
KSR.tm.t_check_trans();
return 1;
end
if KSR.tm.t_check_trans()==0 then return 1 end
-- authentication
ksr_route_auth();
-- remove preloaded route headers
KSR.hdr.remove("Route");
if string.find("INVITE|SUBSCRIBE", KSR.pv.get("$rm")) then
KSR.rr.record_route();
end
-- account only INVITEs
if KSR.pv.get("$rm")=="INVITE" then
KSR.setflag(FLT_ACC); -- do accounting
end
-- dispatch requests to foreign domains
ksr_route_sipout();
-- -- requests for my local domains
-- handle registrations
ksr_route_registrar();
if KSR.pv.is_null("$rU") then
-- request with no Username in RURI
KSR.sl.sl_send_reply(484,"Address Incomplete");
return 1;
end
-- user location service
ksr_route_location();
return 1;
end
26. Standard way: one big Lua file
Still not testable
function ksr_request_route()
-- per request initial checks
ksr_route_reqinit();
-- NAT detection
ksr_route_natdetect();
-- CANCEL processing
if KSR.pv.get("$rm") == "CANCEL" then
if KSR.tm.t_check_trans()>0 then
ksr_route_relay();
end
return 1;
end
-- handle requests within SIP dialogs
ksr_route_withindlg();
-- -- only initial requests (no To tag)
-- handle retransmissions
if KSR.tmx.t_precheck_trans()>0 then
KSR.tm.t_check_trans();
return 1;
end
if KSR.tm.t_check_trans()==0 then return 1 end
-- authentication
ksr_route_auth();
-- remove preloaded route headers
KSR.hdr.remove("Route");
if string.find("INVITE|SUBSCRIBE", KSR.pv.get("$rm")) then
KSR.rr.record_route();
end
-- account only INVITEs
if KSR.pv.get("$rm")=="INVITE" then
KSR.setflag(FLT_ACC); -- do accounting
end
-- dispatch requests to foreign domains
ksr_route_sipout();
-- -- requests for my local domains
-- handle registrations
ksr_route_registrar();
if KSR.pv.is_null("$rU") then
-- request with no Username in RURI
KSR.sl.sl_send_reply(484,"Address Incomplete");
return 1;
end
-- user location service
ksr_route_location();
return 1;
end
27. How about a library?
• Encapsulate Kamailio functions in easy-to-use native functions
• Re-use often used calls
• Testable
• Fix logic errors before deploying them into production
if KSR.pv.get("$rm") == "INVITE" then
[..]
end
if kamailio.is_invite() then
[..]
end
28. How about a library?
Reduce the main script to a minimum
kamailio = require("kamailio")
function ksr_request_route()
kamailio.process_request()
end
29. So how do we get there?
• Install dependencies
- Interpreter: lua, version 5.1 (apt-get install lua-5.1)
- Testing framework: busted (apt-get install lua-busted)
• Create your library.
• Define your function.
• Write tests.
• Make the function work.
30. Create your library
• Can be just one file containing all your methods
/etc/kamailio/kamailio-functions.lua
/usr/local/share/lua/5.1/kamailio-functions.lua
31. Create your library
• Can be just one file containing all your methods
/etc/kamailio/kamailio-functions.lua
/usr/local/share/lua/5.1/kamailio-functions.lua
• Can be a directory containing multiple files
/usr/local/share/lua/5.1/kamailio/
!"" actions.lua
!"" init.lua
!"" message.lua
!"" message_state.lua
!"" nathandling.lua
!"" security.lua
#"" traffic.lua
32. Create your library
• Can be just one file containing all your methods
/etc/kamailio/kamailio-functions.lua
/usr/local/share/lua/5.1/kamailio-functions.lua
• Can be a directory containing multiple files
/usr/local/share/lua/5.1/kamailio/
!"" actions.lua
!"" init.lua
!"" message.lua
!"" message_state.lua
!"" nathandling.lua
!"" security.lua
#"" traffic.lua
33. Create your library
• Can be just one file containing all your methods
/etc/kamailio/kamailio-functions.lua
/usr/local/share/lua/5.1/kamailio-functions.lua
• Can be a directory containing multiple files
/usr/local/share/lua/5.1/kamailio/
!"" actions.lua
!"" init.lua
!"" message.lua
!"" message_state.lua
!"" nathandling.lua
!"" security.lua
#"" traffic.lua
damm@stretch:~$ lua
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> foo = require "foo"
stdin:1: module 'foo' not found:
no field package.preload['foo']
no file './foo.lua'
no file '/usr/local/share/lua/5.1/foo.lua'
no file '/usr/local/share/lua/5.1/foo/init.lua'
no file '/usr/local/lib/lua/5.1/foo.lua'
no file '/usr/local/lib/lua/5.1/foo/init.lua'
no file '/usr/share/lua/5.1/foo.lua'
no file '/usr/share/lua/5.1/foo/init.lua'
no file './foo.so'
no file '/usr/local/lib/lua/5.1/foo.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/foo.so'
no file '/usr/lib/lua/5.1/foo.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
stdin:1: in main chunk
[C]: ?
>
34. Create your library
traffic = require "kamailio.traffic"
message = require "kamailio.message"
security = require "kamailio.security"
rex = require "rex_pcre"
local kamailio = {}
function kamailio:process_request()
[..]
end
function kamailio:process_reply()
[..]
end
return kamailio
35. Create your library
traffic = require "kamailio.traffic"
message = require "kamailio.message"
security = require "kamailio.security"
rex = require "rex_pcre"
local kamailio = {}
function kamailio:process_request()
[..]
end
function kamailio:process_reply()
[..]
end
return kamailio
36. Write your function
kamailio.cfg
route["clir"] {
if ($rU =~ "^*31[0-9]+$") {
strip(3);
setflag(21);
} else if ($rU =~ "^*31[*#][0-9]+$") {
strip(4);
setflag(21);
} else if ($rU =~ "^*31%23[0-9]+$") {
strip(6);
setflag(21);
}
if (isflagset(21) && method=="INVITE") {
xlog("L_NOTICE", "User wants to suppress his number for this call. F=$fU T=$tU
D=$fnn");
append_hf("Privacy: idrn");
}
}
37. Write your function
kamailio/headers.lua
rex = require "rex_pcre"
message = require "kamailio.message"
local headers = {}
function headers.get_request_user()
return KSR.pv.get("$rU")
end
function headers.set_request_user(value)
KSR.pv.sets("$rU", value)
end
function headers.set_privacy_header()
KSR.hdr.append("Privacy: id")
end
function headers.suppress_cid_if_needed()
request_user = headers.get_request_user()
if rex.find(request_user, "^*31([#]|%23)?") then
headers.set_request_user(rex.gsub(request_user, "^*31([#]|%23)?", ""))
if message.is_invite() then headers.set_privacy_header() end
end
end
return headers
38. Write your function
kamailio/headers.lua
rex = require "rex_pcre"
message = require "kamailio.message"
local headers = {}
function headers.get_request_user()
return KSR.pv.get("$rU")
end
function headers.set_request_user(value)
KSR.pv.sets("$rU", value)
end
function headers.set_privacy_header()
KSR.hdr.append("Privacy: id")
end
function headers.suppress_cid_if_needed()
request_user = headers.get_request_user()
if rex.find(request_user, "^*31([#]|%23)?") then
headers.set_request_user(rex.gsub(request_user, "^*31([#]|%23)?", ""))
if message.is_invite() then headers.set_privacy_header() end
end
end
return headers
39. Write your function
kamailio/headers.lua
rex = require "rex_pcre"
message = require "kamailio.message"
local headers = {}
function headers.get_request_user()
return KSR.pv.get("$rU")
end
function headers.set_request_user(value)
KSR.pv.sets("$rU", value)
end
function headers.set_privacy_header()
KSR.hdr.append("Privacy: id")
end
function headers.suppress_cid_if_needed()
request_user = headers.get_request_user()
if rex.find(request_user, "^*31([#]|%23)?") then
headers.set_request_user(rex.gsub(request_user, "^*31([#]|%23)?", ""))
if message.is_invite() then headers.set_privacy_header() end
end
end
return headers
40. Write your function
kamailio/headers.lua
rex = require "rex_pcre"
message = require "kamailio.message"
local headers = {}
function headers.get_request_user()
return KSR.pv.get("$rU")
end
function headers.set_request_user(value)
KSR.pv.sets("$rU", value)
end
function headers.set_privacy_header()
KSR.hdr.append("Privacy: id")
end
function headers.suppress_cid_if_needed()
request_user = headers.get_request_user()
if rex.find(request_user, "^*31([#]|%23)?") then
headers.set_request_user(rex.gsub(request_user, "^*31([#]|%23)?", ""))
if message.is_invite() then headers.set_privacy_header() end
end
end
return headers
41. Test it
spec/headers_spec.lua
require 'busted.runner'()
local headers = require "../kamailio/headers"
describe("Check and enable CLIR ->", function()
it("Caller dials *31021112345", function()
-- Call the function
headers.suppress_cid_if_needed()
-- Now check if everything is as expected
assert.spy(KSR.pv.sets).was.called_with( "$rU", "021112345" )
assert.spy(KSR.hdr.append).was.called_with("Privacy: id")
end)
end)
42. Test it
spec/headers_spec.lua
require 'busted.runner'()
local headers = require "../kamailio/headers"
describe("Check and enable CLIR ->", function()
it("Caller dials *31021112345", function()
-- Call the function
headers.suppress_cid_if_needed()
-- Now check if everything is as expected
assert.spy(KSR.pv.sets).was.called_with( "$rU", "021112345" )
assert.spy(KSR.hdr.append).was.called_with("Privacy: id")
end)
end)
43. Test it
spec/headers_spec.lua
require 'busted.runner'()
local headers = require "../kamailio/headers"
describe("Check and enable CLIR ->", function()
it("Caller dials *31021112345", function()
-- Call the function
headers.suppress_cid_if_needed()
-- Now check if everything is as expected
assert.spy(KSR.pv.sets).was.called_with( "$rU", "021112345" )
assert.spy(KSR.hdr.append).was.called_with("Privacy: id")
end)
end)
44. Test it
spec/headers_spec.lua
require 'busted.runner'()
local headers = require "../kamailio/headers"
describe("Check and enable CLIR ->", function()
it("Caller dials *31021112345", function()
-- Call the function
headers.suppress_cid_if_needed()
-- Now check if everything is as expected
assert.spy(KSR.pv.sets).was.called_with( "$rU", "021112345" )
assert.spy(KSR.hdr.append).was.called_with("Privacy: id")
end)
end)
45. Fix your tests
require 'busted.runner'()
local function init_mock(options)
-- mock global variable 'KSR'
local ksr_mock = {
pv = {
get = function(key)
if key == "$rU" then
if options.rU ~= nil then return options.rU else return "01234567" end
end
end,
sets = function(k, v) end,
},
hdr = {
append = function(header) end,
}
}
_G["KSR"] = mock(ksr_mock)
local message_mock = {
is_invite = function() return options.is_invite end
}
_G["message"] = mock(message_mock)
end
local headers = require "kamailio/headers"
[..]
46. Fix your tests
require 'busted.runner'()
local function init_mock(options)
-- mock global variable 'KSR'
local ksr_mock = {
pv = {
get = function(key)
if key == "$rU" then
if options.rU ~= nil then return options.rU else return "01234567" end
end
end,
sets = function(k, v) end,
},
hdr = {
append = function(header) end,
}
}
_G["KSR"] = mock(ksr_mock)
local message_mock = {
is_invite = function() return options.is_invite end
}
_G["message"] = mock(message_mock)
end
local headers = require "kamailio/headers"
[..]
47. Fix your tests
require 'busted.runner'()
local function init_mock(options)
-- mock global variable 'KSR'
local ksr_mock = {
pv = {
get = function(key)
if key == "$rU" then
if options.rU ~= nil then return options.rU else return "01234567" end
end
end,
sets = function(k, v) end,
},
hdr = {
append = function(header) end,
}
}
_G["KSR"] = mock(ksr_mock)
local message_mock = {
is_invite = function() return options.is_invite end
}
_G["message"] = mock(message_mock)
end
local headers = require "kamailio/headers"
[..]
48. Fix your tests
require 'busted.runner'()
local function init_mock(options) [..] end
describe("Check and enable CLIR ->", function()
it("Caller dials *31021112345", function()
-- Initialize the mock
init_mock{ rU = "*31021112345", is_invite = true }
-- Call the function
headers.suppress_cid_if_needed()
-- Now check if everything is as expected
assert.spy(KSR.pv.sets).was.called_with("$rU", "021112345")
assert.spy(KSR.hdr.append).was.called_with("Privacy: id")
end)
end)
49. Fix your tests
require 'busted.runner'()
local function init_mock(options) [..] end
describe("Check and enable CLIR ->", function()
it("Caller dials *31021112345", function()
-- Initialize the mock
init_mock{ rU = "*31021112345", is_invite = true }
-- Call the function
headers.suppress_cid_if_needed()
-- Now check if everything is as expected
assert.spy(KSR.pv.sets).was.called_with("$rU", "021112345")
assert.spy(KSR.hdr.append).was.called_with("Privacy: id")
end)
end)
50. Fix your tests
require 'busted.runner'()
local function init_mock(options) [..] end
describe("Check and enable CLIR ->", function()
it("Caller dials *31021112345", function()
-- Initialize the mock
init_mock{ rU = "*31021112345", is_invite = true }
-- Call the function
headers.suppress_cid_if_needed()
-- Now check if everything is as expected
assert.spy(KSR.pv.sets).was.called_with("$rU", "021112345")
assert.spy(KSR.hdr.append).was.called_with("Privacy: id")
end)
end)
56. Fix your code
kamailio/headers.lua
rex = require "rex_pcre"
message = require "kamailio.message"
local headers = {}
function headers.get_request_user()
return KSR.pv.get("$rU")
end
function headers.set_request_user(value)
KSR.pv.sets("$rU", value)
end
function headers.set_privacy_header()
KSR.hdr.append("Privacy: id")
end
function headers.suppress_cid_if_needed()
request_user = headers.get_request_user()
if rex.find(request_user, "^*31([#]|%23)?") then
headers.set_request_user(rex.gsub(request_user, "^*31([#]|%23)?", ""))
if message.is_invite() then headers.set_privacy_header() end
end
end
return headers
57. Fix your code
kamailio/headers.lua
rex = require "rex_pcre"
message = require "kamailio.message"
local headers = {}
function headers.get_request_user()
return KSR.pv.get("$rU")
end
function headers.set_request_user(value)
KSR.pv.sets("$rU", value)
end
function headers.set_privacy_header()
KSR.hdr.append("Privacy: id")
end
function headers.suppress_cid_if_needed()
request_user = headers.get_request_user()
if rex.find(request_user, "^*31([#]|%23)?") then
headers.set_request_user(rex.gsub(request_user, "^*31([#]|%23)?", ""))
if message.is_invite() then headers.set_privacy_header() end
end
end
return headers
58. Fix your code
kamailio/headers.lua
rex = require "rex_pcre"
message = require "kamailio.message"
local headers = {}
function headers.get_request_user()
return KSR.pv.get("$rU")
end
function headers.set_request_user(value)
KSR.pv.sets("$rU", value)
end
function headers.set_privacy_header()
KSR.hdr.append("Privacy: id")
end
function headers.suppress_cid_if_needed()
request_user = headers.get_request_user()
if rex.find(request_user, "^*31([*#]|%23)?") then
headers.set_request_user(rex.gsub(request_user, "^*31([*#]|%23)?", ""))
if message.is_invite() then headers.set_privacy_header() end
end
end
return headers
59. Fix your code
kamailio/headers.lua
rex = require "rex_pcre"
message = require "kamailio.message"
local headers = {}
function headers.get_request_user()
return KSR.pv.get("$rU")
end
function headers.set_request_user(value)
KSR.pv.sets("$rU", value)
end
function headers.set_privacy_header()
KSR.hdr.append("Privacy: id")
end
function headers.suppress_cid_if_needed()
request_user = headers.get_request_user()
if rex.find(request_user, "^*31([*#]|%23)?") then
headers.set_request_user(rex.gsub(request_user, "^*31([*#]|%23)?", ""))
if message.is_invite() then headers.set_privacy_header() end
end
end
return headers