<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9031922773224056133</id><updated>2026-03-29T15:14:32.277+02:00</updated><category term="debian"/><category term="VoIP"/><category term="webrtc"/><category term="docker"/><category term="perl"/><category term="SIP"/><category term="linux"/><category term="puppet"/><category term="kamailio"/><category term="freeswitch"/><category term="RTP"/><category term="Wireshark"/><category term="python"/><category term="CPAN"/><category term="git"/><category term="opus"/><category term="&quot;Perl Best Practices&quot;"/><category term="MySQL"/><category term="PCAP"/><category term="RTC"/><category term="asterisk"/><category term="audio codecs"/><category term="dh-make-perl"/><category term="pjsip"/><category term="running"/><category term="tdd"/><category term="ubuntu"/><category term="unit testing"/><category term="vim"/><category term="Amazon"/><category term="G.711"/><category term="Hudson"/><category term="Internet"/><category term="Kindle"/><category term="Lua"/><category term="Open Source"/><category term="SILK"/><category term="SRTP"/><category term="STUN"/><category term="TLS"/><category term="WebSocket"/><category term="Windows Mobile"/><category term="astricon"/><category term="continuous integration"/><category term="digitalocean"/><category term="hackathon"/><category term="homer"/><category term="node.js"/><category term="perlcritic"/><category term="sipp"/><category term="software development"/><category term="turn"/><category term="AppStore"/><category term="Audacity"/><category term="Build-Depends-Indep"/><category term="C"/><category term="CANCEL"/><category term="CentOS"/><category term="DTMF"/><category term="Encapsulation"/><category term="Erlang"/><category term="Expectations"/><category term="FOSDEM"/><category term="Facebook"/><category term="G.729"/><category term="ITU"/><category term="Italy"/><category term="Jenkins"/><category term="JsSIP"/><category term="Kubernetes"/><category term="LAST_INSERT_ID"/><category term="Lexicon"/><category term="Literature"/><category term="MS"/><category term="Matrix"/><category term="Microsoft"/><category term="Mnesia"/><category term="PHP"/><category term="PHPUnit"/><category term="POE"/><category term="Programming"/><category term="Putty"/><category term="Putty Session Manager"/><category term="RFC 3261"/><category term="RSA"/><category term="Ruby on Rails"/><category term="SDP"/><category term="Script"/><category term="TADHack"/><category term="TAP::Harness::JUnit"/><category term="Tahar Ben Jelloun"/><category term="Tate"/><category term="Tate Modern"/><category term="Telecom API"/><category term="Test::Harness prove"/><category term="Test::More"/><category term="Verizon"/><category term="Windows MarketPlace for Mobile"/><category term="aliases"/><category term="apt-get"/><category term="base64"/><category term="bash"/><category term="books"/><category term="cell phone"/><category term="clarify"/><category term="cloud computing"/><category term="cluecon"/><category term="conffiles"/><category term="configuration management"/><category term="curl"/><category term="cycling"/><category term="data privacy"/><category term="debchange"/><category term="debian apt madison"/><category term="debian apt puppet"/><category term="debuild"/><category term="development"/><category term="diff"/><category term="dpkg"/><category term="dpkg info"/><category term="dpkg-buildpackage"/><category term="e-readers"/><category term="eclipse"/><category term="economy"/><category term="ejabberd"/><category term="emacs"/><category term="endurance"/><category term="epic"/><category term="freeswitch dtls-srtp voip"/><category term="grep"/><category term="grep-status"/><category term="hashes"/><category term="https"/><category term="iPhone"/><category term="iPod Touch"/><category term="ice"/><category term="iptables"/><category term="janus"/><category term="libpcap"/><category term="life"/><category term="marathon"/><category term="openvpn"/><category term="order of ignorance"/><category term="perl 6"/><category term="pjsua"/><category term="postinst"/><category term="project management"/><category term="prove"/><category term="psychology"/><category term="reading"/><category term="regexp"/><category term="reprepro"/><category term="respoke"/><category term="scapy"/><category term="security"/><category term="sh"/><category term="shell"/><category term="sipsak"/><category term="sociology"/><category term="sox"/><category term="speex"/><category term="sport"/><category term="svn"/><category term="tab completion"/><category term="testing"/><category term="truphone"/><category term="truphone labs"/><category term="twitter"/><category term="vi"/><title type='text'>Giacomo Vacca</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://www.giacomovacca.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default?start-index=26&amp;max-results=25'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>124</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-8310405856546919656</id><published>2026-02-02T11:07:00.001+01:00</published><updated>2026-02-02T11:07:21.966+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="webrtc"/><title type='text'>Understanding WebRTC State Machines</title><content type='html'>&lt;h1&gt;Understanding WebRTC State Machines&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Specific transports, aggregate states, and the Chrome/libwebrtc mental model&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;WebRTC is one of those technologies that appears deceptively simple on the surface. You call &lt;code&gt;createOffer()&lt;/code&gt;, exchange some SDP, and suddenly two browsers are streaming video to each other. But beneath that simplicity lies a set of interlocking state machines that govern every aspect of the connection&#39;s lifecycle—from signaling and ICE candidate exchange to DTLS handshake completion.&lt;/p&gt;

&lt;p&gt;If you&#39;ve ever stared at a WebRTC debugging log wondering why &lt;code&gt;connectionState&lt;/code&gt; reads &lt;code&gt;&quot;connecting&quot;&lt;/code&gt; while &lt;code&gt;iceConnectionState&lt;/code&gt; says &lt;code&gt;&quot;connected&quot;&lt;/code&gt;, this article is for you. The key insight, and the one the Chrome/libwebrtc codebase is built around, is that WebRTC state is organized into two distinct tiers: &lt;b&gt;specific&lt;/b&gt; state machines that live on individual transports, and &lt;b&gt;aggregate&lt;/b&gt; states on &lt;code&gt;RTCPeerConnection&lt;/code&gt; that are derived—computed—from those transports.&lt;/p&gt;

&lt;p&gt;This article walks through each layer in detail, explains how the aggregate states are calculated, and ties it all together with a narrative of a typical connection&#39;s lifetime.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2&gt;The Two-Tier Architecture&lt;/h2&gt;

&lt;p&gt;The easiest mental model for reasoning about Chrome&#39;s WebRTC behavior is to think of it in two layers.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Specific state machines&lt;/b&gt; live on individual transports. Each ICE transport, each DTLS transport, and the SCTP/DataChannel layer maintain their own state, tracking their own progress through their respective protocols independently.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Aggregate states&lt;/b&gt; live on the &lt;code&gt;RTCPeerConnection&lt;/code&gt; object and have no independent transition logic of their own. Instead, they are computed from the set of currently-relevant transports (the active transceivers plus the optional SCTP transport). Think of them as dashboards—read-only views that reduce the complexity of multiple transports into a single summary value using well-defined precedence rules.&lt;/p&gt;

&lt;p&gt;This distinction matters enormously for debugging. When an aggregate state like &lt;code&gt;connectionState&lt;/code&gt; reports &lt;code&gt;&quot;failed&quot;&lt;/code&gt;, the question is never &quot;why did connectionState fail?&quot;—it doesn&#39;t fail on its own. The question is &quot;which specific transport entered the failed state, and why?&quot;&lt;/p&gt;

&lt;hr /&gt;

&lt;h2&gt;The Specific State Machines&lt;/h2&gt;

&lt;h3&gt;SDP/JSEP Signaling State&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;signalingState&lt;/code&gt; property tracks the progress of the offer/answer exchange—and nothing else. It is a common misconception that signaling state reflects connectivity. It does not. A peer connection can be in &lt;code&gt;signalingState: &quot;stable&quot;&lt;/code&gt; and have no working media path whatsoever; &quot;stable&quot; simply means that the last offer/answer round-trip has completed successfully.&lt;/p&gt;

&lt;p&gt;The signaling states are:&lt;/p&gt;

&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;State&lt;/th&gt;&lt;th&gt;Meaning&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;stable&lt;/code&gt;&lt;/td&gt;&lt;td&gt;No offer/answer in progress; the default and resting state.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;have-local-offer&lt;/code&gt;&lt;/td&gt;&lt;td&gt;A local offer has been set, awaiting a remote answer.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;have-remote-offer&lt;/code&gt;&lt;/td&gt;&lt;td&gt;A remote offer has been received, awaiting a local answer.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;have-local-pranswer&lt;/code&gt;&lt;/td&gt;&lt;td&gt;A local provisional answer has been set.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;have-remote-pranswer&lt;/code&gt;&lt;/td&gt;&lt;td&gt;A remote provisional answer has been received.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;closed&lt;/code&gt;&lt;/td&gt;&lt;td&gt;The peer connection has been shut down.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Every state can transition to &lt;code&gt;closed&lt;/code&gt; when &lt;code&gt;close()&lt;/code&gt; is called. The key transitions to remember are: calling &lt;code&gt;setLocalDescription(offer)&lt;/code&gt; from &lt;code&gt;stable&lt;/code&gt; moves to &lt;code&gt;have-local-offer&lt;/code&gt;, and receiving the remote answer returns to &lt;code&gt;stable&lt;/code&gt;. The same pattern holds symmetrically for the answering side.&lt;/p&gt;

&lt;blockquote&gt;&lt;b&gt;Key Takeaway:&lt;/b&gt; &lt;code&gt;signalingState&lt;/code&gt; is purely about offer/answer progress. It tells you nothing about whether ICE has found a path or DTLS has completed its handshake.&lt;/blockquote&gt;

&lt;h3&gt;ICE Transport State&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;RTCIceTransport.state&lt;/code&gt; property is where the real connectivity story lives. Each ICE transport independently manages candidate pair checks, consent verification, and failure detection.&lt;/p&gt;

&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;State&lt;/th&gt;&lt;th&gt;Meaning&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;new&lt;/code&gt;&lt;/td&gt;&lt;td&gt;The transport exists but has not begun checking candidates.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;checking&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Candidate pair checks are underway.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;connected&lt;/code&gt;&lt;/td&gt;&lt;td&gt;A viable pair has been selected, though additional checks may still run.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;completed&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Gathering is done, end-of-candidates has been signaled, and a final pair is selected.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;disconnected&lt;/code&gt;&lt;/td&gt;&lt;td&gt;A transient loss of connectivity; the transport is still trying to recover.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;failed&lt;/code&gt;&lt;/td&gt;&lt;td&gt;All checks are exhausted and no working pair could be established.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;closed&lt;/code&gt;&lt;/td&gt;&lt;td&gt;The transport has been shut down.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;What makes the ICE state machine interesting—and occasionally surprising—are its &lt;b&gt;back edges&lt;/b&gt;. Unlike a simple linear progression, ICE can move backwards:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;b&gt;connected → checking:&lt;/b&gt; When consent is revoked on the active pair, the transport drops back to re-check alternatives.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;completed → checking:&lt;/b&gt; An ICE restart (triggered by renegotiation) resets a completed transport back to checking.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;connected → disconnected:&lt;/b&gt; A transient network interruption moves the transport to disconnected, from which it may recover or eventually fail.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;disconnected → checking:&lt;/b&gt; If new candidate pairs become available during a disconnected period, the transport re-enters checking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These back edges are critical for understanding connection lifetime. A connection that appears &quot;stable&quot; in the completed state can regress to checking during an ICE restart, and a brief network blip can trigger a disconnected → checking → connected cycle without the user ever noticing.&lt;/p&gt;

&lt;blockquote&gt;&lt;b&gt;Debugging Tip:&lt;/b&gt; The &lt;code&gt;disconnected&lt;/code&gt; state is transient by design. If you see it in logs, wait before concluding there&#39;s a problem—ICE may be in the process of recovering. The &lt;code&gt;failed&lt;/code&gt; state is the terminal one to watch for.&lt;/blockquote&gt;

&lt;h3&gt;DTLS Transport State&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;RTCDtlsTransport.state&lt;/code&gt; property tracks the DTLS handshake that secures the media path. It is comparatively simple—a mostly linear progression from &lt;code&gt;new&lt;/code&gt; through &lt;code&gt;connecting&lt;/code&gt; to &lt;code&gt;connected&lt;/code&gt;, with &lt;code&gt;failed&lt;/code&gt; as the error terminal.&lt;/p&gt;

&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;State&lt;/th&gt;&lt;th&gt;Meaning&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;new&lt;/code&gt;&lt;/td&gt;&lt;td&gt;The DTLS handshake has not started.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;connecting&lt;/code&gt;&lt;/td&gt;&lt;td&gt;The DTLS handshake is in progress.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;connected&lt;/code&gt;&lt;/td&gt;&lt;td&gt;The handshake completed and the fingerprint was verified.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;failed&lt;/code&gt;&lt;/td&gt;&lt;td&gt;The handshake failed (e.g., fingerprint mismatch, DTLS alert).&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;closed&lt;/code&gt;&lt;/td&gt;&lt;td&gt;The transport has been shut down via close_notify or peer connection closure.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Failure in DTLS is almost always a security-related event: a certificate fingerprint mismatch (which can indicate a man-in-the-middle attempt or an SDP error), a DTLS alert, or a timeout during the handshake. Unlike ICE, DTLS has no recovery path from failure—once it fails, the transport is done.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2&gt;The Aggregate (Derived) States&lt;/h2&gt;

&lt;p&gt;The aggregate states on &lt;code&gt;RTCPeerConnection&lt;/code&gt; exist as a convenience for application developers. Rather than requiring you to iterate over every transport and compute the overall status yourself, the spec defines derivation rules that collapse the individual transport states into summary values. There are three aggregate states to understand.&lt;/p&gt;

&lt;h3&gt;Aggregate ICE Connectivity: iceConnectionState&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;iceConnectionState&lt;/code&gt; property is computed from the set of all currently-relevant ICE transports using the following precedence rules, evaluated in order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;closed&lt;/code&gt; — if the peer connection itself is closed.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;failed&lt;/code&gt; — if any ICE transport is in the failed state.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;disconnected&lt;/code&gt; — if any ICE transport is disconnected.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;new&lt;/code&gt; — if all ICE transports are new or closed (or none exist).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;checking&lt;/code&gt; — if any ICE transport is new or checking.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;completed&lt;/code&gt; — if all ICE transports are completed or closed.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;connected&lt;/code&gt; — if all ICE transports are connected, completed, or closed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The precedence ordering is important. Notice that &lt;code&gt;failed&lt;/code&gt; dominates: a single failed transport poisons the entire aggregate, regardless of how many other transports are healthy. Similarly, &lt;code&gt;disconnected&lt;/code&gt; takes precedence over positive states. This is a &quot;worst-case-wins&quot; model.&lt;/p&gt;

&lt;p&gt;One subtlety worth noting: when ICE transports are created or discarded due to signaling changes—bundle policy changes, RTCP multiplexing adjustments, or adding new media lines—the aggregate state can &quot;jump&quot; forward without any individual transport changing state. A new transceiver added mid-session can momentarily pull the aggregate back to &lt;code&gt;checking&lt;/code&gt; even if existing transports are all connected.&lt;/p&gt;

&lt;h3&gt;Overall Session State: connectionState&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;connectionState&lt;/code&gt; property is the highest-level health indicator on &lt;code&gt;RTCPeerConnection&lt;/code&gt;. It combines the aggregate ICE connection state with the DTLS transport states. Its precedence rules are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;closed&lt;/code&gt; — if the ICE aggregate is closed.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;failed&lt;/code&gt; — if the ICE aggregate is failed &lt;b&gt;or&lt;/b&gt; any DTLS transport has failed.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;disconnected&lt;/code&gt; — if the ICE aggregate is disconnected.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;new&lt;/code&gt; — if the ICE aggregate is new and all DTLS transports are new or closed (or no transports exist).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;connected&lt;/code&gt; — if the ICE aggregate is connected and all DTLS transports are connected or closed.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;connecting&lt;/code&gt; — otherwise (the catch-all bucket).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is the state that explains the puzzle from the introduction. &lt;code&gt;connectionState&lt;/code&gt; can read &lt;code&gt;&quot;connecting&quot;&lt;/code&gt; even when &lt;code&gt;iceConnectionState&lt;/code&gt; shows &lt;code&gt;&quot;connected&quot;&lt;/code&gt; because the DTLS handshake hasn&#39;t finished yet. The ICE path is established, but the secure channel over that path is still being negotiated. Since neither the &lt;code&gt;failed&lt;/code&gt; nor &lt;code&gt;disconnected&lt;/code&gt; rules apply, and DTLS isn&#39;t yet &lt;code&gt;connected&lt;/code&gt;, the catch-all &lt;code&gt;connecting&lt;/code&gt; state kicks in.&lt;/p&gt;

&lt;blockquote&gt;&lt;b&gt;Key Takeaway:&lt;/b&gt; &lt;code&gt;connectionState = &quot;connected&quot;&lt;/code&gt; means both ICE has found a working path &lt;em&gt;and&lt;/em&gt; DTLS has completed its handshake. It is the definitive signal that the media channel is fully operational.&lt;/blockquote&gt;

&lt;h3&gt;Aggregate ICE Gathering: iceGatheringState&lt;/h3&gt;

&lt;p&gt;Separate from connectivity, the &lt;code&gt;iceGatheringState&lt;/code&gt; tracks candidate gathering progress across all transports. It follows a simple progression: &lt;code&gt;new&lt;/code&gt; → &lt;code&gt;gathering&lt;/code&gt; → &lt;code&gt;complete&lt;/code&gt;. It can return to &lt;code&gt;gathering&lt;/code&gt; if new network interfaces or STUN/TURN servers become available. In practice, with trickle ICE, the gathering state often reaches &lt;code&gt;complete&lt;/code&gt; well before the ICE connectivity state finishes checking all pairs.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2&gt;A Connection&#39;s Lifetime&lt;/h2&gt;

&lt;p&gt;Tying all these state machines together, here is the typical progression of a successful WebRTC connection from offer to media flow:&lt;/p&gt;

&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Layer&lt;/th&gt;&lt;th&gt;State Progression&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Signaling&lt;/td&gt;&lt;td&gt;stable → have-local-offer → stable (after answer)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ICE Gathering (agg.)&lt;/td&gt;&lt;td&gt;new → gathering → complete&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ICE Transport&lt;/td&gt;&lt;td&gt;new → checking → connected → completed&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ICE Connection (agg.)&lt;/td&gt;&lt;td&gt;new → checking → connected / completed&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;DTLS Transport&lt;/td&gt;&lt;td&gt;new → connecting → connected&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Connection (agg.)&lt;/td&gt;&lt;td&gt;new → connecting → connected&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Notice the ordering: signaling completes first (the offer/answer exchange), then ICE gathering begins. As candidates trickle in, ICE connectivity checks start. Once ICE finds a viable pair (&lt;code&gt;connected&lt;/code&gt;), DTLS begins its handshake over that path. Only when DTLS also reaches &lt;code&gt;connected&lt;/code&gt; does the aggregate &lt;code&gt;connectionState&lt;/code&gt; finally report &lt;code&gt;&quot;connected&quot;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;During this progression, there is an inevitable window where ICE is connected but DTLS is still negotiating. This is normal and expected. The aggregate &lt;code&gt;connectionState&lt;/code&gt; will show &lt;code&gt;&quot;connecting&quot;&lt;/code&gt; during this window—not because anything is wrong, but because the derivation rules correctly reflect that the full secure channel is not yet established.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2&gt;Practical Debugging Advice&lt;/h2&gt;

&lt;p&gt;Armed with an understanding of the two-tier architecture, here are some practical principles for debugging WebRTC connections.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Always drill down from aggregate to specific.&lt;/b&gt; When &lt;code&gt;connectionState&lt;/code&gt; or &lt;code&gt;iceConnectionState&lt;/code&gt; shows something unexpected, don&#39;t try to reason about why the aggregate changed. Instead, inspect the individual &lt;code&gt;RTCIceTransport&lt;/code&gt; and &lt;code&gt;RTCDtlsTransport&lt;/code&gt; objects to find which specific transport triggered the change.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Respect the back edges.&lt;/b&gt; ICE is not a one-way street. Consent revocation, ICE restarts, and transient network issues can all cause state regressions. Build your connection-monitoring logic to handle backwards transitions gracefully, especially the &lt;code&gt;connected → disconnected → checking → connected&lt;/code&gt; cycle.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Distinguish transient from terminal.&lt;/b&gt; The &lt;code&gt;disconnected&lt;/code&gt; state is transient; &lt;code&gt;failed&lt;/code&gt; is terminal. Don&#39;t show error UI on disconnected—give ICE a chance to recover. Reserve error handling for the &lt;code&gt;failed&lt;/code&gt; state, or for disconnected states that persist beyond a reasonable timeout.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Remember what connectionState = &quot;connected&quot; actually means.&lt;/b&gt; It means ICE has a working path &lt;em&gt;and&lt;/em&gt; DTLS has completed its handshake. If you need to know that media can flow securely, this is the state to watch—not &lt;code&gt;iceConnectionState&lt;/code&gt; alone.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Watch for aggregate jumps from signaling changes.&lt;/b&gt; Adding a new transceiver or changing bundle policy mid-session can cause aggregate states to shift even when no individual transport changed. If your state-monitoring code triggers unexpectedly during renegotiation, this is likely why.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;WebRTC&#39;s state management is a layered system. Specific state machines on individual transports do the real work of establishing connectivity and security. Aggregate states on &lt;code&gt;RTCPeerConnection&lt;/code&gt; provide a convenient summary by applying precedence rules across the set of active transports. Understanding this two-tier architecture—and especially the derivation rules that connect them—is the key to reasoning confidently about WebRTC connection lifecycle, debugging unexpected state transitions, and building robust real-time communication applications.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2&gt;References&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;W3C, &lt;em&gt;WebRTC: Real-Time Communication in Browsers&lt;/em&gt; (W3C Recommendation). &lt;a href=&quot;https://www.w3.org/TR/webrtc/&quot;&gt;https://www.w3.org/TR/webrtc/&lt;/a&gt;. Sections referenced: RTCSignalingState enum, RTCIceConnectionState derivation, RTCPeerConnectionState derivation, RTCIceGatheringState, and non-normative signaling transition diagrams.&lt;/li&gt;
&lt;li&gt;MDN Web Docs, &lt;em&gt;RTCIceTransport: state property&lt;/em&gt;. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/RTCIceTransport/state&quot;&gt;https://developer.mozilla.org/en-US/docs/Web/API/RTCIceTransport/state&lt;/a&gt;. Referenced for per-transport ICE state definitions and back-edge transition descriptions.&lt;/li&gt;
&lt;li&gt;MDN Web Docs, &lt;em&gt;RTCDtlsTransport: state property&lt;/em&gt;. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/RTCDtlsTransport/state&quot;&gt;https://developer.mozilla.org/en-US/docs/Web/API/RTCDtlsTransport/state&lt;/a&gt;. Referenced for DTLS transport state definitions and failure conditions.&lt;/li&gt;
&lt;li&gt;IETF RFC 8829, &lt;em&gt;JavaScript Session Establishment Protocol (JSEP)&lt;/em&gt;. &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc8829&quot;&gt;https://www.rfc-editor.org/rfc/rfc8829&lt;/a&gt;. Background reference for the offer/answer model and SDP handling that drives signalingState transitions.&lt;/li&gt;
&lt;li&gt;IETF RFC 8445, &lt;em&gt;Interactive Connectivity Establishment (ICE)&lt;/em&gt;. &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc8445&quot;&gt;https://www.rfc-editor.org/rfc/rfc8445&lt;/a&gt;. Background reference for ICE candidate pair checking, consent verification, and the state model underlying RTCIceTransport.&lt;/li&gt;
&lt;li&gt;IETF RFC 6347, &lt;em&gt;Datagram Transport Layer Security Version 1.2&lt;/em&gt;. &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc6347&quot;&gt;https://www.rfc-editor.org/rfc/rfc6347&lt;/a&gt;. Background reference for the DTLS handshake and alert mechanisms underlying RTCDtlsTransport.&lt;/li&gt;
&lt;/ol&gt;

&lt;hr&gt;

&lt;p&gt;&lt;em&gt;This article was written in collaboration with GPT-5.2 and Claude Opus 4.5. The technical research and notes were developed with GPT-5.2, and the article was drafted and formatted with Claude Opus 4.5.&lt;/em&gt;&lt;/p&gt;
</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/8310405856546919656'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/8310405856546919656'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2026/02/understanding-webrtc-state-machines.html' title='Understanding WebRTC State Machines'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-527510556796856490</id><published>2025-12-21T20:29:00.005+01:00</published><updated>2025-12-21T20:29:25.981+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Lua"/><category scheme="http://www.blogger.com/atom/ns#" term="RTP"/><category scheme="http://www.blogger.com/atom/ns#" term="Wireshark"/><title type='text'>A rudimentary dissector for Wireshark (Lua)</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;a href=&quot;https://wiki.wireshark.org/&quot; target=&quot;_blank&quot;&gt;Wireshark&lt;/a&gt; offers a simple but effective option to extend its capabilities, by using &lt;a href=&quot;https://wiki.wireshark.org/lua/dissectors&quot; target=&quot;_blank&quot;&gt;Lua dissectors&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Just to give an example, recently received a pcap file containing some traffic (it was RTP) encapsulated inside a UDP header. The reason for encapsulation was transporting over a VPN.&lt;/p&gt;&lt;p&gt;I&#39;m in such a habit to look into RTP streams on Wireshark, that I have a setting that tells it to try an interpret any UDP packet automatically as carrying RTP (&lt;a href=&quot;https://www.giacomovacca.com/2024/07/wireshark-setting-to-interpret-udp-as.html&quot; target=&quot;_blank&quot;&gt;I wrote how here&lt;/a&gt;). That also failed.&lt;/p&gt;&lt;p&gt;So Wireshark was not able to interpret those frames as RTP (or anything else, for what matters), and I remembered time ago writing a custom dissector. Wireshark allows to do that simply in Lua and add it as a plugin.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://gist.github.com/giavac/cdd414035b187ea3a40e70835bbc2449&quot; target=&quot;_blank&quot;&gt;The code is available here&lt;/a&gt;. I just had to make it available inside &#39;$HOME/.local/lib/wireshark/plugins/`.&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/527510556796856490'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/527510556796856490'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2025/12/a-rudimentary-dissector-for-wireshark.html' title='A rudimentary dissector for Wireshark (Lua)'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-6751946853143661294</id><published>2025-11-20T22:05:00.006+01:00</published><updated>2025-12-21T20:08:07.601+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="life"/><category scheme="http://www.blogger.com/atom/ns#" term="marathon"/><category scheme="http://www.blogger.com/atom/ns#" term="running"/><title type='text'>It&#39;s not a sprint</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;You’ve surely heard at least once in your life somebody saying “Calm down: it’s not a sprint, it’s a marathon”.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;People use this phrase to try and slow things down, but it misses the point.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;The first misconception is that a marathon is something you do slowly. A marathon is fast; it’s just as fast as possible for that athlete in that moment.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Most people couldn’t hold an elite marathoner’s pace for even 100 meters. It’s a marathon, but it’s not slow.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;It’s easy to make a point that running a marathon is tough, not just for the distance but for the speed you try to keep.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;What’s maybe harder to see is that a marathon is much easier than many life challenges.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;You can simply prepare for a marathon. You get to the starting line with months or years of preparation. You tried progressively longer and tougher sessions, simulating the marathon effort. That’s a privilege. Many hurdles you’ll face in life will just appear in front of you while you were thinking of something else.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;A marathon has a fixed length and a fixed course that’s known in advance. Life challenges are typically faced only once, making you very unprepared.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;You can run the same marathon many years in a row, each time learning something more about that specific event. In life, it’s never clear when a challenge will end. Or if it will end.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Nobody tries to make you fail at completing a marathon, apart, I guess, very rare exceptions. That’s not the case for many life endeavours.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;You can quit a marathon. Nobody will blame you for it. There’s basically no risk that somebody will be harmed if you fail.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;If you try to run in the wrong direction, somebody will likely tell you and help you get back on track. In life, you’d be lucky if somebody even notices. And the ones who notice may just stay quiet.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;And finally the only way a marathon can disappoint you is if you have unrealistic expectations. People can disappoint you even if the expectations are modest.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;So maybe next time somebody will tell you “Calm down: it’s not a sprint, it’s a marathon” you’ll want to answer “You wish”.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-feature-settings: normal; font-kerning: auto; font-optical-sizing: auto; font-size-adjust: none; font-size: 13px; font-stretch: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-variation-settings: normal; line-height: normal; margin: 0px; min-height: 15px; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/6751946853143661294'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/6751946853143661294'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2025/11/its-not-sprint.html' title='It&#39;s not a sprint'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-6977376266802993694</id><published>2025-03-12T10:27:00.005+01:00</published><updated>2025-12-21T18:34:26.877+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Audacity"/><category scheme="http://www.blogger.com/atom/ns#" term="SRTP"/><category scheme="http://www.blogger.com/atom/ns#" term="Wireshark"/><title type='text'>Decrypt SDES SRTP from pcap</title><content type='html'>&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;If you have a pcap file with encrypted RTP (SDES SRTP) and have access to the SIP signalling to see the keys, these instructions will help you decrypt the RTP payload and save it as raw audio. Optionally, depending on the codec, you can then import the raw audio in Wireshark and save it as an audio file.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt; text-align: left;&quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Steps&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 400; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Build ‘srtp-decrypt’&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;These are the steps:&lt;/span&gt;&lt;/p&gt;&lt;span id=&quot;docs-internal-guid-1b932483-7fff-875a-2c74-e49f72cb80be&quot;&gt;&lt;ol style=&quot;margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px; text-align: left;&quot;&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: decimal; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Build ‘srtp-decrypt’&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: decimal; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Get crypto key for each direction&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: decimal; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Use the decrypt.sh bash script to decrypt into raw audio&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: decimal; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Import the raw audio into Wireshark as hex dump&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: decimal; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Generate the wav file&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: decimal; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Generate the wav file as two separate channels, one per direction&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Follow instructions here:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;a href=&quot;https://github.com/gteissier/srtp-decrypt&quot; style=&quot;text-decoration-line: none;&quot;&gt;&lt;span style=&quot;color: #1155cc; font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-decoration-line: underline; text-decoration-skip-ink: none; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;https://github.com/gteissier/srtp-decrypt&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Assume the binary will be produced in a path like ‘/root/code/srtp-decrypt/srtp-decrypt’&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;h3 style=&quot;line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 400; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Get crypto key for each direction&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Access the SIP involved and take note of the ‘crypto’ line from the SDP for each direction.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;e.g.:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;v=0&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-style: italic; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-style: italic; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;m=audio 16398 RTP/SAVP 96 8 97&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-style: italic; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;c=IN IP4 xxxxx&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-style: italic; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-style: italic; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:K7oAZZ5Fm9fePS5/t1ac00000000000000000000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;...&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; white-space-collapse: preserve;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;The crypto key for the RTP stream produced by this party is &lt;/span&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 700; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;K7oAZZ5Fm9fePS5/t1ac00000000000000000000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;h3 style=&quot;line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 400; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Use a bash script to decrypt into raw audio&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Use this simple bash script to perform the actual decryption:&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;set -x&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;SRTP_DECRYPT_BIN=/root/code/srtp-decrypt/srtp-decrypt&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;HEADER_SIZE=48&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;CRYPTO_KEY=5eKSVpIOePOgjjfep21R3b000000000000000000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;RTP_PCAP=outbound.pcap&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;RAW_DATA=outbound.raw&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;${SRTP_DECRYPT_BIN} -d ${HEADER_SIZE} -k ${CRYPTO_KEY} &amp;lt; ${RTP_PCAP} &amp;gt; ${RAW_DATA}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Where:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;CRYPTO_KEY&lt;/span&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt; needs the value of the crypto key seen earlier.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;RTP_PCAP&lt;/span&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt; has the pcap with the RTP stream that you want to decrypt.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;RAW_DATA&lt;/span&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt; is the output file where to put the decrypted raw audio.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;HEADER_SIZE&lt;/span&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt; may vary, depending on the presence of the SLL header in the capture.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; font-weight: 400; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Import the raw audio into Wireshark as hex dump&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;In Wireshark:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px; text-align: left;&quot;&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;File → Import from Hex Dump&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Select the file with the raw audio&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Offsets: Hexadecimal&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Timestamp format: %M:%S.%f&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Encapsulation type: Ethernet&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;UDP: source port 10000, destination port 20000&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Import&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Then go to:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px; text-align: left;&quot;&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Telephony → RTP → RTP Streams&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Play&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Select stream&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Export as Synchronised audio file&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;If for example you have two RTP streams, one per direction for the same call, you can generate the wav file with two separate channels, one per direction.&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;Once you have the raw audio for both directions, you can use Audacity (&lt;/span&gt;&lt;a href=&quot;https://www.audacityteam.org/&quot; style=&quot;text-decoration-line: none;&quot;&gt;&lt;span style=&quot;color: #1155cc; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-decoration-line: underline; text-decoration-skip-ink: none; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;https://www.audacityteam.org/&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; vertical-align: baseline; white-space-collapse: preserve;&quot;&gt;) to import the audio.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul style=&quot;margin-bottom: 0px; margin-top: 0px; padding-inline-start: 48px; text-align: left;&quot;&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Open the first file.&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;File → Import Audio for the second file.&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Select the first audio, right click, “Set as Stereo file”&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li aria-level=&quot;1&quot; style=&quot;font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; list-style-type: disc; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;p role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-variant-alternates: normal; font-variant-east-asian: normal; font-variant-emoji: normal; font-variant-numeric: normal; font-variant-position: normal; text-wrap-mode: wrap; vertical-align: baseline;&quot;&gt;Save&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-family: inherit; white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;span style=&quot;white-space-collapse: preserve;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/6977376266802993694'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/6977376266802993694'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2025/03/decrypt-sdes-srtp-from-pcap.html' title='Decrypt SDES SRTP from pcap'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-5721597201957102007</id><published>2024-07-11T16:01:00.003+02:00</published><updated>2025-12-21T18:32:13.511+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="RTP"/><category scheme="http://www.blogger.com/atom/ns#" term="webrtc"/><category scheme="http://www.blogger.com/atom/ns#" term="Wireshark"/><title type='text'>Wireshark setting to interpret UDP as RTP automatically</title><content type='html'>&lt;p&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Before I forget again, a Wireshark setting that can help saving time by trying to interpret any UDP as RTP, if possible:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Analyze --&amp;gt; Enabled Protocols... --&amp;gt; Search for RTP and enable at least &#39;rtp_udp&#39;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Without that change, when SIP signalling is not present (or it&#39;s encrypted) Wireshark would not understand automatically that UDP packets may be RTP.&lt;/p&gt;&lt;p&gt;This is particularly true for example for WebRTC calls, where signalling happens elsewhere and is not available to Wireshark.&lt;/p&gt;&lt;p&gt;This will also save the reader some time if you&#39;re used to right click and &#39;Decode As...&#39; to achieve the same.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/5721597201957102007'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/5721597201957102007'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2024/07/wireshark-setting-to-interpret-udp-as.html' title='Wireshark setting to interpret UDP as RTP automatically'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-6676521369880459231</id><published>2022-10-27T13:32:00.005+02:00</published><updated>2025-12-21T17:36:14.313+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ice"/><category scheme="http://www.blogger.com/atom/ns#" term="STUN"/><category scheme="http://www.blogger.com/atom/ns#" term="turn"/><category scheme="http://www.blogger.com/atom/ns#" term="webrtc"/><title type='text'>About ICE negotiation</title><content type='html'>&lt;p&gt;&lt;i&gt;Disclaimer: I wrote this article on March 2022 while working with Subspace, and the original link is here:&amp;nbsp;&lt;a href=&quot;https://subspace.com/resources/ice-negotiation&quot;&gt;https://subspace.com/resources/ice-negotiation&lt;/a&gt; . This post in my personal blog is a way to ensure it doesn&#39;t get lost. There is nothing service-specific in it, I&#39;ve made only minor edits and I hope it can be a good technical reference on the topic.&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://webrtc.org/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;WebRTC&lt;/a&gt; is a set of protocols that allow applications, typically running on Web browsers, to exchange media (audio, video, data) with other entities.&lt;/p&gt;&lt;div&gt;Before media can flow, however, the WebRTC entities need to discover what type of connection is possible, and among the possible connections, what’s the best to be used. This needs to happen as fast as possible, so that users can perceive the service as instantaneous as possible.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;WebRTC includes protocols like &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc8489.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;STUN&lt;/a&gt; and &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc8656.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;TURN&lt;/a&gt; that are designed to facilitate the establishment of connections when a direct connection is not possible. The typical case is a computer inside a home or office network, with a private IP address, and able to reach the public Internet only through an address translation (NAT).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;span&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;STUN helps in discovering the IP address and port from where a computer enters the Internet, and in some circumstances that IP address and port can be used by other entities to reach that computer. STUN is also used for keeping such bindings alive.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;TURN provides a way for two entities to communicate when they are behind two different symmetric NATs, or when one is behind a firewall that restricts outbound traffic to only some UDP or TCP ports. TURN uses STUN as the underlying protocol, adding requests, responses and indications to accomplish media relay.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;STUN and TURN play a role in the ICE negotiation process. &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc8445.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;ICE&lt;/a&gt;, Interactive Connectivity Establishment, is a protocol that allows the dynamic discovery of the best way to establish a connection for entities that may be behind NAT.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;All WebRTC clients use ICE before media can flow.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There are three main phases: the gathering of candidates, the connectivity checks, and the nomination of the candidate pairs to be used.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The ICE candidates are simply transport addresses (IP address, port and transport type) that can potentially be used to communicate (send and receive media) and that the ICE client collects and shares to the other party through some form of signalling.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There are three main types of ICE candidates: &#39;host&#39;, &#39;server reflexive&#39; and &#39;relay&#39;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&#39;host&#39; candidates refer to transport addresses that are directly visible by the client, where the client can start listening for incoming connections or packets. Computers behind NAT may only have private IP addresses as &#39;host&#39; candidates, but they are potentially usable if the other party belongs to the same network, or depending on the type of NAT.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&#39;server reflexive&#39; candidates are the ones discovered through the interaction with a STUN server. The client sends a Binding Request to the STUN server and receives a Binding Success Response with a MAPPED-ADDRESS containing the source IP address and port from where the request was received. There may be more than one level of NAT, and that transport address represents the outmost one.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&#39;relay&#39; candidates refer to allocations reserved on a TURN server. The ICE client requests an Allocation of a relay, and after successful authentication the TURN server provides a RELAYED-ADDRESS containing the transport address allocated on that server for the client.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;These types of ICE candidates have different priorities, &#39;host&#39; being at highest priority and &#39;relay&#39; at lowest priority; this is a way to privilege direct interconnection when possible (but that not necessarily represents the best solution in terms of connection quality and in general of Quality Of Experience).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This diagrams shows a typical process where ICE candidates are gathered and sent to the other party:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEggwl-Sj6Y1GTc5HrjnW1SGdPynvBM8Vu5r6pLZY9fUIuiaD3tHbzyrAA-RZx0hKgyzFhxa11FLPRF9Mn8FLpXB4yXH3uO1100qou2o4hXg434BSjTchT10sXpQIDuNpuQVdxwGkg1mfFxTJtfDPnge3PxbPdpUq9kMjiY1d1XuF2DrA9IWBvQub18U&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;393&quot; data-original-width=&quot;694&quot; height=&quot;226&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEggwl-Sj6Y1GTc5HrjnW1SGdPynvBM8Vu5r6pLZY9fUIuiaD3tHbzyrAA-RZx0hKgyzFhxa11FLPRF9Mn8FLpXB4yXH3uO1100qou2o4hXg434BSjTchT10sXpQIDuNpuQVdxwGkg1mfFxTJtfDPnge3PxbPdpUq9kMjiY1d1XuF2DrA9IWBvQub18U=w400-h226&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In this example the candidates are communicated as soon as they are retrieved. This technique is called &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc8838.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Trickle ICE&lt;/a&gt; and was designed to ensure that the connectivity checks can happen as soon as the candidates are available.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Without Trickle ICE, the WebRTC client would need to wait for all the candidates to be collected before sending an offer or an answer, increasing the session set up time.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The candidates are transmitted over a signalling system established between the two parties. This is outside of the WebRTC specifications and application-specific.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The WebRTC client will then receive the ICE candidates from the other party, and it will build a list of “candidate pairs”: each local candidate will be paired with each remote candidate.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After this operation the connectivity checks can begin.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let’s see it with an example, assuming UDP as transport for all cases. The WebRTC client has a local host candidate, IP1:port1, and has received a remote host candidate, IP2:port2. It builds a “candidate pair” with the two: {IP1:port1, IP2:port2}.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The WebRTC client will start sending STUN Binding Requests with source IP1:port1 and destination IP2:port2. These requests use STUN short-term authentication, and contain a username and password that were previously exchanged when transmitting the candidates inside the SDP offer/answer.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If the Binding Request reaches the other party on IP2:port2, then the other party will authenticate the request, and respond with a Binding Success Response, including the MAPPED-ADDRESS attribute, containing the source of the request.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If the Binding Success Response reaches the WebRTC client, then it will identify the request by looking into the transaction ID and mark the check as Successful, and so suitable for exchanging media.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If for any reason the Binding Success Response is not received, then the candidate pair will remain in a In Progress state for some time, and then move to Failed: that pair cannot be used to exchange media.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEimhErTpOE6gUIaqvV3E-1JrrBi277LhHrt6cxFlHFYJzy0sRtS6tF15ri-Ys0rRcbiA98DJJPvwOnoQdx001wLgfKlJyzoTGmhrT8sIkoGkuMH3z9sir47-kjqmRQDIGroCfxZpF6TNr_rcAPtNs3qThL1iSCkh0-_fMWqh_SGjrWAIhzNiIWINEO5&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;333&quot; data-original-width=&quot;694&quot; height=&quot;154&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEimhErTpOE6gUIaqvV3E-1JrrBi277LhHrt6cxFlHFYJzy0sRtS6tF15ri-Ys0rRcbiA98DJJPvwOnoQdx001wLgfKlJyzoTGmhrT8sIkoGkuMH3z9sir47-kjqmRQDIGroCfxZpF6TNr_rcAPtNs3qThL1iSCkh0-_fMWqh_SGjrWAIhzNiIWINEO5&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It’s important to note that this is symmetrical: the other party too can start the connectivity check from IP2:port2 towards IP1:port1. To avoid a conflict, the parties assume the role of &quot;controlling&quot; or &quot;controlled&quot; agent. The controlling agent will be the one deciding which candidate pair will be used for exchanging media.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Before media can flow through a TURN server, a client must create a Permission. This is important during ICE connectivity checks.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For ICE candidates of type &#39;relay&#39;, the connectivity check will be performed sending Binding Requests that traverse the TURN server and reach the other party on the relay side. The Binding Requests will be carried by a Send Indication, destined to the remote candidate as peer address. The TURN server will only accept it and relay it to the destination if a Permission has been granted for that peer.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiBAgdScgI0iNtx3nNry-9cfiksVA7By2MPVo-RaYXsP-6SdjTz3lIoe4nxJwtC3YtS0NyUnnO8h6uBpT7YCSHSbGXy4tXaY6tFie_rnXVSvnB5AbqV23PHo3C3AOp3qZpmbsZUYmog1FvMoZli1urMfDO7C-RL8XXC7WNVYfYSoPeu6HMXHe886Xmi&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;359&quot; data-original-width=&quot;694&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiBAgdScgI0iNtx3nNry-9cfiksVA7By2MPVo-RaYXsP-6SdjTz3lIoe4nxJwtC3YtS0NyUnnO8h6uBpT7YCSHSbGXy4tXaY6tFie_rnXVSvnB5AbqV23PHo3C3AOp3qZpmbsZUYmog1FvMoZli1urMfDO7C-RL8XXC7WNVYfYSoPeu6HMXHe886Xmi=w400-h208&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;(NAT has been omitted in this diagram for simplicity)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Of course a TURN allocation must exist for the CreatePermission request to succeed, but that’s already been created during the candidate gathering phase.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If the candidate pair selected for exchanging media will be one with a local &#39;relay&#39; candidate, then typically the WebRTC client binds a TURN Channel to the other party, and starts exchanging media using ChannelData messages, instead of Send/Data Indications.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There are more details that can be discussed, like managing timeouts, role conflicts, ICE Lite, etc, which we will address in other articles. One additional aspect is important here: we mentioned three types of candidates, host, server reflexive and relayed, but there’s a fourth one, &quot;peer reflexive&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Peer reflexive candidates are not provided directly by a party during candidate exchange, but are instead discovered dynamically during the connectivity checks. Getting back to the previous example with a candidate pair {IP1:port1, IP2:port2}, depending on NAT conditions, the response to the Bind Request from IP1:port1 can be received by another source, IP3:port3.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The WebRTC client can verify IP3:port3 is sending a valid response by checking the transaction ID, and if successful it will dynamically add a remote candidate of type peer reflexive. Sometimes the peer reflexive candidate is the only one suitable and will be used to exchange media.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Chrome’s chrome://webrtc-internals, Firefox’s about:webrtc and Safari&#39;s &quot;WebRTC Logging&quot; will show the list of candidates and the pair that was selected, so those tools are of great value when troubleshooting.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you take a trace on the computer running the WebRTC client, you’ll be able to see the STUN Binding Requests and Responses, and CreatePermission, Send/Data Indications for connectivity checks if unencrypted TURN is used. Wireshark will filter those messages for you if you use the ‘stun’ filter, and will also be able to interpret the Binding Request/Response carried inside Send/Data Indications (and also the RTP streams, but that’s for another article).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you&#39;re interested about troubleshooting TURN sessions, take a look at this other article, &lt;a href=&quot;https://www.giacomovacca.com/2022/05/troubleshooting-turn.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&quot;Troubleshooting TURN&quot;&lt;/a&gt;.&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/6676521369880459231'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/6676521369880459231'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2022/10/about-ice-negotiation.html' title='About ICE negotiation'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEggwl-Sj6Y1GTc5HrjnW1SGdPynvBM8Vu5r6pLZY9fUIuiaD3tHbzyrAA-RZx0hKgyzFhxa11FLPRF9Mn8FLpXB4yXH3uO1100qou2o4hXg434BSjTchT10sXpQIDuNpuQVdxwGkg1mfFxTJtfDPnge3PxbPdpUq9kMjiY1d1XuF2DrA9IWBvQub18U=s72-w400-h226-c" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-5260487434300856944</id><published>2022-05-16T17:29:00.002+02:00</published><updated>2025-12-21T17:36:54.865+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="turn"/><category scheme="http://www.blogger.com/atom/ns#" term="webrtc"/><title type='text'>Troubleshooting TURN</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;WebRTC applications use the &lt;a href=&quot;https://datatracker.ietf.org/doc/html/rfc8445&quot; target=&quot;_blank&quot;&gt;ICE negotiation&lt;/a&gt; to discovery the best way to communicate with a remote party. I&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; white-space: pre-wrap;&quot;&gt;t dynamically finds a pair of candidates (IP address, port and transport, also known as “transport address”) suitable for exchanging media and data.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The most important aspect of this is “dynamically”: a local and a remote transport address are found based on the network conditions at the time of establishing a session. For example, a WebRTC client that normally uses a server reflexive transport address to communicate with an SFU. when running inside the home office, may use a relay transport address over TCP when running inside an office network which limits remote UDP targets. The same configuration (defined as “iceServers” when creating an &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection&quot; target=&quot;_blank&quot;&gt;RTCPeerConnection&lt;/a&gt; will work in both cases, producing different outcomes.&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;This means that a certain portion of WebRTC sessions happen over TURN, i.e. they are relayed through a TURN service, when the choice is left to the client. ‘host’, ‘server reflexive’ and ‘relay’ candidates are left to compete with each other, and the best will win, with the caveat that ‘host’ candidates have the highest priority, and ‘relay’ the lowest. This prioritization originates from the logical assumption that a relayed connection may be less performant than a direct one.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;There are cases though when using a TURN service is not optional, but mandatory; an RTCPeerConfiguration setting, ‘iceTransportPolicy’ allows this.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In any case, when TURN is used, it’s important to be able to troubleshoot the session establishment, and this article aims to provide some important guidelines.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;These are the key points:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;Acquiring the TURN settings&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;Confirming the reachability of the TURN server&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;Creating a relay allocation on the TURN server&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;Setting permissions for using the created allocations&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;Exchanging ICE connectivity checks over TURN&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;Exchanging media and/or data over TURN&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;h1 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 20pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Acquiring the TURN settings&lt;/span&gt;&lt;/h1&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;While STUN servers are typically used without the need for authentication, it’s unlikely that a TURN service can. The resources involved in a TURN service are expensive, in particular in the case of highly scalable and distributed systems, and for this reason are only allowed for authenticated customers.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The required TURN settings are:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;A URL (in the form ‘turn:&amp;lt;FQDN or IP address&amp;gt;:port)&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;An username&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;A password (called ‘credential’)&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;These are provided inside the ‘iceServers’ configuration structure passed to the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection&quot; target=&quot;_blank&quot;&gt;RTCPeerConnection&lt;/a&gt; at the moment of creation.&lt;/span&gt;&lt;/p&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Troubleshooting points&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;It’s important to verify that the TURN settings are correctly configured; in Chrome, open Developer Tools and check in the JavaScript code that the ‘iceServers’ structure contains valid values.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Check also the ‘iceTransportPolicy’ (which default value is ‘all’).&lt;/span&gt;&lt;/p&gt;&lt;h1 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 20pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Confirming the reachability of the TURN server&lt;/span&gt;&lt;/h1&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;When the ICE candidates gathering phase begins, the ICE client verifies that the TURN URL defines a reachable service by sending a STUN Binding Request towards the IP and port resolved from the ‘iceServer’ settings.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;This request originates from the IP address and port that will be used to access the TURN service, and so it will check that it’s suitable for it.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;If the STUN Binding Request is received by the TURN server, then it will respond with a STUN Binding Success, carrying an attribute (XOR-MAPPED-ADDRESS) that tells what source IP and port was seen by the server.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;If the STUN Binding Success response is received by the client, then there’s proof that the TURN server is reachable.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;For example:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikQ32P8qmYtE674lYrVTte9nV1pjjX3c2OHKqiVIJ-6tCtHf38YFONiFV3sYrIYYeIwCXuZVZJXVqAmQwMt250GEy_hjuC5KD6e2zQXQGqSIQ2BwbhlsyAfhYoK6h5Byn-BdPcGUDsMdsOkw2FjViwM2noY5QNylabvY5_r6nG_IrZt5fvUk9U19Tb/s2968/binding.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;178&quot; data-original-width=&quot;2968&quot; height=&quot;38&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikQ32P8qmYtE674lYrVTte9nV1pjjX3c2OHKqiVIJ-6tCtHf38YFONiFV3sYrIYYeIwCXuZVZJXVqAmQwMt250GEy_hjuC5KD6e2zQXQGqSIQ2BwbhlsyAfhYoK6h5Byn-BdPcGUDsMdsOkw2FjViwM2noY5QNylabvY5_r6nG_IrZt5fvUk9U19Tb/w640-h38/binding.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Now it’s possible to negotiate a relay allocation.&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt; text-align: left;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Troubleshooting points&lt;/span&gt;&lt;/h3&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In the host running the WebRTC client, take a network trace and verify that the STUN Binding Request is addressed to the expected destination (in particular if the TURN URL required a DNS resolution and so there are multiple IP addresses that could be used).&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Verify in the trace that the STUN Binding Success Response is received.&lt;/span&gt;&lt;/p&gt;&lt;h1 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 20pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Creating a relay allocation on the TURN server&lt;/span&gt;&lt;/h1&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;This is the key element: the client asks the TURN server to become a relay on its behalf.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Here the TURN protocol is used, and the client issues an Allocate Request towards the TURN server. This request must be authenticated, for the reasons discussed earlier, and so it’s challenged with a 401 Unauthenticated response, carrying a realm and a nonce.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The client will use the provided credentials (username and credential), together with the given realm and nonce, to compute a MESSAGE-INTEGRITY attribute and send again the Allocate Request with this attribute.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;If the credentials are correct (and also the user is allowed to access the service), then the TURN service will reserve a transport address for that allocation: this is the relay transport address. An Allocate Success Response is transmitted to the client, with a XOR-RELAYED-ADDRESS attribute.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;At this point the client has gained a ‘relay’ candidate and transmits it to the remote party through the signalling system in use (this is service-specific and not standardized).&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Here’s an example of a successful allocation:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgoqN1Z7BWWitbEctb4ehc3of4PUEa4uGM0NNsEGwfIlnRLlHE1htxDS4A3NGiN3ry-FGQ2H9PrMTWRLkjOCofVWWhelMRhXSR3aWGf5OhWOmi1K3oSed-rTDQPPaiV2d6eCnmphzdzhwIA33lhZzJyrJmY0MjCcHid6pfh1p04g-uQ4sS67LTshbG/s3350/allocate_ok.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;192&quot; data-original-width=&quot;3350&quot; height=&quot;36&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgoqN1Z7BWWitbEctb4ehc3of4PUEa4uGM0NNsEGwfIlnRLlHE1htxDS4A3NGiN3ry-FGQ2H9PrMTWRLkjOCofVWWhelMRhXSR3aWGf5OhWOmi1K3oSed-rTDQPPaiV2d6eCnmphzdzhwIA33lhZzJyrJmY0MjCcHid6pfh1p04g-uQ4sS67LTshbG/w640-h36/allocate_ok.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Note that a client may create more than one allocation for the same session; each one will be identified by a different source port, so it will be easily identifiable. You can filter them out with something like ‘stun and udp.port==PORT`, where PORT is the client source port for a transaction you’re interested in.&lt;/span&gt;&lt;/p&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Troubleshooting points&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In the host running the WebRTC client, take a network trace and confirm that there’s an Allocate Success Response.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;h3 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #434343; font-family: Arial; font-size: 14pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Wrong credentials&lt;/span&gt;&lt;/h3&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In case of wrong credentials, instead of an Allocate Success Response you’ll see another 401 Unauthenticated response. In this case you must check that the credentials are correct, and the user is authorized to access the service.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaJxvYurO9wz179vsDOKUuvDnuQjkcqMm7kkeJp7PuPzBgO1aGCpCjWqAPaaSKaao7dnHKqFhKdFp3PRlwjR185vcoUWaKr0zjU4u2wItyzmg6L_pTC5CjuP7frkW6eREDKRKNGgvpcZ6TVYT3uly5Jhc3Xg2mLmN1O-KYJQ2LxzJttMItgwioUxAD/s3140/allocation_401.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;224&quot; data-original-width=&quot;3140&quot; height=&quot;46&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaJxvYurO9wz179vsDOKUuvDnuQjkcqMm7kkeJp7PuPzBgO1aGCpCjWqAPaaSKaao7dnHKqFhKdFp3PRlwjR185vcoUWaKr0zjU4u2wItyzmg6L_pTC5CjuP7frkW6eREDKRKNGgvpcZ6TVYT3uly5Jhc3Xg2mLmN1O-KYJQ2LxzJttMItgwioUxAD/w640-h46/allocation_401.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #434343; font-family: Arial; font-size: 14pt; white-space: pre-wrap;&quot;&gt;Other errors for Allocate Request&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Any other error for the Allocate Request will have a detailed error code (in a similar fashion as HTTP or SIP have), so take a note on that and search for its root cause.&lt;/span&gt;&lt;/p&gt;&lt;h1 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 20pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Setting permissions for using the created allocations&lt;/span&gt;&lt;/h1&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;For security reasons, before media or data is exchanged through the relay, the client must set specific permissions for the remote party.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Once the client has a valid relay allocation, every time it receives an ICE candidate from the remote it must set a permission for the remote IP address.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;This is accomplished with a TURN CreatePermission Request. The allocation the permission refers to is implicit from the client source IP address and port. The TURN server will respond with a CreatePermission Success if the request is accepted; note that often a client receives ICE candidates with private or reserved IP addresses: in that case the TURN server will most probably reject the request with a 403 Forbidden response.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Example:&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8iv1VHLyvLMhV6_pHYI6sfwbqu3tX14yLR9HoRAR8ZUsTgJPHpWZAsRoscgrjP4JK6iLVZ18gBN7vt8Bd_veiCjlIVtplhBxNyBjFC4RyfRFl0OWNJ-gnPxxGYgdpgFyOARiK6WK2fDuEdY_VIERGrKI5pajLDZcno2uBdJiZbI8OGDGaqcGXplAe/s3480/permissions.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;174&quot; data-original-width=&quot;3480&quot; height=&quot;32&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8iv1VHLyvLMhV6_pHYI6sfwbqu3tX14yLR9HoRAR8ZUsTgJPHpWZAsRoscgrjP4JK6iLVZ18gBN7vt8Bd_veiCjlIVtplhBxNyBjFC4RyfRFl0OWNJ-gnPxxGYgdpgFyOARiK6WK2fDuEdY_VIERGrKI5pajLDZcno2uBdJiZbI8OGDGaqcGXplAe/w640-h32/permissions.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; white-space: pre-wrap;&quot;&gt;Troubleshooting points&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In the host running the WebRTC client, take a network trace and confirm that there’s a CreatePermission Success for at least one of the remote candidates.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;If no CreatePermission requests are sent, or none of them is successfully accepted, then no relaying will be possible.&lt;/span&gt;&lt;/p&gt;&lt;h1 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 20pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Exchanging ICE connectivity checks over TURN&lt;/span&gt;&lt;/h1&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Once the TURN server is reached, a relay allocation reserved and a permission created, there are the conditions for exchanging ICE connectivity checks over TURN.&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;These are performed by sending STUN &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc8489#section-9.1&quot; target=&quot;_blank&quot;&gt;Binding Requests with short term credentials&lt;/a&gt;; the peculiarity with TURN is that these Binding Requests are encapsulated inside a TURN Send Indication, addressed to the remote peer.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Wireshark will nicely solve this encapsulation for you, and instead of showing a Send Indication will show you its content, the Binding Request.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The TURN server will relay the Binding Request to the remote peer, performing the relay for the first time. The expected outcome is that the remote entity will respond with a Binding Success, which the TURN server will encapsulate inside a Data Indication and deliver to the client.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;If that happens, then the client has learned that the remote candidate is indeed reachable via TURN and that’s a suitable candidate pair for exchanging media and data.&lt;/span&gt;&lt;/p&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Troubleshooting points&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In the host running the WebRTC client, take a network trace and confirm that there are Binding Requests carried over TURN that receive a Binding Success.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;If Binding Success responses are not received, then something is preventing it and the best way to investigate is to take network traces on the TURN server host, if possible. Those traces will tell you whether the Binding Requests are correctly leaving the TURN server towards the remote party and whether the Binding Success responses are being received or not.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;It’s possible that the remote endpoint is simply unreachable from the TURN service, and in this case the ICE candidates pair will be marked as unusable.&lt;/span&gt;&lt;/p&gt;&lt;h1 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 20pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Exchanging media and/or data over TURN&lt;/span&gt;&lt;/h1&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The last fundamental step is the actual exchange of packets through the relay. The typical type of packets is RTP.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Once the connectivity checks will be successful, if the client has elected the relay candidate as the one to be used, then RTP can start flowing. You’ll be able to see the RTP packets flowing in both directions, typically with video and audio multiplexed.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;There are two ways for transmitting data:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;Indications&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li dir=&quot;ltr&quot; style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; list-style-type: disc; margin-left: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;p dir=&quot;ltr&quot; role=&quot;presentation&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline;&quot;&gt;Channels&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-size: 14.6667px; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;A Send Indication carries the data (RTP) and destination from the client to the TURN server. The TURN server, granted the allocation exists and the permission allows it, will extract the data and send it to the destination from the allocated relay transport address.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;When the data arrives from the remote peer to the relay transport address, then the TURN server, after performing the above checks, will encapsulate the data inside a Data Indication and send it to the client.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;There is a more efficient way though to exchange data: the client can define a Channel (through the ChannelBind request), which associates a channel ID to a remote party. From that moment both the client and the TURN server can exchange data via ChannelData messages carrying just the channel ID and data, omitting the remote transport address. This reduces the network and computing overhead and it is typically chosen against the use of Indications.&lt;/span&gt;&lt;/p&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Troubleshooting points&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In the host running the WebRTC client, take a network trace and confirm that data is being sent from the client with Send Indications or ChannelData messages, and to the client with Data Indications and ChannelData messages.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;In case of monodirectional media, it’s advisable to take network traces on the TURN server host to clarify whether the media is being exchanged or not on the relay side with the remote peer.&lt;/span&gt;&lt;/p&gt;&lt;h1 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 20pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Encrypted TURN&lt;/span&gt;&lt;/h1&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;It’s possible to use TURN over TLS, with all the data exchanged encrypted. In this case using Wireshark as described won’t allow you to see the details of the requests and responses, and troubleshooting is harder.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;One possible approach is to first of all ensure that all the operations described previously happen correctly when using unencrypted TURN (over UDP or TCP). It’s very likely that the TURN service you are using is accessible over unencrypted UDP (default behavior): before moving to TLS ensure UDP works fine.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Wireshark will show you anyway the TLS connections established with the server, so that will confirm whether the connection was successful, the TLS session established, and some application data exchanged.&lt;/span&gt;&lt;/p&gt;&lt;h1 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 20pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 20pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Useful tools&lt;/span&gt;&lt;/h1&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Wireshark&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;a href=&quot;https://www.wireshark.org/download.html&quot; target=&quot;_blank&quot;&gt;Wireshark&lt;/a&gt; is available for a variety of platforms; it’s a fundamental tool to understand what’s happening between the local WebRTC client and the remote server.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;It comes with filters that detect the type of packets. You can use `stun` to filter out STUN and TURN packets, and even select specific TURN transactions, like `stun.type.method==0x0003` to show Allocate Request and Responses.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Saving a trace into a pcap file and making it available to others helps enormously the ability to troubleshoot.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Wireshark can be used for both capturing and just displaying captures.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;There are cases where the dissectors, i.e. the interpreters of the packets, don’t recognize a TURN transaction. For example this happens when they happen over a non-default port (3478 for UDP and TCP, 5349 for TLS). To “help” Wireshark, right click on a packet, select “Decode As…” and set ‘STUN’ as protocol: it will correctly interpret all the packets using that non-default port.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The same applies for RTP: when signalling is not available to Wireshark, then UDP packets containing RTP may not be correctly interpreted. Use the same “Decode As…” method.&lt;/span&gt;&lt;/p&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;tcpdump&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;On the server side, any tool for packet capture would do, with &lt;a href=&quot;https://www.tcpdump.org/&quot; target=&quot;_blank&quot;&gt;tcpdump&lt;/a&gt; being a common solution.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Save the trace into a pcap file with the `-w` option, e.g. `tcpdump -n -v -w trace_1.pcap`, copy it to your machine and use Wireshark to display the packets.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;WebRTC samples, Trickle ICE&lt;/span&gt;&lt;/h2&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;This &lt;a href=&quot;https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/&quot; target=&quot;_blank&quot;&gt;open source tool&lt;/a&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;allows you to verify the browser can correctly gather `relay` candidates with the given TURN server details (URL, username, credential).&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Before troubleshooting a client implementation, ensure that this tool can correctly access the TURN resources you’re referring to.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;turnutils_uclient&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The popular open source implementation of a TURN server, coturn, comes with a &lt;a href=&quot;https://github.com/coturn/coturn/blob/master/README.turnutils&quot; target=&quot;_blank&quot;&gt;tool&lt;/a&gt; that simulates a client. A plethora of options are available, allowing you to test specific aspects of the TURN operations, e.g. using Send Indications or using Channels, etc.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Use `turnutils_uclient` to ensure the TURN service you want to use is accessible correctly with the given TURN settings, You’ll also get information about the round trip time and jitter.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Chrome webrtc-internals&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;When using Chrome, the best way to understand what’s happening is to open a tab on chrome://webrtc-internals/. It will show you all the information related to each RTCPeerConnection being managed by the browser at that point, including the list of ICE candidates, the details of the TURN server being used (except the credential for obvious reasons), including the iceTransportPolicy (‘all’ or ‘relay’), the chosen ICE candidates pair, statistics on media transfer, etc.&lt;/span&gt;&lt;/p&gt;&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot; /&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Search for `relay` candidates and verify the client is able to retrieve them from the TURN service, and whether they are selected as the candidate pair or not.&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 16pt; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Conclusions&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;This article should provide a good checklist for troubleshooting the connection to a TURN service. There is much more to say, in particular for what concerns browsers different than Chrome and server-side investigations: I plan to write about it in the future.&lt;/span&gt;&lt;/p&gt;&lt;h1 style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;yj6qo&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/5260487434300856944'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/5260487434300856944'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2022/05/troubleshooting-turn.html' title='Troubleshooting TURN'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikQ32P8qmYtE674lYrVTte9nV1pjjX3c2OHKqiVIJ-6tCtHf38YFONiFV3sYrIYYeIwCXuZVZJXVqAmQwMt250GEy_hjuC5KD6e2zQXQGqSIQ2BwbhlsyAfhYoK6h5Byn-BdPcGUDsMdsOkw2FjViwM2noY5QNylabvY5_r6nG_IrZt5fvUk9U19Tb/s72-w640-h38-c/binding.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-2219551049909265370</id><published>2021-03-11T11:01:00.001+01:00</published><updated>2025-12-21T20:09:08.473+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cycling"/><category scheme="http://www.blogger.com/atom/ns#" term="endurance"/><category scheme="http://www.blogger.com/atom/ns#" term="running"/><category scheme="http://www.blogger.com/atom/ns#" term="sport"/><title type='text'>Differences between running and cycling</title><content type='html'>&lt;p&gt;&amp;nbsp;I&#39;m a passionate runner, and always considered cycling as something fun, e.g. mountain-biking, but difficult to practice regularly. There&#39;s a lot of overhead in cycling, like the preparation, bike maintenance, dealing with city traffic, etc.&lt;/p&gt;&lt;p&gt;Anyway about eight months ago I bought a road bike and felt in love with it. Soon after that I discovered &lt;a href=&quot;https://zwift.com&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Zwift&lt;/a&gt; and that gave an additional dimension to the sport: practice whenever you want from home, with accurate power measurements and a way to socialise with distant people. That was a game changer.&lt;/p&gt;&lt;p&gt;In five months I cycled 1600 virtual Km and climbed almost 17 virtual Km. Meanwhile my running performance, instead of degrading, improved, and that surprised me.&lt;/p&gt;&lt;p&gt;Anyway what I wanted to write about is a great article I read, &lt;a href=&quot;https://www.researchgate.net/publication/24205037_Physiological_Differences_Between_Cycling_and_Running&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&quot;Physiological Differences Between Cycling and Running&quot;&lt;/a&gt;. It&#39;s a review of articles published in that area. Some conclusions are very interesting.&lt;/p&gt;&lt;p&gt;In general it seems sports medicine is still inconclusive for many aspects, and coaches may still have an advantage by following empirical/heuristic approaches in comparison with research-driven indications.&lt;/p&gt;&lt;p&gt;But more specifically, some notes from the conclusions:&lt;/p&gt;&lt;p&gt;- For the same person, VO2max depends on the speciality (i.e. runners achieve higher values on treadmill than cycle ergometer)&lt;/p&gt;&lt;p&gt;- There seems to be more physiological transfer from running to cycling than the other way around&lt;/p&gt;&lt;p&gt;- Pedalling cadence impacts the metabolic response during cycling, but also during a following run (at least in the short term)&lt;/p&gt;&lt;p&gt;- The Lactate Threshold is lower for athletes when not practicing their speciality, i.e. the Lactate Threshold depends on the training method&lt;/p&gt;&lt;p&gt;- Both female and male are impacted in the same way when comparing VO2max for running and cycling&lt;/p&gt;&lt;p&gt;- Triathletes have similar max Heart Rate when running and cycling, again pointing to the importance of the actual speciality used in training&lt;/p&gt;&lt;p&gt;- The position when cycling makes it harder to breathe&lt;/p&gt;&lt;p&gt;and probably other important elements that I wasn&#39;t able to fully grasp.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/2219551049909265370'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/2219551049909265370'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2021/03/off-topic-differences-between-running.html' title='Differences between running and cycling'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-2236304383459526909</id><published>2021-03-10T11:55:00.002+01:00</published><updated>2021-03-10T11:55:33.755+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="STUN"/><category scheme="http://www.blogger.com/atom/ns#" term="VoIP"/><category scheme="http://www.blogger.com/atom/ns#" term="webrtc"/><title type='text'>Notes on STUN protocol</title><content type='html'>&lt;p&gt;&amp;nbsp;Since I needed to see a few details in the handling of attributes in STUN responses, I thought of going through the whole STUN protocol RFC again and take notes on the most important parts.&lt;/p&gt;&lt;p&gt;I put my notes in some slides, and I&#39;m sharing then in Slideshare in case somebody else may find them useful too:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;485&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;//www.slideshare.net/slideshow/embed_code/key/EfRt24YCe4G6cz&quot; style=&quot;border-width: 1px; border: 1px solid #CCC; margin-bottom: 5px; max-width: 100%;&quot; width=&quot;595&quot;&gt; &lt;/iframe&gt; &lt;div style=&quot;margin-bottom: 5px;&quot;&gt; &lt;strong&gt; &lt;a href=&quot;//www.slideshare.net/GiacomoVacca/stun-protocol&quot; target=&quot;_blank&quot; title=&quot;STUN protocol&quot;&gt;STUN protocol&lt;/a&gt; &lt;/strong&gt; from &lt;strong&gt;&lt;a href=&quot;https://www.slideshare.net/GiacomoVacca&quot; target=&quot;_blank&quot;&gt;Giacomo Vacca&lt;/a&gt;&lt;/strong&gt; &lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/2236304383459526909'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/2236304383459526909'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2021/03/notes-on-stun-protocol.html' title='Notes on STUN protocol'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-4629565785251821398</id><published>2021-02-19T09:45:00.001+01:00</published><updated>2021-02-19T09:45:36.930+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="libpcap"/><category scheme="http://www.blogger.com/atom/ns#" term="pjsip"/><category scheme="http://www.blogger.com/atom/ns#" term="RTP"/><category scheme="http://www.blogger.com/atom/ns#" term="SRTP"/><category scheme="http://www.blogger.com/atom/ns#" term="VoIP"/><title type='text'>Extracting RTP streams from network captures</title><content type='html'>&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px;&quot;&gt;I needed an efficient way to programmatically extract RTP streams from a network capture.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;In addition I wanted to:&lt;/p&gt;&lt;ul class=&quot;ul1&quot;&gt;&lt;li class=&quot;li3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;/span&gt;save each stream into a separate pcap file.&lt;/li&gt;&lt;li class=&quot;li3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;/span&gt;extract SRTP-negotiated keys if present and available in the trace, associating them to the related RTP (or SRTP if the negotiation succeeded) stream.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;Some caveats:&lt;/p&gt;&lt;ul class=&quot;ul1&quot;&gt;&lt;li class=&quot;li3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;/span&gt;In normal conditions the negotiation of SRTP sessions happens via a secure transport, typically SIP over TLS, so the exchanged crypto information may not be available from a simple network capture.&lt;/li&gt;&lt;li class=&quot;li3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;/span&gt;There are ways to extract RTP streams using Wireshark or tcpdump; it’s not necessary to do it programmatically.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;All this said I wrote a small tool (&lt;a href=&quot;https://github.com/giavac/pcap_tool&quot;&gt;https://github.com/giavac/pcap_tool&lt;/a&gt;) that parses a network capture and tries to interpret each packet as either RTP/SRTP or SIP, and does two main things:&lt;/p&gt;&lt;ul class=&quot;ul1&quot;&gt;&lt;li class=&quot;li3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;/span&gt;save each detected RTP/SRTP stream into a dedicated pcap file, which name contains the related SSRC.&lt;/li&gt;&lt;li class=&quot;li3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 12px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&lt;/span&gt;print a summary of the crypto information exchanged, if available.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;With those two elements, it’s then possible to decrypt an SRTP stream, depending on the availability of the exchanged crypto information, and also decode it into audio, depending on the codec.&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;Decryption and decoding is not part of my tool, but can be achieved easily with other tools, like &lt;b&gt;pjsip’s pcaputil&lt;/b&gt;.&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;I might integrate that part into pcap_tool in the future. Again not because it’s strictly necessary, but to start getting more control on the parsing and manipulation. This may reveal to be useful in the future.&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;a href=&quot;https://github.com/giavac/pcap_tool&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;pcap_tool is available here&lt;/a&gt; for anybody interested in using it and may perhaps wish to change or extend some parts.&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;You can just clone it and build it as described in the README.&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;An example output:&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;./pcap_tool -d ../../trace_20210218_1.pcap&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;[…]&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;Extracted 1092 RTP frames&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Detected RTP Stream: 0x7a2179fa&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Source port:22248 - Destination port:4000 - Packets: 544 (./stream-0x7a2179fa.pcap)&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Detected RTP Stream: 0x772dc5d7&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Source port:4000 - Destination port:22248 - Packets: 548 (./stream-0x772dc5d7.pcap)&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;source port: 22248 - tag: 3 - suite: AES_CM_128_HMAC_SHA1_80 - key: /1TI6DJWHk7fBJY1yBp7L51uEz1JJ2n6CcQAAsJM&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;-----&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;source port: 4000 - tag: 4 - suite: AES_CM_128_HMAC_SHA1_32 - key: mPytX24bRmyNgMaqQSxP8dMMqdkkmQeHgC2Ttb3v&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;source port: 4000 - tag: 3 - suite: AES_CM_128_HMAC_SHA1_80 - key: J1YS1owJDKAFdq5cRF+JtektYDf6IiowCAeijeal&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;source port: 4000 - tag: 2 - suite: AES_256_CM_HMAC_SHA1_32 - key: 5A9R8O8MCzbuGvJ08WWNJcNHsPaEcEp1ZDp5DunknZ+bZ2JQaVpZ2qmqraTmgQ==&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;source port: 4000 - tag: 1 - suite: AES_256_CM_HMAC_SHA1_80 - key: ZcZn1IY++2xsSIk/U1GsHSGp+OI/BYIocv/40ldJB28bcNeMmYzs4z4ozrNQ5Q==&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;-----&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;That network capture contained 2 SRTP streams, which have been saved separately into &lt;b&gt;stream-0x7a2179fa.pcap&lt;/b&gt; and &lt;b&gt;stream-0x772dc5d7.pcap&lt;/b&gt;&amp;nbsp;files respectively.&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;For the negotiation it’s visible what the sender from port 22248 (owner of the 0x7a2179fa stream) used as crypto information, and looking at the same tag (3 in this case) it’s possible to see what crypto information was used by the sender of 0x772dc5d7 stream from port 4000.&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;With this it’s possible to decrypt (and decode since G.711 was used) with pjsip’s pcaputil with something like:&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;&lt;i&gt;pcaputil -c AES_CM_128_HMAC_SHA1_80 -k /1TI6DJWHk7fBJY1yBp7L51uEz1JJ2n6CcQAAsJM stream-0x7a2179fa.pcap stream-0x7a2179fa.wav&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;and have the audio from that stream into a WAV file.&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;How to build pcaputil (in fact all pjsip’s applications) is widely documented but I also described it in the appendix of &lt;a href=&quot;https://www.giacomovacca.com/2020/11/testing-sip-platforms-and-pjsip.html&quot;&gt;&lt;span class=&quot;s2&quot; style=&quot;color: #dca10d;&quot;&gt;https://www.giacomovacca.com/2020/11/testing-sip-platforms-and-pjsip.html&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p3&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px;&quot;&gt;The call in the example was generated in fact with pjsua.&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot; style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; margin: 0px; min-height: 15px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/4629565785251821398'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/4629565785251821398'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2021/02/extracting-rtp-streams-from-network.html' title='Extracting RTP streams from network captures'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-2767873427584427777</id><published>2020-12-04T09:52:00.000+01:00</published><updated>2020-12-04T09:52:09.264+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SIP"/><title type='text'>SIP - Connection reuse vs Persistent connection</title><content type='html'>&lt;p&gt;It goes without saying that SIP solutions are impacted by NAT. So much that some scenarios required integration to &lt;a href=&quot;https://tools.ietf.org/html/rfc3261&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;RFC 3261&lt;/a&gt;, e.g. with &lt;a href=&quot;https://tools.ietf.org/html/rfc3581&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;RFC 3581&lt;/a&gt;, which defined the &#39;&lt;i&gt;rport&lt;/i&gt;&#39; attribute to be added in the Via header (integrating the &#39;&lt;i&gt;received&lt;/i&gt;&#39; attribute): with that information, responses could be routed to the source port of the related request, and not on the advertised port in the original Via.&lt;/p&gt;&lt;p&gt;That was called &lt;b&gt;Symmetric Response&lt;/b&gt;, and applied to connection-less transports (UDP), while, as mentioned in &lt;a href=&quot;https://tools.ietf.org/html/rfc6314&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;RFC 6314&lt;/a&gt;, it&#39;s not necessary when using reliable transports (TCP in most cases): SIP responses can be sent back on the same connection on which the request arrived.&lt;/p&gt;&lt;p&gt;Also from RFC 3261, chapter 18, Transport layer, client behaviour:&lt;/p&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;blockquote&gt;&quot;For reliable transports, the response is normally sent on the connection on which the request was received.&quot;&lt;/blockquote&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;But the client needs to be prepared to receive the response on a new connection:&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;blockquote&gt;&quot;[...] the transport layer MUST also be prepared to receive an incoming connection on the source IP address from which the request was sent and port number in the &quot;sent-by&quot; field.&quot;&lt;/blockquote&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;That obviously would require the ability to create such connection from the server to the client.&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;Anyway when a reliable connection between two SIP entities is up, after a transaction is already concluded, there are two interesting opportunities:&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;- Use that same connection for more requests from the client&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;- Use that same connection for more requests from the server&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;where for &quot;client&quot; I refer to the entity that created the connection and sent the initial request, and &quot;server&quot; is the entity that accepted the connection and delivered the response(s).&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;The first case is mentioned in the same chapter on Transport layer:&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;blockquote&gt;&quot;If a request is destined to an IP address, port, and transport to which an existing connection is open, it is RECOMMENDED that this connection be used to send the request, but another connection MAY be opened and used.&quot;&lt;/blockquote&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;This is what&#39;s referred to as &quot;&lt;b&gt;Persistent connection&lt;/b&gt;&quot;, as mentioned in &lt;a href=&quot;https://tools.ietf.org/html/rfc5923&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;RFC 5923&lt;/a&gt;:&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&quot;The SIP protocol includes the notion of a persistent connection&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; [...], which is a mechanisms to insure that&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; responses to a request reuse the existing connection that is&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; typically still available, as well as reusing the existing&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; connections for other requests sent by the originator of the&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; connection.&quot;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The second case (using the same connection from future requests from the server) is instead the subject of RFC 5923, and it is defined as &quot;&lt;b&gt;Connection reuse&lt;/b&gt;&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Once the connection is up, it seems a good opportunistic approach to reuse it, but an important limitation is mandated:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;blockquote&gt;&quot;Unlike TCP, TLS connections can be reused to send requests in the backwards direction since each end can be authenticated when the connection is initially set up.&quot;&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;In other words, only TLS connections formed by exchanging certificates can be reused, because the identities have been mutually verified.&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;The way the client can tell the server that connection reuse is desired is with a new parameter to be added in the Via header: &#39;&lt;i&gt;alias&lt;/i&gt;&#39;.&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;In general, RFC 5923 at chapter 5 clarifies:&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&quot;The act of reusing a connection needs&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; the desired property that requests get delivered in the backwards&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; direction only if they would have been delivered to the same&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; destination had connection reuse not been employed.&quot;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;Last important bit, not to be left implicit: persistent connections don&#39;t imply connection reuse, as RFC 5923 clarifies:&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&quot;[...] Persistent connections do not&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; imply connection reuse.&quot;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So this post is basically sharing my own notes on this topic, which maybe somebody else (including me) can find useful in the future.&lt;/div&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div data-en-clipboard=&quot;true&quot; data-pm-slice=&quot;1 1 []&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/2767873427584427777'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/2767873427584427777'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2020/12/sip-connection-reuse-vs-persistent.html' title='SIP - Connection reuse vs Persistent connection'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-128004288564520346</id><published>2020-11-24T09:54:00.003+01:00</published><updated>2020-12-04T09:54:00.187+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DTMF"/><category scheme="http://www.blogger.com/atom/ns#" term="PCAP"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="RTP"/><category scheme="http://www.blogger.com/atom/ns#" term="scapy"/><title type='text'>Dissecting traces with DTMF tones</title><content type='html'>&lt;p&gt;I&#39;m sure I belong to the large group of people who love to analyse network traces with tools like Wireshark. Being able to see the details of a packet or datagram down to the level of the bits is not only extremely useful, but also fascinating.&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Time ago I wrote a dissector for Wireshark, using the Lua interface, and that was fun (I see it&#39;s still available &lt;a href=&quot;https://github.com/sipcapture/hep-wireshark&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;). &lt;a href=&quot;https://gitlab.com/wireshark/wireshark/-/wikis/Lua&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;The official recommendation&lt;/a&gt;&amp;nbsp;is to use Lua only for prototyping and testing, but when performances are not key and there isn&#39;t the intent to add the dissector to the official distribution, it&#39;s fast and effective.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In order to parse network traces with audio and extract it into the payload first, and then decode it into a WAV file, C is a viable solution. I wrote about &lt;a href=&quot;https://www.giacomovacca.com/2013/06/voip-calls-encoded-with-silk-from-rtp.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;a program that does that here &lt;/a&gt;and since it attracted some attention and feedback I wrote &lt;a href=&quot;https://www.giacomovacca.com/2017/01/voip-calls-encoded-with-silk-from-rtp.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;an updated version later&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;More recently I wanted to identify programmatically the presence (and value) of DTMF tones - as RTP Events, RFC 2833 - in network traces. This time rather than using C, I wanted to integrate it with python, and &lt;a href=&quot;https://scapy.net/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;scapy&lt;/a&gt;&amp;nbsp;seemed a good choice.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;scapy&lt;/i&gt; is quite complete, but interestingly it doesn&#39;t have a parser for the RTP Event extension. So I thought of mapping the raw content in the RTP payload to a structure, with the help of &lt;a href=&quot;https://docs.python.org/3/library/ctypes.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;C types&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This it the core of the program:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;def process_pcap(file_name, sut_ip):&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; for (pkt_data, pkt_metadata,) in RawPcapReader(file_name):&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; ether_pkt = Ether(pkt_data)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; # A little housekeeping to filter IPv4 UDP packets goes here&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; ...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; if ether_pkt.haslayer(UDP):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; udp_pkt = ether_pkt[UDP]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; # Get the raw UDP packet into an RTP structure&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; rtp_pkt = RTP(udp_pkt[&quot;Raw&quot;].load)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; ptype = rtp_pkt.payload_type&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; # Assume payload type 96 or 101 are used for RTP events&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; if (ptype == 96 or ptype == 101):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; rtpevent_content = rtp_pkt.payload&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; # map the payload into an RTPEvent object&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; rtpevent_struct = RTPEvent.from_buffer_copy(rtpevent_content.load)&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The RTPEvent class looks like this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;class RTPEvent(ctypes.BigEndianStructure):&lt;/div&gt;&lt;div&gt;&amp;nbsp; _fields_ = [&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; (&#39;event_id&#39;, ctypes.c_uint8),&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; (&#39;end_of_event&#39;, ctypes.c_uint8, 1),&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; (&#39;reserved&#39;, ctypes.c_uint8, 1),&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; (&#39;volume&#39;, ctypes.c_uint8, 6),&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; (&#39;duration&#39;, ctypes.c_uint16)&lt;/div&gt;&lt;div&gt;&amp;nbsp; ]&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;so once mapped, the &lt;i&gt;rtpevent_struct&lt;/i&gt; object will have its DTMF-specific details, in particular with the digit contained in &lt;i&gt;rtpevent_struct.event_id&lt;/i&gt;, and the indication whether it&#39;s the marker of end of the event in the &lt;i&gt;end_of_event &lt;/i&gt;bit.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;All the other information (source/destination IP address and port, timestamp, SSRC) is obviously available in the UDP and RTP portion, so it&#39;s easy to adapt to your needs and filter out the DTMF tones for the streams you&#39;re interesting in.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/128004288564520346'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/128004288564520346'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2020/11/dissecting-traces-with-dtmf-tones.html' title='Dissecting traces with DTMF tones'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-1848076294167537600</id><published>2020-11-23T10:07:00.002+01:00</published><updated>2020-12-04T09:54:27.974+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Kubernetes"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Kubernetes role-based authorisation for controller applications</title><content type='html'>&lt;p&gt;There are many scenarios where an application running inside a Kubernetes environment may need to interact with its API.&lt;/p&gt;&lt;div&gt;For example, an application running inside a Pod may need to retrieve real time information about the availability of other applications&#39; endpoints.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This may be a form of service discovery that integrates or extend the native Kubernetes internal service discovery. In most cases, DNS records are associated to a Service and provide the list of active Endpoints for that Service, with a proper TTL. There are situations though where those DNS records are not available, an application is not able to use them directly, or what&#39;s needed is more than the private IP addresses associated with the Endpoints.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If interacting with the Kubernetes API from inside an application is needed, then there are two main areas to consider: Authentication and Authorisation.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Every Pod has a Service Account associated to it, and applications running inside that Pod can use that Service Account. Without a specific configuration the Service Account will default to a generic namespace and generic authorisation.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It&#39;s possible instead to define a more specific Service Account, with fine grained permissions to access the API. This Service Account can then be linked to a Pod with a Role-based approach.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;A reference: &lt;a href=&quot;https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account&quot; rev=&quot;en_rl_none&quot;&gt;https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account&lt;/a&gt;/ &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can get a list of available Service Accounts with an intuitive:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;# kubectl get serviceaccounts&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;which is likely to show you a single &#39;default&#39; service.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Service Accounts may have a namespace scope. You can check what Service Accounts are associated to a pod with a command like:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;# kubectl -n NAMESPACE get pods/PODNAME -o yaml | grep serviceAccountName&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Service Account authentication can use the token reachable from inside a Pod, in the &lt;i&gt;/var/run/secrets/kubernetes.io/serviceaccount &lt;/i&gt;directory, under the namespace-specific directory, e.g. &lt;i&gt;/var/run/secrets/kubernetes.io/serviceaccount/NAMESPACE/token.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;Those tokens are also visible as Mounts in the related containers.&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span data-markholder=&quot;true&quot;&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; For internal requests, Kubernetes provides a local default HTTPS endpoint at &lt;i&gt;https://kubernetes.default.svc - &lt;/i&gt; so a way to discover the details of a Service Account for a given namespace could be:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;i&gt;#!/bin/bash&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;# Point to the internal API server hostname&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;APISERVER=https://kubernetes.default.svc&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;# Path to ServiceAccount token&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;SERVICEACCOUNT=/var/run/secrets/kubernetes.io/serviceaccount&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;# Read this Pod&#39;s namespace&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;NAMESPACE=$(cat ${SERVICEACCOUNT}/namespace)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;# Read the ServiceAccount bearer token&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;TOKEN=$(cat ${SERVICEACCOUNT}/token)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;# Reference the internal certificate authority (CA)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;CACERT=${SERVICEACCOUNT}/ca.crt&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;# Explore the API with TOKEN&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;curl --cacert ${CACERT} --header &quot;Authorization: Bearer ${TOKEN}&quot; -X GET ${APISERVER}/api/v1/namespaces/${NAMESPACE}/pods&lt;/i&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;i&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Accessing the internal API programmatically&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With common python libraries as &lt;a href=&quot;https://github.com/kubernetes-client/python&quot; rev=&quot;en_rl_none&quot;&gt;https://github.com/kubernetes-client/python&lt;/a&gt; (available on debian with the &#39;python3-kubernetes&#39; package) it&#39;s extremely easy to automate the invocation of the internal APIs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Most of the examples assume you&#39;re running your program as a user, and refer to the local kube config file, but when running inside a container it&#39;s possible to inherit the Service Account token associated with the hosting Pod.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For this, instead of using &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;config.load_kube_config()&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;use&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;config.load_incluster_config()&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then you can instantiate your API client object:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;v1 = client.CoreV1Api()&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;and either do a single request, like getting a list of all pods inside any namespace:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;ret = v1.list_pod_for_all_namespaces(watch=False)&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;or a list of pods belonging to a namespace and matching a specific application label, like:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;ret = v1.list_namespaced_pod(namespace, label_selector=app_name, watch=False)&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;or you can &quot;watch&quot; some resources, which basically means subscribing to such resource updates and getting a notification at each change:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;w = watch.Watch()&lt;/div&gt;&lt;div&gt;for event in w.stream(v1.list_namespace, _request_timeout=60):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; ...&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Each event can be ADDED, DELETED and MODIFIED, and carries a rich set of information associated to the current status of the resource.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Defining your specific ServiceAccount&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Before getting to that point, though, you need to define your non-default Service Account and assign specific permissions to it. To achieve this, the role-based approach can be used.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First of all define a ServiceAccount resource:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;apiVersion: v1&lt;/div&gt;&lt;div&gt;kind: ServiceAccount&lt;/div&gt;&lt;div&gt;metadata:&lt;/div&gt;&lt;div&gt;&amp;nbsp; labels:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; app.kubernetes.io/component: mycomponent&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; name: mycomponent-serviceaccount&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then define a role associated to this resource:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;apiVersion: rbac.authorization.k8s.io/v1&lt;/div&gt;&lt;div&gt;kind: Role&lt;/div&gt;&lt;div&gt;metadata:&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: myrole&lt;/div&gt;&lt;div&gt;&amp;nbsp; namespace: mynamespace&lt;/div&gt;&lt;div&gt;  labels:&lt;/div&gt;&lt;div&gt;  [...]&lt;/div&gt;&lt;div&gt;  annotations:&lt;/div&gt;&lt;div&gt;  [...]&lt;/div&gt;&lt;div&gt;rules:&lt;/div&gt;&lt;div&gt;[...]&lt;/div&gt;&lt;div&gt;&amp;nbsp; - apiGroups:&lt;/div&gt;&lt;div&gt;&amp;nbsp; - &quot;&quot;&lt;/div&gt;&lt;div&gt;&amp;nbsp; resources:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; - pods&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; - endpoints&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; verbs: [&quot;get&quot;, &quot;list&quot;, &quot;watch&quot;]&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This example adds the permission to get, list, or watch the list of pods and endpoints in the given namespace.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Create a role binding:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;apiVersion: rbac.authorization.k8s.io/v1&lt;/div&gt;&lt;div&gt;kind: RoleBinding&lt;/div&gt;&lt;div&gt;metadata:&lt;/div&gt;&lt;div&gt;  name: myrolebinding&lt;/div&gt;&lt;div&gt;  namespace: mynamespace&lt;/div&gt;&lt;div&gt;  labels:&lt;/div&gt;&lt;div&gt;[...]&lt;/div&gt;&lt;div&gt;  annotations:&lt;/div&gt;&lt;div&gt;[...]&lt;/div&gt;&lt;div&gt;roleRef:&lt;/div&gt;&lt;div&gt;&amp;nbsp; apiGroup: rbac.authorization.k8s.io&lt;/div&gt;&lt;div&gt;&amp;nbsp; kind: Role&lt;/div&gt;&lt;div&gt;&amp;nbsp; name: myrole&lt;/div&gt;&lt;div&gt;subjects:&lt;/div&gt;&lt;div&gt;&amp;nbsp; [...]&lt;/div&gt;&lt;div&gt;&amp;nbsp; - kind: ServiceAccount&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; name: mycomponent-serviceaccount&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; namespace: mynamespace&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Whenever a Role cannot be restricted to a namespace, for example if it needs to access cluster-wide resources like Nodes, then the ClusterRole resource is available.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;References and other sources&lt;/h2&gt;&lt;div&gt;&quot;Access clusters using the Kubernetes API&quot;, https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;An interesting post about asynchronous watches with Python:&amp;nbsp;https://medium.com/@sebgoa/kubernets-async-watches-b8fa8a7ebfd4&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&quot;Kubernetes Patterns&quot;, an ebook by Redhat:&amp;nbsp;https://www.redhat.com/cms/managed-files/cm-oreilly-kubernetes-patterns-ebook-f19824-201910-en.pdf&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span data-markholder=&quot;true&quot;&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/1848076294167537600'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/1848076294167537600'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2020/11/kubernetes-role-based-authorisation-for.html' title='Kubernetes role-based authorisation for controller applications'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-7209452652279212245</id><published>2020-11-20T13:27:00.014+01:00</published><updated>2020-12-16T13:10:03.105+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="pjsip"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="SIP"/><title type='text'>Testing SIP platforms and pjsip</title><content type='html'>&lt;p&gt;There are various levels of testing, from unit to component, from integration to end-to-end, not to mention performance testing and fuzzing.&lt;/p&gt;&lt;div&gt;When developing or maintaining Real Time Communications (RTC or VoIP) systems,&amp;nbsp; all these levels (with the exclusion maybe of unit testing) are made easier by applications explicitly designed for this, like &lt;a href=&quot;http://sipp.sourceforge.net/doc/reference.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;sipp&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;sipp&lt;/i&gt; has a deep focus on performance testing, or using a simpler term, load testing. Some of its features allow to fine tune properties like call rate, call duration, simulate packet loss, ramp up traffic, etc. In practical terms though once you have the flexibility to generate SIP signalling to negotiate sessions and RTP streams, you can use &lt;i&gt;sipp&lt;/i&gt; for functional testing too.&lt;/div&gt;&lt;div&gt;&lt;i&gt;sipp&lt;/i&gt; can act as an entity generating a call, or receiving a call, which makes it suitable to surround the system under test and simulate its interactions with the real world.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What &lt;i&gt;sipp&lt;/i&gt; does can be generalised: we want to be able to simulate the real world that surrounds (or will surround) our system in Production. From this point of view &lt;i&gt;sipp&lt;/i&gt; is not the only answer, and projects often use other tools, or a combination of other tools.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;One simple and effective approach is re-using RTC applications and build the testing tool around them. When a system is built around an application, it&#39;s likely that the people working on it are familiar enough with the application to re-use it to mock the external world. This is often achieved with &lt;a href=&quot;https://www.asterisk.org/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Asterisk&lt;/a&gt; or &lt;a href=&quot;https://freeswitch.com/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;FreeSWITCH&lt;/a&gt;. They both expose an API for originating calls, and surely can play the role of called party (or &quot;absorbers&quot;, or &quot;parrots&quot; depending on their main scope and terminology).&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://www.kamailio.org/w/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Kamailio&lt;/a&gt; also can be used to generate calls, even though its core focus on signalling makes it slightly more complex to use in generic cases.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Unless behavioural changes are put in place, such solutions imply compromising on the SIP stacks in use. &lt;i&gt;Asterisk&lt;/i&gt; or &lt;i&gt;FreeSWITCH&lt;/i&gt; won&#39;t make it too easy to generate an INVITE with a wrongly formatted SIP header, for example, while &lt;i&gt;sipp&lt;/i&gt; is much more flexible, ad the SIP messages can be mocked down to the single character. What typically happens is that &lt;i&gt;sipp&lt;/i&gt; is used to generate or receive calls when specific syntax requirements for the signalling are needed, while &lt;i&gt;Asterisk&lt;/i&gt; and &lt;i&gt;FreeSWITCH&lt;/i&gt; can be used in more permissive cases, where what&#39;s important is a generic session establishment.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When dealing with media (typically, RTP streams) is necessary, then &lt;i&gt;sipp&lt;/i&gt; provides at least two methods: re-playing an RTP stream from a trace (pcap file), or encoding a WAV file into a stream. Recently &lt;i&gt;sipp&lt;/i&gt; added the ability to play RTP Events separately (DTMF tones as in RFC 2833 -&amp;nbsp; I think the first patch with this functionality was &lt;a href=&quot;https://sourceforge.net/p/sipp/patches/50&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;this&lt;/a&gt;). sipp is not able to transcode or generate non-PCM streams, but still it can play a non-PCM stream with just some limitations, which covers most of typical cases.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Less generic scenarios where RTC applications like &lt;i&gt;Asterisk&lt;/i&gt; and &lt;i&gt;FreeSWITCH&lt;/i&gt; can be useful are the ones requiring SRTP (encrypted RTP). Even though &lt;i&gt;sipp&lt;/i&gt; can be used to negotiate SRTP,&amp;nbsp; by adapting the SDP portion of the offer/answer, it doesn&#39;t provide a solution to &lt;i&gt;generate&lt;/i&gt; SRTP streams.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In this case a very useful item to add to your toolbox is &lt;a href=&quot;https://www.pjsip.org/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;pjsip&lt;/a&gt;, which is a SIP stack library (used also by &lt;i&gt;Asterisk&lt;/i&gt; and &lt;b&gt;chan_pjsip&lt;/b&gt; being the current recommended SIP channel, as opposed to the older chan_sip) that exposes an API and also a command-line option (&lt;b&gt;pjsua&lt;/b&gt;). &lt;i&gt;pjsua&lt;/i&gt; can be used directly, with either command line arguments or a configuration file, or it&#39;s possible to use &lt;i&gt;pjsip&lt;/i&gt; library to write programs with languages like python: this makes it very flexible and helps its integration in existing and new testing systems.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With &lt;i&gt;pjsip&lt;/i&gt;, it&#39;s possible to generate calls that play audio and DTMF tones, in a similar way than &lt;i&gt;sipp&lt;/i&gt;, but also encrypt RTP and establish SRTP streams.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;pjsua &lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The easiest approach is to build the pjsip project and use the pjsua binary (you can see a procedure in the Appendix).&lt;/div&gt;&lt;div&gt;&lt;i&gt;pjsua&lt;/i&gt; accepts command-line arguments, but can receive arguments from a configuration file, which makes it easier to read. For example you could just&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;#&amp;nbsp; pjsua --config-file pjsua.cfg&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;where pjsua.cfg contains just the caller and callee:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;sip:bob@example.com&lt;/div&gt;&lt;div&gt;--id=sip:alice@example.com&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;A more sophisticated configuration file contains instructions on codecs and encryption, e.g.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;sip:bob@example.com&lt;/div&gt;&lt;div&gt;--id=sip:alice@example.com&lt;/div&gt;&lt;div&gt;--use-srtp=0&lt;/div&gt;&lt;div&gt;--srtp-secure=0&lt;/div&gt;&lt;div&gt;--realm=*&lt;/div&gt;&lt;div&gt;--log-level=6&lt;/div&gt;&lt;div&gt;--no-vad&lt;/div&gt;&lt;div&gt;--dis-codec GSM&lt;/div&gt;&lt;div&gt;--dis-codec H263&lt;/div&gt;&lt;div&gt;--dis-codec iLBC&lt;/div&gt;&lt;div&gt;--dis-codec G722&lt;/div&gt;&lt;div&gt;--dis-codec speex&lt;/div&gt;&lt;div&gt;--dis-codec pcmu&lt;/div&gt;&lt;div&gt;--dis-codec pcma&lt;/div&gt;&lt;div&gt;--dis-codec opus&lt;/div&gt;&lt;div&gt;--add-codec pcma&lt;/div&gt;&lt;div&gt;--null-audio&lt;/div&gt;&lt;div&gt;--auto-play&lt;/div&gt;&lt;div&gt;--play-file /some_audio.wav&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Since I mentioned SRTP as a possible key element for using &lt;i&gt;pjsip&lt;/i&gt;, let&#39;s look into the related options:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;--use-srtp=0&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;--srtp-secure=0&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&#39;use-srtp&#39; can be 0, 1 or 2, and means &quot;disabled&quot;, &quot;optional&quot; and &quot;mandatory&quot;, respectively.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With &quot;optional&quot; pjsua offers both plain and encrypted RTP at the same time, and the callee entity can decide. With &quot;mandatory&quot; it will only offer SRTP, and the callee will have to either accept or reject.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&#39;srtp-secure&#39; refers to the use of TLS, and can also be 0, 1 or 2, meaning &quot;not required&quot;, use &quot;tls&quot;, or use &quot;sips&quot; respectively. Needless to say, in normal scenarios you want to protect the SRTP crypto information carried in the SDP, so you want to encrypt signalling too. SIP over TLS is the typical solution. For testing purposes you may prefer making it easier to check the content of signalling, and use &#39;srtp-secure=0&#39;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&#39;no-vad&#39; formally should be used to disable silence detection; in practice you want this option when generating a call from a machine that doesn&#39;t have a sound card.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Similarly, &#39;null-audio&#39; disables the requirement to play the audio, required when the calls are generated from a host with no sound interfaces.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&#39;dis-codec&#39; is used to disable a codec from the negotiation, and &#39;add-codec&#39; instead selects a codec to be added to the offer. This adds flexibility, and it&#39;s also worth noting that video codecs are available too.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Using pjsip library with python&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It&#39;s possible to use the &lt;i&gt;pjsip&lt;/i&gt; library&#39;s API with high level programming languages like python. This makes test automation quite versatile, and I remember seeing this approach as early as 2012, where the project I was working on had the client applications built on top of pjsip: it was extremely valuable to simulate programmatically the clients from linux machines.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Being designed for interactive applications, &lt;i&gt;pjsip&lt;/i&gt; comes with a nice event-based model, so in principle you need to trigger the desired actions and register callback functions that will be called at the proper moment.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;A complete reference to the python library can be found &lt;a href=&quot;https://www.pjsip.org/python/pjsua.htm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In general, after you import the library:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;import pjsua as pj&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;then the library is imported in an object, the configuration objects are populated, and a call is triggered, e.g.:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib = pj.Lib()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; media_cfg = pj.MediaConfig()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; media_cfg.no_vad = 0&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib.init(log_cfg = pj.LogConfig(level=3, callback=log_cb), media_cfg=media_cfg)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib.set_null_snd_dev()&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib.set_codec_priority(&quot;GSM&quot;, 0)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib.set_codec_priority(&quot;iLBC&quot;, 0)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib.set_codec_priority(&quot;G722&quot;, 0)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib.set_codec_priority(&quot;speex&quot;, 0)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib.set_codec_priority(&quot;pcmu&quot;, 0)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib.set_codec_priority(&quot;pcma&quot;, 1)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; transport = lib.create_transport(pj.TransportType.UDP)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib.start()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; acc = lib.create_account_for_transport(transport)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; call = acc.make_call(sys.argv[1], MyCallCallback(), hdr_list=custom_headers)&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can see that set_codec_priority to 0 is equivalent to the &lt;i&gt;--dis-codec&lt;/i&gt; command line option.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;MyCallCallback() is the callback function that will be invoked at each change of call state, with an event object passed as argument. You&#39;ll have something like:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;class MyCallCallback(pj.CallCallback):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; def __init__(self, call=None):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pj.CallCallback.__init__(self, call)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; def on_state(self):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if self.call.info().state == pj.CallState.CONFIRMED:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # The call has been answered&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # Here you can create a player to generate audio into an RTP stream, send DTMF, log information, etc&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # You can even invoke other APIs to interact with more complex systems&lt;/div&gt;&lt;div&gt;...&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; def on_media_state(self):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; global lib&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if self.call.info().media_state == pj.MediaState.ACTIVE:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; ...&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; # Media is now flowing, so you can connect it to the internal conference object&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; # Connect the call to sound device&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; call_slot = self.call.info().conf_slot&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; lib.conf_connect(call_slot, 0)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; lib.conf_connect(0, call_slot)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; print &quot;on_media_state - MediaState ACTIVE&quot;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As it can be expected, exceptions can be caught and errors displayed:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;except pj.Error, e:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; print &quot;Exception: &quot; + str(e)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib.destroy()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; lib = None&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; sys.exit(1)&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you happen to need DTMF tones, &lt;i&gt;pjsip&lt;/i&gt; offers the &lt;b&gt;dial_dtmf()&lt;/b&gt; function, as part of the Call object, e.g.:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;self.call.dial_dtmf(&quot;0&quot;)&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Just remember that these calls are asynchronous, non-blocking: you need to add explicitly a delay to separate the beginning of a tone from other actions.&lt;/div&gt;&lt;div&gt;&lt;i&gt;pjsip&lt;/i&gt; will generate proper RTP Event packets of the given duration, inside the existing RTP stream (and so they will have the same SSRC and proper timestamp reference).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I&#39;ll write about analysing pcap traces to extract information on RTP events in a separate article.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Wrap up&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This article is somehow what I would have wanted to read on the topic some time ago, but I had to infer from various sources and after various experiments. I hope it will be useful to some of the readers.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Appendix - pjsua build and install&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To build pjsua on debian you can do something like:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;apt install python-dev gcc make gcc binutils build-essential libasound2-dev wget&lt;/div&gt;&lt;div&gt;wget https://github.com/pjsip/pjproject/archive/2.10.tar.gz&lt;/div&gt;&lt;div&gt;tar -xvf 2.10.tar.gz&lt;/div&gt;&lt;div&gt;cd pjproject-2.10&lt;/div&gt;&lt;div&gt;export CFLAGS=&quot;$CFLAGS -fPIC&quot;&lt;/div&gt;&lt;div&gt;./configure &amp;amp;&amp;amp; make dep &amp;amp;&amp;amp; make&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The binary will be available at ./&lt;i&gt;pjsip-apps/bin/pjsua-x86_64-unknown-linux-gnu&lt;/i&gt;, which of course you can link to something easier to use, or copy to a directory in the PATH.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/7209452652279212245'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/7209452652279212245'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2020/11/testing-sip-platforms-and-pjsip.html' title='Testing SIP platforms and pjsip'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-1082297690650652159</id><published>2019-11-22T09:26:00.000+01:00</published><updated>2019-11-22T09:30:25.567+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="kamailio"/><category scheme="http://www.blogger.com/atom/ns#" term="testing"/><category scheme="http://www.blogger.com/atom/ns#" term="VoIP"/><title type='text'>kamailio-tests, a testing framework for Kamailio developers</title><content type='html'>&lt;div style=&quot;-en-clipboard: true;&quot;&gt;
&lt;a href=&quot;https://www.kamailio.org/w/&quot; target=&quot;_blank&quot;&gt;Kamailio&lt;/a&gt; is an open source VoIP server, widely used in the VoIP industry for its performance and feature set.&lt;/div&gt;
&lt;div style=&quot;-en-clipboard: true;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;-en-clipboard: true;&quot;&gt;
&lt;a href=&quot;https://github.com/kamailio/kamailio-tests&quot; target=&quot;_blank&quot;&gt;kamailio-tests&lt;/a&gt; is a project that aims to provide a level of automated testing for developers.
&lt;/div&gt;
&lt;div style=&quot;-en-clipboard: true;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The main idea is that simple things like loading a module or calling a core or module function can be tested without building an entire infrastructure around Kamailio.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Also, we want to be able to perform the tests against various versions of Kamailio, and on various OS distributions. In this way a backward incompatible function or a regression can be discovered by a developer even though their system uses one single version and OS combination.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This includes also third party libraries, e.g. you may think of testing the HTTP clients with different curl libraries, while Kamailio and OS stay at the same version.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
kamailio-test doesn&#39;t perform tests at function level (but it requires the application to run) or &quot;integration testing&quot; (because in order to remain generic and compact it doesn&#39;t cover complex architectures), but aims to test Kamailio as an isolated application.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In order to achieve this, kamailio-tests relies on Docker to allow developers to experiment and perform their tests in perfect isolation. For example, once you&#39;ve built the base Docker images you can add and modify tests while travelling on a plane.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Most VoIP platforms have extensive and complex test scenarios that involve setting up accounts, other components, specific logging systems, etc. We can&#39;t provide a compact, generic solution that would replace that, but instead we can focus on self-contained (pun intended), simple tests that give us key feedback on issues (and also the opportunity to debug them in that same infrastructure).
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The internal structure of the project and how to use it is described in its &lt;a href=&quot;https://github.com/kamailio/kamailio-tests/blob/master/README.md&quot; target=&quot;_blank&quot;&gt;README&lt;/a&gt;, but here I&#39;d like to reiterate how tests are run and how new tests can be added.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Of course you&#39;ll need Docker, and it can be a Desktop or server version.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Currently CentOS 7, Debian 9 and Debian 10 are supported via dedicated Dockerfiles.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
What version of Kamailio to test can be chosen by simply checking out the desired git branch or tag from &lt;a href=&quot;https://github.com/kamailio/kamailio&quot; target=&quot;_blank&quot;&gt;Kamailio github repo&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The installation process is described in the README, but let&#39;s see comment it here too:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
First create a directory where to store the resources and go to it, e.g.:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
mkdir kamailio-testing&lt;br /&gt;
cd kamailio-testing
&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Clone the kamailio-tests git repository inside that work directory:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
git clone &lt;a href=&quot;https://github.com/kamailio/kamailio-tests&quot;&gt;https://github.com/kamailio/kamailio-tests&lt;/a&gt;&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Clone the kamailio git repository inside that work directory:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
git clone &lt;a href=&quot;https://github.com/kamailio/kamailio&quot;&gt;https://github.com/kamailio/kamailio&lt;/a&gt;&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here you can git checkout the branch or tag you want to test, e.g.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
cd kamailio&lt;br /&gt;
git checkout 5.3.1&lt;br /&gt;
cd ../&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Copy the desired Dockerfile from kamailio-tests in the current folder, based on the OS distribution you want, e.g. for Debian Stretch:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
cp kamailio-tests/docker/Dockerfile.debian9 Dockerfile&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Build the Docker image. Give it the name you want: you&#39;ll just have to refer to it when launching the tests. e.g.:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
docker build -t kamailio-tests-deb9x .&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Run the tests. If you&#39;re happy with the default behaviour you can just:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
docker run kamailio-tests-deb9x
&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
and all not explicitly excluded tests will be executed.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Some tests may be excluded from execution by listing them in the etc/excludeunits.txt.DISTRIBUTION file, e.g.&amp;nbsp;etc/excludeunits.txt.centos7.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
How to add a test?
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Create a new folder in units/, with a name starting with &#39;t&#39;, followed by a string indicating the module, like &#39;geoip&#39;, and four digits, e.g. &#39;tgeoip0001&#39;.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Inside this folder the minimum amount of data is a shell script that the test framework will execute and a kamailio.cfg file. See for example &lt;a href=&quot;https://github.com/kamailio/kamailio-tests/tree/master/units/tgeoip0001&quot; target=&quot;_blank&quot;&gt;this test for geoip module&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The script must start with:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
#!/bin/bash&lt;br /&gt;
. ../../etc/config&lt;br /&gt;
. ../../libs/utils&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
to prepare configuration and utility commands.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Then you can launch Kamailio with the configuration required, e.g.:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tgeoip0001.cfg -a no -ddd -E 2&amp;gt;&amp;amp;1 | tee /tmp/kamailio-tgeoip0001.log &amp;amp;&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
You can see that logs are being sent to a local file; this is typically how the test result can be verified. Of course you can use a different approach.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Inside the container you have &lt;a href=&quot;https://linux.die.net/man/1/sipsak&quot; target=&quot;_blank&quot;&gt;sipsak&lt;/a&gt; available, so you can launch a test call to trigger call processing in Kamailio with something like:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
sipsak -s sip:alice@127.0.0.1
&lt;/blockquote&gt;
&lt;div&gt;
To help triggering the tests also tools like &lt;a href=&quot;http://sipp.sourceforge.net/doc/reference.html&quot; target=&quot;_blank&quot;&gt;sipp&lt;/a&gt; and &lt;a href=&quot;https://www.pjsip.org/pjsua.htm&quot; target=&quot;_blank&quot;&gt;pjsua&lt;/a&gt; can be considered, but are not currently installed in the docker images.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
After waiting for the necessary time, you can just kill Kamailio with
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
kill_pidfile ${KAMPID}
&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
and check the test result by parsing the log file, e.g.:
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
grep &quot;ip address is registered in US&quot; /tmp/kamailio-tgeoip0001.log&lt;br /&gt;
ret=$?&lt;br /&gt;
if [ ! &quot;$ret&quot; -eq 0 ] ; then&lt;br /&gt;
&amp;nbsp; &amp;nbsp; exit 1&lt;br /&gt;
fi
&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&#39;exit 1&#39; will make the test fail.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
End the test script with
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
exit 0&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
to make it pass.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Adding a README.md inside that same folder is highly recommended.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
You can add one or more tests and run them before committing the changes.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;

&lt;br /&gt;
&lt;div&gt;
Once happy please fork the kamailio-tests repo with your changes and raise a pull request.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Thanks for reading; feedback is welcome.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/1082297690650652159'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/1082297690650652159'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2019/11/kamailio-tests-testing-framework-for.html' title='kamailio-tests, a testing framework for Kamailio developers'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-1457023522994598768</id><published>2019-11-17T19:42:00.001+01:00</published><updated>2019-11-18T13:24:25.818+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="kamailio"/><category scheme="http://www.blogger.com/atom/ns#" term="SIP"/><title type='text'>My notes on Kamailio Developer Meeting - November 2019</title><content type='html'>&lt;div style=&quot;-en-clipboard: true;&quot;&gt;
The Kamailio Developers Meeting is a two-day event held in Dusseldorf, currently at the second edition.&amp;nbsp;
&lt;/div&gt;
&lt;div style=&quot;-en-clipboard: true;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As described in https://www.kamailio.org/w/developers-meeting/,&amp;nbsp;
&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&quot;The purpose of the event is to support the interaction between developers and to offer a great environment to work together on relevant topics related to the Kamailio project. It is intended for participants that want to write code for Kamailio and its tools or improve the documentation. There will be no formal presentations, only open discussions, coding or documentation writing sessions.&quot;
&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The sipgate offices offered a very welcoming environment. Noticeable to have a kitchen with chefs for breakfast and lunch, and a private pub, where the social event was held. I noticed the presence of art works and learned that those offices are also part of an art itinerary in Dusseldorf.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
We started listing the topics that we wanted to tackle during the event, then discussed a plan to go through them.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The first important activity was &lt;a href=&quot;https://www.kamailio.org/w/2019/11/kamailio-v5-3-1-released/&quot; target=&quot;_blank&quot;&gt;the release of kamailio version 5.3.1&lt;/a&gt; (minor bug fix). The release process includes running the tests in &lt;a href=&quot;https://github.com/kamailio/kamailio-tests&quot; target=&quot;_blank&quot;&gt;kamilio-tests repo&lt;/a&gt; (more on this later in a dedicated post), and an issue was found and resolved during the release.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Then it was the time to discuss RPM packages building: Sergey Safarov has made an incredible amount of work to ensure that RPM packages for kamailio are available, and now they are available at &lt;a href=&quot;https://rpm.kamailio.org/&quot;&gt;https://rpm.kamailio.org/&lt;/a&gt;. Work is in progress to move all the building phases to infrastructure belonging to the kamailio projects and avoiding personal accounts to access cloud services as much as possible.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
A documentation review was carried out: it was reported that often the return values of module functions are not documented, and work is encouraged in that direction, including a review of documentation of function parameters. Modules may make available several pseudovariables, and not always they are documented. There&#39;s also &lt;a href=&quot;https://www.kamailio.org/wiki/cookbooks/devel/pseudovariables&quot; target=&quot;_blank&quot;&gt;a dedicated wiki page on pseudovariables&lt;/a&gt; that&#39;s useful as reference.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Daniel made a briefing on the &lt;a href=&quot;https://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/&quot; target=&quot;_blank&quot;&gt;Kemi framework&lt;/a&gt;, explaining how to structure the wrapper functions (two steps, one the parameters manipulation for the standard cfg file, and then encapsulate the code into a separate function. Also in this way executing a function from Kemi doesn&#39;t require executing all the typical wrapper manipulations required by cfg functions, impacting positively on performance). Developers need to ensure that when you develop a new function the body of the function is separate from the code that manipulates the parameters.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
An open topic focused on the best process to handle &quot;dialog failover&quot;. This may be necessary if a kamailio-based component disappears during the dialog lifetime, or if the architecture allows for in-dialog messages to be processed by different entities during a call, even in the typical case where record-routing applies. Currently it&#39;s possible to load dialog information on the fly from a DB, see &lt;a href=&quot;https://www.blogger.com/.%20https://www.kamailio.org/docs/modules/stable/modules/dialog.html#dialog.f.dlg_db_load_callid&quot; target=&quot;_blank&quot;&gt;dlg_db_load_callid()&lt;/a&gt;, but when an instance &quot;takes over&quot; the dialog information there&#39;s typically the need to manipulate the record-routing, which is complex and not exactly &quot;standard&quot; behaviour.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Modules like &lt;a href=&quot;https://www.kamailio.org/docs/modules/devel/modules/evapi.html&quot; target=&quot;_blank&quot;&gt;evapi&lt;/a&gt; and &lt;a href=&quot;https://www.kamailio.org/docs/modules/devel/modules/http_async_client.html&quot; target=&quot;_blank&quot;&gt;http_async_client&lt;/a&gt; allow for the management of asynchronous events by spawning dedicated workers which will execute portions of the routing logic when defined events happen. An open discussion is about the best method for managing asynchronous events and at the same time return execution to the main workers when an event is triggered.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Debian packaging; a PGP signed key was created, to benefit from the physical presence of various holders of PGP signatures. An open point is related to the ability to keep earlier versions of the kamailio packages every time a new version is released. This is a known behaviour that may limit the options in some environments, and I&#39;ve experienced it directly. This is caused by reprepro and what seems to be the right way to go is moving from reprepro and use aptly instead. We&#39;ll update on this.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Use of TLSv1.3: the only limitation appears to be in libssl library. &lt;a href=&quot;https://kamailio.org/docs/modules/devel/modules/tls.html#tls.p.tls_method&quot; target=&quot;_blank&quot;&gt;It&#39;s possible to allow the usage of version 1.3, but only by choosing tlsv1.2+&lt;/a&gt;, which admits using v1.2, and so doesn&#39;t enforce v1.3 only. When this will be allowed, kamailio administrators will just need to update the configuration and reload the tls module. Remember that only configurations in tls.cfg can be reloaded, while modparam declarations require a restart.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Finally, we know that a common pattern of usage of kamailio involves querying APIs and basing call processing on the API responses. A simple but powerful solution sees the use of http_async_client in collaboration with &lt;a href=&quot;https://www.kamailio.org/docs/modules/devel/modules/rtjson.html&quot; target=&quot;_blank&quot;&gt;rtjson&lt;/a&gt;; see for example this article from wazo developers:&amp;nbsp;&lt;a href=&quot;https://wazo-platform.org/blog/kamailio-routing-with-rtjson-and-http-async-client&quot;&gt;https://wazo-platform.org/blog/kamailio-routing-with-rtjson-and-http-async-client&lt;/a&gt;&amp;nbsp;We are discussing whether extending rtjson may be generally helpful for scenarios like this; in that case I&#39;ll post an update.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For me this event was a great experience, both from a friendship point of view and as a learning experience. I&#39;m very happy about how the kamailio project is managed, decisions are taken and information is shared.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;i&gt;Here&#39;s my report; for obvious reasons this can only be a limited account of what happened during the event, and the information provided is based on my recollection and notes. I&#39;m sure I&#39;m omitting other important material, and I&#39;ll be happy to integrate with another post.&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/1457023522994598768'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/1457023522994598768'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2019/11/my-notes-on-kamailio-developer-meeting.html' title='My notes on Kamailio Developer Meeting - November 2019'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-4162437257315685964</id><published>2018-11-27T10:17:00.000+01:00</published><updated>2018-11-27T10:18:01.515+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="running"/><title type='text'>You need to slow down</title><content type='html'>&lt;div style=&quot;-en-clipboard: true;&quot;&gt;
&lt;i&gt;This blog has been historically focused on technical topics in areas related to Real Time Communications, but I&#39;m taking the liberty to digress a little.
&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I&#39;ve been reading recently about the dynamics of performance in running.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I&#39;m just an amateur runner, and I always train (and race) alone, so I felt the need to make it more interesting than just reading training tables. I&#39;ve been studying what is it that limits performance. &quot;Train more&quot;, unfortunately, not only doesn&#39;t always work, but needs to take into account injuries, and overtraining in general.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
One of the first concepts that struck me is that it&#39;s been proven that fatigue, and the consequential slow down, does not mean that the body is unable to continue with that effort. What&#39;s behind slowing down is a sort of protective mechanism in our nervous system, which wants to prevent the body to reach exhaustion.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Our nervous system is constantly getting feedback signals from the body, including the perception of adverse weather conditions, and computing for how longer the current effort can be sustained. Even knowing how long is left to run is a form of external feedback.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
When this computation detects that the effort is too high, the nervous system takes control and doesn&#39;t fire as many muscle fibres as the athlete wants to. The athlete thinks the muscles can&#39;t continue to work at that level, but in reality they are entering a protective status. Without that, people could literally run until body exhaustion or even death.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I find this fascinating. Evolution has given us a sophisticated algorithm aimed to prevent body exhaustion by generating fatigue symptoms and consequently reduce the actual effort.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
What&#39;s also fascinating is that it seems this system can be &quot;tricked&quot;. One way of doing is by training. Training is a way of educating your nervous system that a certain effort is OK. &quot;There&#39;s no need to shut me down, brain, I know what I&#39;m doing. I did that thousands of times in my training sessions.&quot;
&lt;/div&gt;
&lt;div&gt;
So while the body adapts to the stress of training, the nervous system too becomes more familiar with that stress, and gives up a little.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Another way of tricking that system is by providing false external feedback. It seems that if you get false information about elements like the air temperature, or even the remaining time in your training session or race, then the nervous system acts accordingly. If it believes it&#39;s not as hot as it is, it will not intervene to shut the muscle fibre activation.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Similarly, if the athlete thinks the race is close to the end, the nervous system will allow a prolonged effort. This is why elite marathoners, who clearly haven&#39;t underperformed for the first 40 km, can run the last 2 km even faster.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Of course, all these tricks have limits, and the improvements that can be tricked are in the order of small percentages. But still this shows the importance of external feedback.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This is properly explained by &lt;a href=&quot;https://www.amazon.com/Science-Running-limit-maximize-performance/dp/0615942946&quot; target=&quot;_blank&quot;&gt;Steve Magness in his &quot;Science of running&quot; book&lt;/a&gt;. I then read another book from this author, &lt;a href=&quot;https://www.amazon.com/Peak-Performance-Elevate-Burnout-Science/dp/162336793X&quot; target=&quot;_blank&quot;&gt;&quot;Peak performance&quot;&lt;/a&gt;. To be perfectly honest, I was expecting something strictly related to endurance sport, but in this second case the concept of performance was wider.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
There seems though to be an analogy between the shutting down of muscle fibres from the nervous system during running, and something that happens behind a desk and is more widely known: mental burnout. From this point of view, mental burnout can be seen as a way of saying &quot;You can&#39;t keep going at this (perceived) level of effort. You need to sleep, hydrate, rest, but you keep working. I&#39;m going to take control and shut you down.&quot;.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;

&lt;br /&gt;
&lt;div&gt;
As I&#39;m making my own little experiments, in the future I&#39;d like to write more about this, and in particular about the relationship between effort and rest.&amp;nbsp;&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/4162437257315685964'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/4162437257315685964'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2018/11/you-need-to-slow-down.html' title='You need to slow down'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-8829966017877262844</id><published>2018-11-19T21:20:00.002+01:00</published><updated>2018-11-19T21:20:53.043+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="docker"/><title type='text'>Docker from scratch</title><content type='html'>Some time ago I prepared an introductory seminar on Docker, which I called &quot;Docker from scratch&quot;.&lt;br /&gt;
&lt;br /&gt;
The audience was a local group of heterogeneous developers.
As it typically happens, preparing that material was a great opportunity to understand better some of the aspects.&lt;br /&gt;
&lt;br /&gt;
I then published the slides in Slideshare. I notice now that they got a decent number of views and downloads, so &lt;a href=&quot;https://www.slideshare.net/GiacomoVacca/docker-from-scratch&quot; target=&quot;_blank&quot;&gt;I&#39;m linking those slides here as well for reference&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
One big change in respect to 2016 is represented by the choice of abandoning Docker Toolbox in favour of running Docker directly on macOS. I have to say I liked the sandboxing that came with Docker Toolbox, where the docker engine ran inside VirtualBox, &lt;a href=&quot;https://docs.docker.com/toolbox/toolbox_install_mac/&quot; target=&quot;_blank&quot;&gt;now only available for older versions&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/8829966017877262844'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/8829966017877262844'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2018/11/docker-from-scratch.html' title='Docker from scratch'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-749983483150872745</id><published>2018-05-29T20:50:00.000+02:00</published><updated>2018-05-29T20:50:15.452+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="kamailio"/><category scheme="http://www.blogger.com/atom/ns#" term="RTC"/><category scheme="http://www.blogger.com/atom/ns#" term="VoIP"/><category scheme="http://www.blogger.com/atom/ns#" term="webrtc"/><title type='text'>On Kamailio World 2018, part II</title><content type='html'>&lt;div style=&quot;-en-clipboard: true;&quot;&gt;
&lt;a href=&quot;http://www.giacomovacca.com/2018/05/on-kamailio-world-2018-part-i.html&quot; target=&quot;_blank&quot;&gt;In the first part of my brain dump about this year&#39;s edition of Kamailio World&lt;/a&gt; I focused mainly on testing. Core developers and application designers want to be able to test the behaviour of &lt;a href=&quot;https://www.kamailio.org/w/&quot; target=&quot;_blank&quot;&gt;Kamailio&lt;/a&gt;-based architectures with minimal effort and fast feedback.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
A different dimension to testing, that I haven&#39;t mentioned in my previous post, was related to &lt;a href=&quot;https://en.wikipedia.org/wiki/Fuzzing&quot; target=&quot;_blank&quot;&gt;Fuzz testing&lt;/a&gt;. There were two presentations focused on this: Sandro Gauci&#39;s (The easiest way to understand who Sandro is: listen on port 5060 on the public Internet and wait a couple of minutes. You&#39;ll see a SIP request from a tool called &lt;a href=&quot;https://github.com/EnableSecurity/sipvicious&quot; target=&quot;_blank&quot;&gt;sipvicious&lt;/a&gt; (aka friendly-scanner), a penetration testing tool Sandro wrote (and others misuse))&amp;nbsp;and &lt;a href=&quot;https://www.kamailio.org/w/henning-westerholt/&quot; target=&quot;_blank&quot;&gt;Henning Westerholt&lt;/a&gt;, historical member of the Kamailio community.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Sandro&#39;s presentation focused around fuzzing approaches for RTC in general (&lt;a href=&quot;https://www.slideshare.net/sandrogauci/a-tale-of-two-rtc-fuzzing-approaches&quot; target=&quot;_blank&quot;&gt;slides&lt;/a&gt;), while Henning was more specifically focused on Kamailio.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Fuzzing is a sophisticated technique to verify the robustness of a software application, by sending input that can vary greatly from the typical or expected usage. The objective is to find weaknesses that can lead to crashes or other malfunctions, so that they can be fixed. Of course testing a server like Kamailio is even trickier than testing an application that can read from a file. It is a fascinating topic.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Kamailio proved to be very robust: Henning reported an average of &amp;nbsp;about 1 message every 44 million required to make Kamailio misbehave. The video of Henning&#39;s presentation is &lt;a href=&quot;https://www.youtube.com/watch?v=bhy7-uxZGqk&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; (by the way, &lt;a href=&quot;https://www.pascom.net/en/mobydick-voip/&quot; target=&quot;_blank&quot;&gt;Pascom&lt;/a&gt; have done a great work this year too, providing a flawless video streaming and recording. It feels like we are a little spoiled, because we give it for granted and barely notice all the work behind it).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In terms of learning opportunities for architects and administrators of Kamailio-based infrastructure, I found very valuable Daniel&#39;s presentations around high-level scripting (with &lt;a href=&quot;https://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/&quot; target=&quot;_blank&quot;&gt;KEMI&lt;/a&gt;) to build the routing logic (&lt;a href=&quot;https://www.youtube.com/watch?v=cp3TZkcpFUQ&quot; target=&quot;_blank&quot;&gt;Video&lt;/a&gt; and &lt;a href=&quot;https://www.kamailio.org/events/2018-KamailioWorld/Day0/W07-Daniel-Constantin.Mierla-KEMI-Scripting.pdf&quot; target=&quot;_blank&quot;&gt;slides&lt;/a&gt;).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Remember that Lua may not be the most popular - apparently - but it&#39;s the one estimated to give you performances closest to the native routing language.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Another valuable presentation was around the Least Cost Routing techniques that the Kamailio environment makes available. (&lt;a href=&quot;https://www.youtube.com/watch?v=ZJa0FVrVo7E&quot; target=&quot;_blank&quot;&gt;Video&lt;/a&gt;, and &lt;a href=&quot;https://www.kamailio.org/events/2018-KamailioWorld/Day2/28-Daniel-Constantin.Mierla-Kamailio-LCR-Engines.pdf&quot; target=&quot;_blank&quot;&gt;slides&lt;/a&gt;). Some solutions use out of the box modules (like &lt;a href=&quot;https://www.kamailio.org/docs/modules/stable/modules/lcr.html&quot; target=&quot;_blank&quot;&gt;lcr&lt;/a&gt;, &lt;a href=&quot;https://www.kamailio.org/docs/modules/stable/modules/carrierroute.html&quot; target=&quot;_blank&quot;&gt;carrierroute&lt;/a&gt;, &lt;a href=&quot;https://www.kamailio.org/docs/modules/stable/modules/drouting.html&quot; target=&quot;_blank&quot;&gt;drouting&lt;/a&gt;), some are more indirect (&lt;a href=&quot;https://www.kamailio.org/docs/modules/stable/modules/pdt.html&quot; target=&quot;_blank&quot;&gt;pdt&lt;/a&gt;, &lt;a href=&quot;https://www.kamailio.org/docs/modules/stable/modules/mtree.html&quot; target=&quot;_blank&quot;&gt;mtree&lt;/a&gt;, &lt;a href=&quot;https://www.kamailio.org/docs/modules/stable/modules/dialplan.html&quot; target=&quot;_blank&quot;&gt;dialplan&lt;/a&gt;, &lt;a href=&quot;https://www.kamailio.org/docs/modules/stable/modules/prefix_route.html&quot; target=&quot;_blank&quot;&gt;prefix_route&lt;/a&gt;), and others are a combination of them. Must-see if you&#39;re working in that area.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Another learning goldmine has been Lorenzo Miniero&#39;s (author of &lt;a href=&quot;https://janus.conf.meetecho.com/&quot; target=&quot;_blank&quot;&gt;Janus&lt;/a&gt;, a WebRTC conferencing framework (this definition is mine)) lecture about Privacy, Security and Authentication for WebRTC. (&lt;a href=&quot;https://www.youtube.com/watch?v=ewNJMci62rs&quot; target=&quot;_blank&quot;&gt;Video&lt;/a&gt;&amp;nbsp;and &lt;a href=&quot;https://www.slideshare.net/LorenzoMiniero/webrtc-securitymore-kamailioworld-2018&quot; target=&quot;_blank&quot;&gt;slides&lt;/a&gt;) Lorenzo does talk fast, but no word is spoken in vain. Worst case, you can watch the video at 0.5 speed (smile). Interesting the case of double encryption for media.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;

&lt;br /&gt;
&lt;div&gt;
I guess there&#39;s enough for a part III in the near future! To be continued.&amp;nbsp;&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/749983483150872745'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/749983483150872745'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2018/05/on-kamailio-world-2018-part-ii.html' title='On Kamailio World 2018, part II'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-1544247621023293075</id><published>2018-05-24T10:20:00.000+02:00</published><updated>2018-05-24T10:40:40.053+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="kamailio"/><category scheme="http://www.blogger.com/atom/ns#" term="RTC"/><category scheme="http://www.blogger.com/atom/ns#" term="SIP"/><category scheme="http://www.blogger.com/atom/ns#" term="VoIP"/><title type='text'>On Kamailio World 2018, part I</title><content type='html'>&lt;div style=&quot;-en-clipboard: true;&quot;&gt;
This was my fifth time in a row attending &lt;a href=&quot;https://www.kamailioworld.com/k06/&quot; target=&quot;_blank&quot;&gt;Kamailio World &lt;/a&gt;in Berlin. The weather was warmer and sunnier than usual.
&lt;/div&gt;
&lt;div style=&quot;-en-clipboard: true;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Apart from the obvious focus on &lt;a href=&quot;https://www.kamailio.org/w/&quot; target=&quot;_blank&quot;&gt;Kamailio&lt;/a&gt;, as usual the RTC ecosystem was well represented (with Janus, Asterisk, FreeSWITCH, Homer, RTPEngine, and many others).
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Attendance from the other side of the Atlantic Ocean gave stronger emphasis to the &quot;World&quot; term in the title.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
My personal mission this year was to talk about &lt;a href=&quot;https://github.com/kamailio/kamailio-tests&quot; target=&quot;_blank&quot;&gt;a framework for testing Kamailio&lt;/a&gt; as a tool for developers and maintainers of the project: &lt;b&gt;kamailio-tests&lt;/b&gt;. The main concept was that early tests that are not focused on a specific business logic (as we all have in our projects) and can be automated will be beneficial to Kamailio&#39;s reliability. We want to defer end-to-end testing to later stages, because they are expensive.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To provide a uniform infrastructure where to run the tests, without requiring permanent test environments, we use Docker for this. This is, of course, not the only possible approach, e.g. you could dynamically spawn VMs, AWS EC2s, etc. But Docker can run on your laptop as well as on a full-fledged CI environment, and this makes it easier to use for the developers.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://www.slideshare.net/GiacomoVacca/kamailio-world-workshop-kamailiotests&quot; target=&quot;_blank&quot;&gt;Please take a look at the slides for more details&lt;/a&gt;. The feedback has been great so far, and this proved various points:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
1. Conferences for developers are not paid holidays for IT guys, but opportunities for knowledge sharing and collaboration (I would say, in particular if Open Source is in the equation).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
2. &quot;Functional&quot; or &quot;component&quot; testing is needed by many, but we haven&#39;t a mature solution yet.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
3. Docker in RTC is less a fancy technology borrowed by other IT areas and more an everyday tool.
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Some have already volunteered to help me improve kamailio-tests, and their point of view will be very useful. More on this project in the future.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Around the topic of testing, in this case not Kamailio itself but more the business logic built around it, there have been interesting insights from Sebastian Damm (sipgate) and Alex Sosic (evosip).&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://www.slideshare.net/SebastianDamm2/kamailioworld-2018-modular-and-test-driven-sip-routing-with-lua&quot; target=&quot;_blank&quot;&gt;Sebastian presented an approach&lt;/a&gt; that benefits from moving the Kamailio routing logic from the native language to &lt;a href=&quot;https://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/&quot; target=&quot;_blank&quot;&gt;KEMI&lt;/a&gt; with Lua (&lt;a href=&quot;https://github.com/sipgate/lua-kamailio&quot;&gt;https://github.com/sipgate/lua-kamailio&lt;/a&gt;). &lt;a href=&quot;https://www.slideshare.net/sosic/cicd-and-tdd-in-deploying-kamailio&quot; target=&quot;_blank&quot;&gt;Alex presented a way to&lt;/a&gt; verify the routing logic is going through the expected paths, again with Docker, and sipp.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
KEMI is an extension of Kamailio that allows developers to write the routing logic in high level languages, like Lua, Python, JS and others. Anedoctical experience made me think Lua was the most popular, while apparently Python is. For what concerns Lua in the RTC world, I wrote a few notes in February:&amp;nbsp;&lt;a href=&quot;http://www.giacomovacca.com/2018/02/the-interesting-case-of-lua-in-rtc-world.html&quot;&gt;http://www.giacomovacca.com/2018/02/the-interesting-case-of-lua-in-rtc-world.html&lt;/a&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;

&lt;br /&gt;
&lt;div&gt;
The advantages of working with a high level language are obvious: easier to read and maintain, it&#39;s easier to test the functions in isolation, and also easier to involve developers without specific knowledge in Kamailio&#39;s routing logic script. They will still need to understand how Kamailio works though, and the underlying protocols, so unless you&#39;re doing something extremely basic, it&#39;s not a complete abstraction from how Kamailio manages its role as &quot;programmable SIP Proxy&quot;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I have tons of notes from Kamailio World, but if I wait to go through all of them before writing something here, there will be the 2019 edition to talk about. So here&#39;s at least a part I.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/1544247621023293075'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/1544247621023293075'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2018/05/on-kamailio-world-2018-part-i.html' title='On Kamailio World 2018, part I'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-6388384057539467524</id><published>2018-02-05T21:44:00.000+01:00</published><updated>2018-02-05T22:21:10.650+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="janus"/><category scheme="http://www.blogger.com/atom/ns#" term="kamailio"/><category scheme="http://www.blogger.com/atom/ns#" term="Lua"/><category scheme="http://www.blogger.com/atom/ns#" term="RTC"/><category scheme="http://www.blogger.com/atom/ns#" term="VoIP"/><category scheme="http://www.blogger.com/atom/ns#" term="Wireshark"/><title type='text'>The interesting case of Lua in RTC world</title><content type='html'>&lt;div&gt;
An interesting pattern that caught my attention is the role that &lt;a href=&quot;https://www.lua.org/about.html&quot; target=&quot;_blank&quot;&gt;Lua&lt;/a&gt; is gaining in the RTC (Real-Time Communications) world.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Lua is a small-footprint programming language, powerful while keeping a simple syntax.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I’ve been using &lt;a href=&quot;https://freeswitch.org/confluence/display/FREESWITCH/Lua+API+Reference&quot; target=&quot;_blank&quot;&gt;Lua to script dialplan actions for FreeSWITCH&lt;/a&gt; since about 2014. It has provided me with a way to define relatively complex logic and speed up the definition of FS’ behaviour.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Delegating this type of logic to a scripting language had several advantages, such as:&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;It’s easier to read and understand than native dialplans or native routing logic.&lt;/li&gt;
&lt;li&gt;Makes unit testing of the dialplan possible/easier.&lt;/li&gt;
&lt;li&gt;Allows changing some pieces of logic easily, in many cases preventing expensive reload of modules or restart of applications.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
I’ve been using &lt;a href=&quot;https://www.kamailio.org/docs/modules/stable/modules/app_lua.html&quot; target=&quot;_blank&quot;&gt;Lua for Kamailio&lt;/a&gt; as well. &lt;a href=&quot;https://www.kamailio.org/w/&quot; target=&quot;_blank&quot;&gt;Kamailio is an open source programmable SIP Proxy&lt;/a&gt;. In a specific case, some bits of the routing logic required regex processing and was expecting to change often: an ideal case for an external script to do that work.&lt;/div&gt;
&lt;div&gt;
When the logic changes, it’s sufficient to instruct Kamailio to reload the script, and from that moment on the new requests being processed will use the new logic.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Recent versions of Kamailio though add a framework called &lt;a href=&quot;https://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/&quot; target=&quot;_blank&quot;&gt;KEMI&lt;/a&gt;. This opens up new possibilities, and also provides support for many other scripting languages, python being the most popular, JS, &lt;a href=&quot;http://www.squirrel-lang.org/&quot; target=&quot;_blank&quot;&gt;Squirrel&lt;/a&gt;. Still, Lua appears to provide the fastest implementations (with no observable performance degradation) while others have limitations. Python, as you can imagine, provides a rich set of functions and libraries, but it’s not as performant and the reload mechanism currently has some issues.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Wireshark, a tool to capture and analyse network activity, &lt;a href=&quot;https://wiki.wireshark.org/Lua&quot; target=&quot;_blank&quot;&gt;exposes a useful API for Lua&lt;/a&gt;. You can use the API to define your own Wireshark dissector (which you’ll need to install as a plugin). This has performance limitations in comparison with dissectors written in C - and so it’s recommended for prototyping only - but still can solve your problem perfectly. Out of need, &lt;a href=&quot;https://github.com/sipcapture/hep-wireshark&quot; target=&quot;_blank&quot;&gt;I wrote a Wireshark dissector for HEP&lt;/a&gt;, a binary protocol used in the Homer environment. &lt;a href=&quot;http://www.sipcapture.org/&quot; target=&quot;_blank&quot;&gt;Homer is an open source framework&lt;/a&gt; for the monitoring and analysis of Real-Time Communications.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Last weekend a new interesting case was &lt;a href=&quot;https://fosdem.org/2018/schedule/event/janus/&quot; target=&quot;_blank&quot;&gt;presented by Lorenzo Miniero at FOSDEM&lt;/a&gt;. The target application was &lt;a href=&quot;https://janus.conf.meetecho.com/&quot; target=&quot;_blank&quot;&gt;Janus, an open source framework to build WebRTC gateways&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Janus allows to build applications by defining the transport and business logic as plugins, on top of the core that implements the WebRTC stack.&lt;/div&gt;
&lt;div&gt;
It’s written in C and so far users needed to write plugins with that language. The Janus developers have introduced the possibility to write plugins in Lua.&lt;/div&gt;
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;a href=&quot;http://www.meetecho.com/blog/tutorial-writing-a-janus-video-call-plugin-in-lua/&quot; target=&quot;_blank&quot;&gt;In his presentation Lorenzo explains also in detail&lt;/a&gt; what approach is best to use for a Real-Time application to interact with single threaded language like Lua in an asynchronous context.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt; Just a funny note: Lua uses a double dash for commenting out a line: &#39;--&#39;. Be careful when you watch diffs in a terminal because a removed comment will start with &#39;- --‘ and may not the easiest thing to interpret (experiences may vary depending on the terminal, of course!).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/6388384057539467524'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/6388384057539467524'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2018/02/the-interesting-case-of-lua-in-rtc-world.html' title='The interesting case of Lua in RTC world'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-2781625397212228262</id><published>2018-01-21T20:10:00.001+01:00</published><updated>2018-01-21T20:10:32.668+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="docker"/><title type='text'>Cache busting when building Docker images</title><content type='html'>One of the handiest features of the docker build system is the caching system.&lt;br /&gt;
&lt;br /&gt;
&#39;docker build&#39; tries to reuse the layers already built until something changes inside the Dockerfile. In this way, we can save several minutes when rebuilding an image if the changes happen further down the list in the Dockerfile.&lt;br /&gt;
&lt;br /&gt;
Sometimes, though, we do want to invalidate the cache and ensure the next build won&#39;t use it.&lt;br /&gt;
&lt;br /&gt;
To do this an option is to pass the &#39;--no-cache&#39; argument to &#39;docker build&#39;.&lt;br /&gt;
&lt;br /&gt;
When dealing with &#39;apt-get install&#39; instructions though there are other tricks. I found &lt;a href=&quot;https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#run&quot;&gt;this document on Dockerfile best practices&lt;/a&gt; very useful.&lt;br /&gt;
&lt;br /&gt;
First of all an observation. If you have &#39;RUN apt-get update&#39; as a single line of a Dockerfile, followed by the installation of a package, e.g.:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;RUN apt-get update&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;RUN apt-get install -y nginx&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
then changing the list of packages and running again the build command won&#39;t trigger an &#39;apt-get update&#39;: that line hasn&#39;t changed so docker build reuses the cache. It might not be what you want.&lt;br /&gt;
&lt;br /&gt;
To force cache invalidation for this specific case the recommendation is to use those commands in the form:&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;RUN apt-get update &amp;amp;&amp;amp; apt-get install -y nginx&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
This will always install the latest version of the packages. It even has a name: &quot;cache busting&quot;.&lt;br /&gt;
&lt;br /&gt;
Another recommendation I like is to put each package on a single line, and have them in alphabetical order: this will ease visual inspection and prevent duplicates or other undesired conditions.&lt;br /&gt;
&lt;br /&gt;
Of course, you can also specify exact versions for the packages as you would normally do with &#39;apt-get install&#39;. That&#39;s &quot;version pinning&quot; and it invalidates the cache too.&lt;br /&gt;
&lt;br /&gt;
You can find all this on the linked page on Dockerfile best practices; this is just my digested interpretation.&lt;br /&gt;
&lt;br /&gt;
Just one more thing: a way to limit the size of a built image is to clean up the content of &#39;/var/lib/apt/lists&#39; in the same RUN command, e.g.:&lt;br /&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;RUN apt-get update &amp;amp;&amp;amp; apt-get install -y \&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;aufs-tools \&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;automake \&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;build-essential \&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&amp;amp;&amp;amp; rm -rf /var/lib/apt/lists/*&lt;/i&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The command above will build an image layer that doesn&#39;t contain the apt cache.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you had instead used this:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;i style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i style=&quot;background-color: white;&quot;&gt;RUN apt-get update &amp;amp;&amp;amp; apt-get install -y \&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;aufs-tools \&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;automake \&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;build-essential&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i style=&quot;background-color: white;&quot;&gt;RUN rm -rf /var/lib/apt/lists/*&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;you would have had not only a larger layer, containing the apt cache, but also an additional layer generated by the second RUN command.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/2781625397212228262'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/2781625397212228262'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2018/01/cache-busting-when-building-docker.html' title='Cache busting when building Docker images'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-2981187770511459866</id><published>2018-01-13T11:56:00.001+01:00</published><updated>2018-07-06T14:03:36.037+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SIP"/><title type='text'>SIP - ACK loose routing</title><content type='html'>If you&#39;ve ever worked with SIP, you must have stumbled upon a trace with 200 OK to INVITE being retransmitted for about 30&quot; and then the call just being set up fail.&lt;br /&gt;
&lt;br /&gt;
The ACK was never received.&lt;br /&gt;
&lt;br /&gt;
Then comes the interesting part: discovering why.&lt;br /&gt;
&lt;br /&gt;
Here are some notes about what should happen, in particular when there are multiple proxies along the path, and with a little additional complexity of one of the proxies with two network interfaces. All this assuming loose routing everywhere. The main reference here of course is &lt;a href=&quot;https://tools.ietf.org/html/rfc3261&quot; target=&quot;_blank&quot;&gt;RFC 3261&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Isn&#39;t an image worth a thousand words? Then here&#39;s a sequence diagram:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4a_no538ZxALs72Lfb1ASY2hyym43Anx7cCtKE0ayd6rQVRzr3NpZL6g2iga0IBSVVHSVhGE3C1zpNM7TVXJ6lSG8-7OjsjKmveLBghfumJ6ugwmgXrHYp4JjFBbBuS6zK-4MIs1ICtA/s1600/ACK_routing_multiple_ifs.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;828&quot; data-original-width=&quot;1007&quot; height=&quot;327&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4a_no538ZxALs72Lfb1ASY2hyym43Anx7cCtKE0ayd6rQVRzr3NpZL6g2iga0IBSVVHSVhGE3C1zpNM7TVXJ6lSG8-7OjsjKmveLBghfumJ6ugwmgXrHYp4JjFBbBuS6zK-4MIs1ICtA/s400/ACK_routing_multiple_ifs.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
All Record-Route headers are assumed to carry loose routing URIs (they have the ;lr attribute).&lt;br /&gt;
&lt;br /&gt;
B, C and D, working as proxies that want to stay in the path, record route themselves. For this reason E, the UAS and &quot;callee&quot;, receives an INVITE with a list of Record-Route headers with B, C and D.&lt;br /&gt;
In particular for B there will be two Record-Route headers, since B is using two separate interfaces, one facing A and the other facing C.&lt;br /&gt;
&lt;br /&gt;
In typical cases the two interfaces represent the interaction with the public Internet on a side and a private infrastructure on the other. But it&#39;s not important for this discussion.&lt;br /&gt;
&lt;br /&gt;
Omitting provisional responses for simplicity, let&#39;s assume E responds immediately with a 200 OK. This response will have the same list of R-R headers, in the same order, as received by E.&lt;br /&gt;
E will also add its URI in the Contact header of the 200 OK.&lt;br /&gt;
&lt;br /&gt;
In this loose routing context the IP address in E&#39;s Contact&#39;s URI will be relevant only for D in the future.&lt;br /&gt;
&lt;br /&gt;
D, C and B don&#39;t modify the list of Record-Route headers, and A receives it as sent by E.&lt;br /&gt;
&lt;br /&gt;
Apart from the operations related to the media session set up, A will send the ACK to the 200 OK.&lt;br /&gt;
This ACK will have a Request URI with E&#39;s Contact URI (stripped of anything that can&#39;t se inside a Request URI), and a Route header list which is basically the received Record-Route header list inverted (see images).&lt;br /&gt;
&lt;br /&gt;
A is saying: &quot;Route this ACK to E, routing it via this list of hops&quot;.&lt;br /&gt;
&lt;br /&gt;
When B receives that ACK, it must recognise that the topmost Route headers are B itself, remove them from the Route list, and pick b2 as the interface to deliver the ACK to C.&lt;br /&gt;
&lt;br /&gt;
C and D will have an easier task to remove a single Route header, the one representing them, and deliver the ACK to the next route.&lt;br /&gt;
&lt;br /&gt;
For D, the next route will be in fact E, and the ACK will be routed using only the Request URI, as the Route headers have all been eliminated. This is the only step where the IP address that E has set in the Contact of its 200 OK response needs to be visible by another entity, namely D.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
ACK routing as explained in RFC 3665&lt;/h2&gt;
&lt;br /&gt;
To further reiterate this concept, let&#39;s look at a somewhat simpler example in &lt;a href=&quot;https://tools.ietf.org/html/rfc3665#section-3.2&quot; target=&quot;_blank&quot;&gt;RFC 3665&lt;/a&gt;.&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;; font-size: 11pt; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;The ACK part is:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;

&lt;script src=&quot;https://gist.github.com/giavac/11f9cbfda014595a7bd9bd03d3c52960.js&quot;&gt;&lt;/script&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 14.6667px; white-space: pre-wrap;&quot;&gt;You can see there&#39;s no requirement for Proxy 1 to be able to reach the UAC contact (client.biloxi.example.com might be completely unreachable from Proxy 1).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 14.6667px; white-space: pre-wrap;&quot;&gt;It&#39;s Proxy 2&#39;s responsibility to route the ACK in the last hop towards Bob.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 14.6667px; white-space: pre-wrap;&quot;&gt;Proxy 1 must leave the R-URI as is (see below for more details on proxy behaviour), strip itself from the list of Routes and route the ACK to the new topmost Route (Proxy 2).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 14.6667px; white-space: pre-wrap;&quot;&gt;Proxy 2 will strip itself from the Route list, being the topmost Route, and forward the ACK to Bob. There are no more Route headers.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 14.6667px; white-space: pre-wrap;&quot;&gt;Only at the last hop Bob&#39;s contact reachability is relevant, and it is for Proxy 2 only.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;
More about the behaviour of the proxies to corroborate the ACK routing&lt;/h2&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;From RFC 3261, 16.4:&lt;/span&gt;&lt;/div&gt;
&lt;span id=&quot;docs-internal-guid-53052e44-ef21-461a-dff0-cb8aa6158ba8&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;; font-size: 10pt; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;“ &amp;nbsp;If the first value in the Route header field indicates this proxy,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;; font-size: 10pt; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;; font-size: 10pt; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;the proxy MUST remove that value from the request.”&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;; font-size: 10pt; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px; white-space: pre-wrap;&quot;&gt;From RFC 3261, 16.5:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px; white-space: pre-wrap;&quot;&gt;“&amp;nbsp; &amp;nbsp; &amp;nbsp;A proxy can only change the Request-URI of a request during&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px; white-space: pre-wrap;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; forwarding if it is responsible for that URI.”&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;h2&gt;
APPENDIX - Why is the ACK to 200 OK to INVITE a separate transaction?&lt;/h2&gt;
&lt;br /&gt;
From RFC 3261, ch. 17:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;The reason for this separation is rooted in the importance of&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; delivering all 200 (OK) responses to an INVITE to the UAC.&amp;nbsp; To&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; deliver them all to the UAC, the UAS alone takes responsibility&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; for retransmitting them (see Section 13.3.1.4), and the UAC alone&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; takes responsibility for acknowledging them with ACK (see Section&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; 13.2.2.4).&amp;nbsp; Since this ACK is retransmitted only by the UAC, it is&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; effectively considered its own transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/2981187770511459866'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/2981187770511459866'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2018/01/sip-ack-loose-routing.html' title='SIP - ACK loose routing'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4a_no538ZxALs72Lfb1ASY2hyym43Anx7cCtKE0ayd6rQVRzr3NpZL6g2iga0IBSVVHSVhGE3C1zpNM7TVXJ6lSG8-7OjsjKmveLBghfumJ6ugwmgXrHYp4JjFBbBuS6zK-4MIs1ICtA/s72-c/ACK_routing_multiple_ifs.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-8144197696895798371</id><published>2018-01-09T11:29:00.001+01:00</published><updated>2018-01-09T11:29:53.246+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="docker"/><title type='text'>Copying a file from a Docker container to the host</title><content type='html'>Often things are more convoluted than you expect. Sometimes they are easier than you fear.&lt;br /&gt;
&lt;br /&gt;
Here&#39;s an example: you&#39;re generating files inside a Docker container (with no volumes configured) and you realise you need some of those files available in the host.&lt;br /&gt;
&lt;br /&gt;
A simple solution is to use &#39;docker cp&#39;, with a format like&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;docker cp CONTAINER_ID:FILE_PATH HOST_FILE_PATH&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://docs.docker.com/engine/reference/commandline/cp/&quot; target=&quot;_blank&quot;&gt;Official documentation&lt;/a&gt;.&lt;br /&gt;
&lt;a href=&quot;https://stackoverflow.com/questions/22049212/copying-files-from-docker-container-to-host&quot; target=&quot;_blank&quot;&gt;A Stackoverflow question with more discussions&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/8144197696895798371'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/8144197696895798371'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2018/01/copying-file-from-docker-container-to.html' title='Copying a file from a Docker container to the host'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-9031922773224056133.post-3555412594231622196</id><published>2017-11-30T12:05:00.000+01:00</published><updated>2017-11-30T12:42:13.295+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="debian"/><category scheme="http://www.blogger.com/atom/ns#" term="PCAP"/><category scheme="http://www.blogger.com/atom/ns#" term="sipp"/><category scheme="http://www.blogger.com/atom/ns#" term="VoIP"/><title type='text'>Around sipp with pcap and authentication support</title><content type='html'>This is just a practical guide to have latest &lt;a href=&quot;http://sipp.sourceforge.net/doc/reference.html&quot; target=&quot;_blank&quot;&gt;sipp&lt;/a&gt; on &lt;a href=&quot;https://www.debian.org/&quot; target=&quot;_blank&quot;&gt;debian&lt;/a&gt;, to benefit from features that are not available in the stock package (&lt;a href=&quot;https://packages.debian.org/jessie/sip-tester&quot; target=&quot;_blank&quot;&gt;sip-tester&lt;/a&gt;&amp;nbsp;- version 3.2.1). For example support for playing pcap files or computing authentication hashes.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Build sipp with pcap support&lt;/h2&gt;
&lt;br /&gt;
&lt;i&gt;apt-get install autoconf libncurses5-dev libpcap-dev g++&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;cd /usr/local/src/&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;git clone https://github.com/SIPp/sipp.git&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;cd sipp/&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;./build.sh --with-pcap&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
./sipp is the built binary. You can see the version and capabilities with &#39;./sipp -v&#39;, e.g.:&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;$ ./sipp -v&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;SIPp v3.6-dev-149-gb95f98f-PCAP-RTPSTREAM.&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;...&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
This version will be able to use actions like&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;exec rtp_stream=&quot;file.wav&quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;exec play_pcap_audio=&quot;pcap/g711a.pcap&quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
(see details in &lt;a href=&quot;http://sipp.sourceforge.net/doc/reference.html&quot; target=&quot;_blank&quot;&gt;current documentation&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;A little caveat for &#39;rtp_stream&#39; and WAV files&lt;/b&gt;. As the documentation says sipp expects a WAV file encoded with PCAM (&#39;A-law&#39;). You can also loop that audio for as long as you need, by adding &#39;&lt;b&gt;,-1&lt;/b&gt;&#39; after the file name (and within the double quotes).&lt;br /&gt;
But sipp will also send the WAV header in the RTP payload. If this is not acceptable for you, then you can strip the WAV header with something like:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;sox -t WAV -r 8000 -c 1 -e a-law audio.wav audio.raw&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
(where sox is &lt;a href=&quot;https://en.wikipedia.org/wiki/SoX&quot; target=&quot;_blank&quot;&gt;this tool&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
play_pcap_audio is useful when you want full control of the RTP produced by sipp, e.g. the exact RTP SSRC, missing packets, Mark set bits, etc. Very powerful.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Add authentication support&lt;/h2&gt;
&lt;br /&gt;
Same dependencies as above, but add:&lt;br /&gt;
&lt;div&gt;
&lt;i&gt;apt-get install libssl-dev
&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;i&gt;./build.sh --with-pcap&amp;nbsp;--with-openssl&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
./sipp is the built binary. You can see the version and capabilities with &#39;./sipp -v&#39;, e.g.:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;$ ./sipp -v&lt;/i&gt;&lt;br /&gt;
&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;&lt;i&gt;

SIPp v3.6-dev-149-gb95f98f-TLS-PCAP-RTPSTREAM.&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;...&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
See the authentication features in &lt;a href=&quot;http://sipp.sourceforge.net/doc/reference.html&quot; target=&quot;_blank&quot;&gt;current documentation&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
More to come around these topics soon.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/3555412594231622196'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/9031922773224056133/posts/default/3555412594231622196'/><link rel='alternate' type='text/html' href='https://www.giacomovacca.com/2017/11/around-sipp-with-pcap-and.html' title='Around sipp with pcap and authentication support'/><author><name>Giacomo Vacca</name><uri>http://www.blogger.com/profile/15806655752624396579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>