<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Krunal Patel on Medium]]></title>
        <description><![CDATA[Stories by Krunal Patel on Medium]]></description>
        <link>https://medium.com/@embedx?source=rss-14c2d6c24d69------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tnnB2ronTf7KwmYOZbt-Cw.png</url>
            <title>Stories by Krunal Patel on Medium</title>
            <link>https://medium.com/@embedx?source=rss-14c2d6c24d69------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 14:28:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@embedx/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Link Adaptation]]></title>
            <link>https://embedx.medium.com/link-adaptation-a73d1b27804a?source=rss-14c2d6c24d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/a73d1b27804a</guid>
            <dc:creator><![CDATA[Krunal Patel]]></dc:creator>
            <pubDate>Fri, 23 Jan 2026 14:16:36 GMT</pubDate>
            <atom:updated>2026-01-23T14:23:49.483Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine you’re talking to a friend across a room:</p><ul><li>If the room is quiet, you can speak softly and still be understood.</li><li>If the room is noisy, you naturally raise your voice or speak more slowly so your friend understands every word.</li></ul><p><strong>Link Adaptation in telecom works exactly the same way.</strong></p><ul><li>The <strong>room</strong> is the wireless environment (signal strength, interference, distance).</li><li>The <strong>voice</strong> is how the network sends data (fast and complex when conditions are good, slower and simpler when conditions are tough).</li><li>The <strong>friend</strong> is the UE (phone), which needs to understand the message clearly.</li></ul><p><em>So, </em><strong><em>Link Adaptation is the network’s way of adjusting how it talks to your phone depending on the radio conditions.</em></strong></p><ul><li>If the signal is strong → it uses faster, more efficient methods (like speaking quickly).</li><li>If the signal is weak → it switches to safer, slower methods (like speaking slowly and clearly).</li></ul><blockquote>The goal is simple: <strong>keep the conversation going smoothly, without too many “Can you repeat that?” moments.</strong></blockquote><p><strong>A Simple Data Download Example</strong></p><p>Imagine you’re downloading a big file.</p><ul><li>If your connection is <strong>strong and clean</strong>, the network says: <br> <em>“Great, let’s send data in big chunks, fast!” ===&gt; </em>Your download finishes fast.</li><li>But if the interference increases or the signal weakens, those big chunks start getting corrupted. <br> The system has to resend them again and again <em>===&gt;</em> slowing everything down.</li><li>So the network adapts: <em>“</em><strong><em>Okay, let’s send smaller, safer chunks so they don’t get lost.</em></strong><em>”</em></li><li><strong>The result</strong>: <br>Lower speed, Fewer errors, No constant retries</li></ul><blockquote><strong>This dynamic adjustment is Link Adaptation.</strong></blockquote><p>In 5G NR, Link Adaptation (<strong>AMC: adaptive modulation and coding</strong>) is the mechanism that dynamically adjusts the Modulation and Coding Scheme (MCS) based on real-time channel conditions, guided by UE feedback (CQI and or HARQ’s ACK NACK). <strong><em>38.300 — 5.2.5.1 Link adaptation</em></strong></p><p><strong>A</strong>daptive <strong>M</strong>odulation and <strong>C</strong>oding is a <strong>cross-layer mechanism</strong> spanning <strong>PHY, MAC, and RRC</strong>, with <strong>decision ownership in MAC Scheduler</strong>.</p><p><strong>In Keywords to check in 3GPP Specifications:</strong></p><ul><li><strong>CQI, MCS tables, and BLER targets</strong> are documented in <strong>PHY specs</strong></li><li><strong>Scheduling, HARQ, and retransmissions</strong> are defined in <strong>MAC specs</strong></li></ul><p><strong>High-Level AMC Flow:</strong></p><ol><li>UE measures <strong>channel quality using CSI reference</strong> signals ==&gt; sends CQI to the gNB via PUCCH.</li><li>MAC Scheduler <strong>maps CQI index ==&gt; MCS</strong> index and decides resources ==&gt; sends DCI via PDCCH.</li><li>Data transmitted via PDSCH ==&gt; UE decodes and UE sends HARQ ACK/NACK via PUCCH.</li><li>Scheduler adjusts future MCS based on CQI + HARQ feedback.</li><li>RRC configures the rules for CQI/HARQ reporting and measurement</li></ol><p>— — —</p><p><strong>Measurement &amp; Reporting (UE ==&gt; gNB)</strong></p><ul><li>UE measures channel quality using Channel State Information Reference Signal (CSI-RS).</li><li>It generates a CQI (Channel Quality Indicator) report and sent back to the gNB via PUCCH (F2) <em>- Spec reference: 3GPP TS 38.214 §5.2.2 (CQI reporting).</em></li><li><strong><em>RRC Configures</em>: </strong><br>- CSI-RS resources for measurement<br>- CQI reporting periodicity and type (wideband / subband)<br>- <em>TS 38.214 NZP CSI-RS resource for channel measurement as described in clause 5.2.2.3.1.</em></li></ul><p>— — —</p><p><strong>MAC Scheduler Decision (gNB side</strong>)</p><ul><li>The MAC scheduler at the base station decides the UE-wise Transport block (PRB allocation)No for every slot.</li><li>The MAC scheduler at the gNB receives CQI feedback from PHY over the FAPI interface.</li><li>It decides which UE gets resources (time/frequency slots), and what MCS to use. then scheduler adjusts the CQI, keeping the Target BLER 10%.</li><li>Once the scheduler decides, it sends <strong>DCI via PDCCH, </strong>informing the UE about Resource allocation (RBs, slots) and MCS index to be used for decoding<br><em>- MCS index (TS 38.214 5.1.3.1 — Table 5.1.3.1–1/2/3) <br>- DCI: (38.212 7.3.1.2 DCI formats for scheduling of PDSCH)</em></li></ul><p>— — —</p><p><strong>UE Feedback to gNB</strong></p><p>UE receives data on PDSCH using the MCS indicated in DCI , UE sends <strong>Feedback back to gNB in two ways,</strong></p><ol><li><strong>HARQ Feedback</strong></li></ol><ul><li>ACK → decoding successful</li><li>NACK → decoding failed, retransmission required</li><li>This feedback is sent via PUCCH. <em>(TS 38.321 5.3.2 HARQ operation)</em></li></ul><p><strong>2. CQI Reporting</strong></p><ul><li>UE continues to report CQI periodically</li><li>Allows the scheduler to adapt future transmissions</li></ul><p>— — —</p><p><strong>RRC Layer Configurations</strong></p><p>The RRC layer does not perform Link Adaptation directly, but it <strong>controls how it operates</strong> by configuring:</p><ul><li>CQI reporting periodicity and format</li><li>CSI measurement resources and reporting</li><li>HARQ process parameters (number of processes, timers).</li><li>RRC ensures UE and gNB are aligned on measurement/reporting rules. (TS 38.331 RRC signalling 6.2.3).</li></ul><p>— — —</p><p><strong>Key 3GPP Specifications to Refer</strong></p><ul><li>TS 38.212 — Channel coding and MCS definitions</li><li>TS 38.214 — CQI reporting and link adaptation procedures</li><li>TS 38.321 — MAC protocol and HARQ operation</li><li>TS 38.331 — RRC signalling and CSI configuration</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a73d1b27804a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Base Station (gNB) know the UE Pathloss?]]></title>
            <link>https://embedx.medium.com/how-base-station-gnb-know-the-ue-pathloss-d7fd3410c6cd?source=rss-14c2d6c24d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7fd3410c6cd</guid>
            <category><![CDATA[cqi]]></category>
            <category><![CDATA[telecom]]></category>
            <category><![CDATA[wireless-communication]]></category>
            <category><![CDATA[mimo]]></category>
            <category><![CDATA[5g]]></category>
            <dc:creator><![CDATA[Krunal Patel]]></dc:creator>
            <pubDate>Sun, 22 Sep 2024 19:06:14 GMT</pubDate>
            <atom:updated>2024-09-22T19:06:14.291Z</atom:updated>
            <content:encoded><![CDATA[<p>Certainly! In 5G NR (New Radio), <strong>pathloss information</strong> is crucial for the gNB (gNodeB) to make decisions about power control, beamforming, and link adaptation. This information allows the network to adjust the transmit power for efficient communication. The UE (User Equipment) indirectly provides this information through <strong>uplink reference signals</strong>, which the gNB uses to estimate pathloss.</p><p>In 5G NR, the gNB (gNodeB) estimates the <strong>UE&#39;s pathloss</strong> using various uplink reference signals that the UE transmits. The gNB doesn&#39;t receive pathloss information directly from the UE; rather, it calculates the pathloss by comparing the power of the signals sent by the UE with the known transmit power of the UE.</p><p>Here’s a detailed breakdown of how the gNB estimates the UE’s pathloss:</p><h3>1. Sounding Reference Signal (SRS)</h3><p><strong>Purpose</strong>: The SRS is the primary signal used for uplink channel sounding, including <strong>pathloss estimation</strong>.</p><p><strong>How it Works</strong>:</p><ul><li>The UE transmits the SRS at a known power level.</li><li>The gNB measures the received power of the SRS and compares it with the known transmit power of the UE.</li><li>Using this difference (between the transmitted and received power), the gNB calculates the <strong>pathloss</strong>.</li></ul><p><strong>Frequency-Domain Coverage</strong>: SRS is typically transmitted over a wider frequency range, allowing the gNB to estimate pathloss over various frequency bands.</p><p><strong>Channel Used</strong>:</p><ul><li>The <strong>Physical Uplink Control Channel (PUCCH)</strong> can carry the SRS when the UE sends control information like CSI.</li><li>The <strong>Physical Uplink Shared Channel (PUSCH)</strong> is used when the UE is transmitting data along with the SRS, typically when the UE is scheduled for data transmission.</li></ul><h3>2. Uplink Reference Signals</h3><ul><li>In addition to SRS, other uplink reference signals like <strong>Demodulation Reference Signals (DM-RS)</strong>, which are transmitted along with uplink data on the <strong>Physical Uplink Shared Channel (PUSCH)</strong>, can also be used to estimate pathloss.</li></ul><p><strong>How it Works</strong>:</p><ul><li>When the UE sends uplink data, it also transmits DM-RS for channel estimation and demodulation.</li><li>The gNB can measure the power of DM-RS, calculate the pathloss, and adjust the link accordingly.</li></ul><h3>3. Pathloss Estimation Formula</h3><p>Pathloss is typically estimated using the following formula:</p><p>. . . . . . . . . . . . <strong>Pathloss</strong>=<strong>P</strong><em>transmit</em>−<strong>P</strong><em>received </em>. . . . . . . . . . . .</p><p>Where:</p><ul><li><strong>P</strong><em>transmit </em>is the transmit power of the UE (which is known or can be derived based on power control settings).</li><li><strong>P</strong><em>received</em> is the power of the signal received by the gNB (measured at the gNB).</li></ul><h3>4. Power Control Mechanisms</h3><p>The UE uses a <strong>power control formula</strong> that allows the gNB to instruct the UE on how much power to transmit. For this, the gNB needs to continuously estimate the pathloss to maintain the link’s quality.</p><p><strong>Open-Loop Power Control:</strong></p><ul><li>Initially, the UE calculates its transmit power based on estimated pathloss and a predefined set of parameters provided by the gNB (like reference signal power and cell-specific power control parameters).</li></ul><p><strong>Closed-Loop Power Control:</strong></p><ul><li>During communication, the gNB fine-tunes the UE’s transmit power using pathloss measurements from uplink signals like SRS or DM-RS. The gNB sends power control commands to the UE to adjust its power based on the current pathloss.</li></ul><h3>5. Uplink Control Information (UCI)</h3><ul><li>Although UCI (like Channel State Information - CSI) reports provide information on channel conditions, the UE does not directly report pathloss. Instead, it sends <strong>CQI (Channel Quality Indicator)</strong>, <strong>PMI (Precoding Matrix Indicator)</strong>, and <strong>RI (Rank Indicator)</strong>, which reflect the downlink channel conditions. However, the gNB primarily relies on <strong>uplink reference signals</strong> (e.g., SRS) for uplink pathloss estimation.</li></ul><h3>Example Process:</h3><ol><li><strong>SRS Transmission</strong>: The UE transmits the SRS at a specific power level.</li><li><strong>Signal Reception</strong>: The gNB receives the SRS and measures its power.</li><li><strong>Pathloss Calculation</strong>: <br><em>The gNB compares the measured power with the known transmit power of the SRS.<br>Using the difference between these two values, the gNB calculates the </em><strong><em>pathloss</em></strong><em>.</em></li><li><strong>Power Control Adjustment</strong>: Based on this pathloss estimation, the gNB may adjust the UE’s transmission power using <strong>uplink power control commands</strong> to maintain an optimal communication link.</li></ol><h3>Conclusion:</h3><p>The gNB estimates the UE’s pathloss primarily by using the <strong>SRS</strong> and other uplink reference signals, such as <strong>DM-RS</strong>. By measuring the power of these signals and comparing them to the UE’s known transmit power, the gNB calculates the pathloss and adjusts uplink transmission settings accordingly to ensure efficient communication and optimal resource usage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7fd3410c6cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RACH Failure Reasons in 5G NR]]></title>
            <link>https://embedx.medium.com/rach-failure-reasons-in-5g-nr-af9212de5631?source=rss-14c2d6c24d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/af9212de5631</guid>
            <dc:creator><![CDATA[Krunal Patel]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 13:18:08 GMT</pubDate>
            <atom:updated>2024-08-27T13:18:08.400Z</atom:updated>
            <content:encoded><![CDATA[<p>RACH (Random Access Channel) failures in 5G NR can occur due to various issues, each stemming from different aspects of the RACH procedure. Below is a comprehensive list of potential reasons for RACH failures in 5G NR.</p><p>The RACH process is primarily a PHY/MAC level procedure, but its configuration is managed by the upper layers, specifically the RRC (Radio Resource Control) layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/0*Ce_YD2sd0KB6RcFT" /></figure><h4>Incorrect PrachConfigCommon</h4><p>One common reason for RACH failure is an incorrect PRACH (Physical Random Access Channel) configuration. The UE (User Equipment) can receive an incorrect PRACH configuration from the upper layers, either through a dedicated message during handover, a message for NSA (Non-Standalone) addition, or from SIB1 (System Information Block 1) during initial acquisition. When the UE receives any message, it checks the ASN (Abstract Syntax Notation) and validates it before passing the information to the lower layers.</p><p>In the case of RACH configuration, the RRC layer checks and validates the configuration before sending it to the PHY/MAC layers. A common issue is the incorrect mapping of SSBperRACHocassion.</p><p><strong>Sample NR RACH Configuration:</strong></p><pre>## Sample NR RACH Configuration ##<br><br>     rach-ConfigCommon setup :<br>                     rach-ConfigGeneric<br>                     prach-ConfigurationIndex 75,<br>                     msg1-FDM one,<br>                     msg1-FrequencyStart 0,<br>                     zeroCorrelationZoneConfig 0,<br>                     preambleReceivedTargetPower -109,<br>                     preambleTransMax n10,<br>                     powerRampingStep dB4,<br>                     ra-ResponseWindow sl20<br>                         ,<br>                     totalNumberOfRA-Preambles 8,<br>                     ssb-perRACH-OccasionAndCB-PreamblesPerSSB one : n8,<br>                     ra-ContentionResolutionTimer sf16,<br>                     prach-RootSequenceIndex l139 : 71,<br>                     msg1-SubcarrierSpacing kHz120,<br>                     restrictedSetConfig unrestrictedSet</pre><h3>Preamble Max Transmissions</h3><p>The gNB (gNodeB) configures the maximum number of preambles the UE can transmit during the RACH process. If the UE does not receive Msg2 (Random Access Response) after sending a RACH preamble, it waits for the random access response timer to expire before triggering RACH again. After a set number of attempts, if no response is received, the UE may declare a RACH failure or restart the RACH process.</p><ul><li><strong>Msg1 Collision in High-Density Cells</strong></li><li><em>In high-density cells, </em><em>Msg1 collision can occur due to multiple UEs transmitting simultaneously, leading to detection failure.</em></li><li><strong>Msg1 detection failure due to low SNR at gNB</strong></li><li><em>Another cause of RACH failure is the detection failure of </em><em>Msg1 due to low Signal-to-Noise Ratio (SNR) at the gNB, particularly if the UE transmits the RACH preamble at a lower power level.</em></li></ul><blockquote><strong>Msg1:</strong> The first message in the RACH procedure, where the UE sends a RACH preamble to initiate communication with the gNB.</blockquote><h4>Msg2 Reception Failure</h4><p>The UE may declare a Msg2 reception failure if it does not detect Msg2 with the RA-RNTI (Random Access Radio Network Temporary Identifier) before the RAR (Random Access Response) timer expires.</p><p>This failure can occur if the gNB does not detect the PRACH transmission and thus does not send Msg2. In such cases, the UE is left unaware of whether Msg1 was successfully received, as only the reception of Msg2 confirms that the gNB has received the PRACH preamble and sent a response.</p><p>In scenarios where the cell or beam is congested, the gNB might not have the resources to allocate PDCCH (Physical Downlink Control Channel) for Msg2 PDSCH (Physical Downlink Shared Channel), resulting in PDCCH blocking and failure to allocate Msg2 resources within the RA Response window.</p><p>If the cell or beam is congested, the gNB might send Msg2 with a Back-off indication, instructing the UE not to trigger RACH for a specified duration.</p><blockquote><strong>Msg2:</strong> The response message sent by the gNB in response to Msg1, containing information for the UE on how to proceed.</blockquote><h4>RAPID Mismatch in Msg2</h4><p>A RAPID (Random Access Preamble ID) mismatch in Msg2 can lead to RACH failure. If the gNB detects a RAPID mismatch, it indicates this in Msg2, prompting the UE to discard Msg2 and reinitiate the RACH process. Additionally, the gNB may include a Back-off timer value in Msg2, with a range from [0–15]. If there is congestion at the gNB, a RAPID mismatch along with a Back-off timer might be sent, instructing the UE to wait for the configured duration before attempting RACH again.</p><p>The Back-off indication is only sent when there is a RAPID mismatch, and the BO value is configured in Msg2. If either is missing, the UE does not apply the Back-off timer.</p><h4>Msg3/Msg4 Failure</h4><p>Failures can also occur at the Msg3 or Msg4 stages. For example, Msg3 detection failure at the gNB may happen if the UE transmits PUSCH (Physical Uplink Shared Channel) at a lower power, causing detection failure. Contention resolution failure occurs if the UE does not receive Msg4 before the contention resolution timer expires, leading to a RACH failure declaration.</p><blockquote><strong><em>Msg3:</em></strong><em> The message sent by the UE after receiving </em><em>Msg2, containing information about the uplink resource request.</em></blockquote><blockquote><strong><em>Msg4:</em></strong><em> The final message in the RACH procedure, sent by the gNB, confirming the contention resolution and the successful establishment of the connection.</em></blockquote><p>#5GNR #RACH #RACHFailure #WirelessCommunication #gNB #PHYLayer #MACLayer #RRC #RandomAccessChannel #Msg1 #Msg2 #Msg3 #Msg4 #PrachConfigCommon #PreambleTransmission #SNR #BackoffTimer #RAPIDMismatch #ContentionResolution</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af9212de5631" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Key RRC Procedures in 5G: A Visual Breakdown ]]></title>
            <link>https://embedx.medium.com/mastering-key-rrc-procedures-in-5g-a-visual-breakdown-1c0c0f3f344f?source=rss-14c2d6c24d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c0c0f3f344f</guid>
            <category><![CDATA[rrc]]></category>
            <category><![CDATA[network]]></category>
            <category><![CDATA[telecommunication]]></category>
            <category><![CDATA[5g-nr]]></category>
            <category><![CDATA[5g-technology]]></category>
            <dc:creator><![CDATA[Krunal Patel]]></dc:creator>
            <pubDate>Mon, 26 Aug 2024 05:04:43 GMT</pubDate>
            <atom:updated>2024-08-26T05:04:43.946Z</atom:updated>
            <content:encoded><![CDATA[<p>In the dynamic landscape of 5G, Radio Resource Control (RRC) procedures are critical for establishing and maintaining seamless communication between User Equipment (UE) and the network. Let’s explore some of the essential RRC procedures, enhanced with a visual guide for clarity! 📊</p><h3>1. Paging Procedure 🌟</h3><p><strong>Purpose</strong>: Alerts the UE about incoming communication when it’s in an idle state.</p><p><strong>Process</strong>: The network sends a paging message to the UE, prompting it to initiate a connection.</p><p><strong>Outcome</strong>: This procedure triggers the transition of the UE from idle to connected mode.</p><h3>2. Successful RRC Connection Establishment 🌟</h3><p><strong>Steps</strong>:</p><ul><li><strong>RRC Setup Request</strong>: The UE sends a request to the network to establish a connection.</li><li><strong>RRC Setup</strong>: The network processes the request and allocates the required resources.</li><li><strong>RRC Setup Complete</strong>: The UE confirms the successful establishment of the connection.</li></ul><p><strong>Outcome</strong>: The UE is now in connected mode, ready for data transmission.</p><h3>3. RRC Connection Establishment Rejected 🌟</h3><p><strong>Steps</strong>:</p><ul><li><strong>RRC Setup Request</strong>: The UE initiates a connection request, similar to the successful procedure.</li><li><strong>RRC Reject</strong>: The network denies the request, possibly due to resource limitations.</li></ul><p><strong>Outcome</strong>: The connection is not established, and the UE remains in idle mode.</p><h3>4. Successful Security Mode Command 🌟</h3><p><strong>Steps</strong>:</p><ul><li><strong>Security Mode Command</strong>: The network initiates security procedures to protect communication.</li><li><strong>Security Mode Complete</strong>: The UE confirms that the security settings are successfully applied.</li></ul><p><strong>Outcome</strong>: Communication is now secure, enabling safe data exchange between the UE and the network.</p><h3>5. Successful RRC Reconfiguration 🌟</h3><p><strong>Steps</strong>:</p><ul><li><strong>RRC Reconfiguration</strong>: The network may modify existing connection parameters to enhance performance.</li><li><strong>RRC Reconfiguration Complete</strong>: The UE confirms the successful application of the new settings.</li></ul><p><strong>Outcome</strong>: The connection is optimized, ensuring efficient and reliable communication.</p><p>For professionals in the telecommunications industry, understanding these RRC procedures is essential, especially as 5G technology rapidly evolves. Each procedure plays a pivotal role in maintaining the stability, security, and efficiency of the network.</p><p>Keep these processes top of mind — they’re the backbone of 5G communication! 💡</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*Q6f1Hsck2P_BqdAtCov0Fg.png" /><figcaption>RRC Procedure</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c0c0f3f344f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Know about 4G & 5G UE Capability Message]]></title>
            <link>https://embedx.medium.com/know-about-4g-5g-ue-capability-message-4d9bdef51d85?source=rss-14c2d6c24d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d9bdef51d85</guid>
            <dc:creator><![CDATA[Krunal Patel]]></dc:creator>
            <pubDate>Mon, 24 Jun 2024 09:44:12 GMT</pubDate>
            <atom:updated>2024-06-24T09:44:12.161Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>This article will delve into the crucial aspects of 4G and 5G UE (User Equipment) Capability messages. Understanding UE Capability messages is vital for network troubleshooting, feature testing, and benchmarking new devices. By familiarizing yourself with UE Capability information, you’ll gain insights into key data such as 4G Carrier Aggregation combinations and ENDC (E-UTRA-NR Dual Connectivity) capabilities. This knowledge is indispensable for anyone involved in network management and device testing.</blockquote><h3>What You’ll Learn in This Article</h3><ol><li><strong>Understanding the UE Capabilities Message:</strong> Explore what the UE Capabilities message is and its significance.</li><li><strong>3GPP Insights on Band Combinations:</strong> Get an in-depth explanation of different band combinations as defined by 3GPP.</li><li><strong>User Guide to Reading 4G CA &amp; NR-ENDC Band Combinations:</strong> Learn how to interpret 4G Carrier Aggregation (CA) and NR-Evolved Universal Terrestrial Radio Access Network Dual Connectivity (NR-ENDC) band combinations.</li><li><strong>UE Capability Signaling Limitations and 3GPP Solutions:</strong> Discover the limitations in UE capability signaling and the solutions proposed by 3GPP.</li></ol><h3>Understanding the UE Capabilities Message</h3><h4>What is the UE Capabilities Message?</h4><p>The UE (User Equipment) capabilities message is a critical component of RRC (Radio Resource Control) signaling. This message allows the UE to communicate its capabilities to the network.</p><h4>Why is it Needed?</h4><p>By receiving the UE capabilities information, the Base Transceiver Station (BTS) can make accurate scheduling decisions, optimizing network performance and ensuring efficient resource allocation.</p><h4>What Information is Covered?</h4><p>The UE capabilities message includes both network and radio capabilities:</p><p><strong>1. Network Capability:</strong> This information is included in the Attach Request and may include the following:</p><ul><li><strong>SRVCC to GERAN &amp; UTRAN Capability</strong>: Support for Single Radio Voice Call Continuity.</li><li><strong>Voice Domain Preference</strong>: The preferred domain for voice services.</li><li><strong>n1Mode Capability for E-UTRAN</strong>: Support for a specific mode in Evolved Universal Terrestrial Radio Access Network.</li><li><strong>dCNR Capability</strong>: Support for different coverage and network configurations.</li></ul><p><strong>2. Radio Capability:</strong> This information is included in the UE capability information and may include the following:</p><ul><li><strong>UE Category</strong>: Defines the capabilities and performance of the UE.</li><li><strong>PDCP, RLC, MAC, PHY Parameters</strong>: Parameters related to Packet Data Convergence Protocol, Radio Link Control, Medium Access Control, and Physical Layer.</li><li><strong>RF Parameters (Includes Band Combination)</strong>: Radio Frequency parameters, including supported band combinations.</li><li><strong>FGI (Feature Group Indicators)</strong>: Indicators of supported features.</li><li><strong>fr1-Add-UE-NR-Capabilities</strong>: Additional capabilities for New Radio (NR) in Frequency Range 1.</li></ul><p>By understanding these capabilities, the network can better manage connections, improving the overall user experience and network efficiency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vpL753gv2tFbXjiP" /></figure><h3>Understanding 3GPP Band Combinations for Carrier Aggregation</h3><p>In this post, we’ll explore the 3GPP tables that detail the various bandwidth classes for Carrier Aggregation (CA). These tables serve as essential guides to understanding how different bands can be combined, including EN-DC (E-UTRA NR Dual Connectivity) combinations.</p><p>Carrier Aggregation (CA) and EN-DC are critical for enhancing network performance by allowing multiple frequency bands to be used simultaneously. This increases data rates, improves coverage, and ensures a more efficient use of the available spectrum.</p><p>Let’s dive into the 3GPP tables and decode the complexities of these band combinations.</p><figure><img alt="ts_136101v151600p(LTE)" src="https://cdn-images-1.medium.com/max/608/0*Kza1iUsd5PsfN6Xn" /><figcaption>ts_136101v151600p(LTE)</figcaption></figure><figure><img alt="ts_13810101v160500p(5G)" src="https://cdn-images-1.medium.com/max/608/0*z1ougTv-Nw_TiMQv" /><figcaption>ts_13810101v160500p(5G)</figcaption></figure><h3>3GPP Tables of different band combinations for 4G&amp;5G</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VAdKiFPEwolh0I9k" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DYy6O7JE4AHKWUDu" /></figure><h3>User Guide: How to Read 4G CA &amp; NR-ENDC Band Combinations</h3><h4>Understanding 4G CA Band Combinations</h4><p><strong>4G CA Band Combination Example:</strong></p><p><strong><em>CA Combination = B1A_B1A_B3C = 4 Carriers</em></strong></p><p><strong>Explanation:</strong></p><p><strong><em>1A: <br>1 = LTE Band 1 | A = A single Component Carrier (CC) of up to 100 Physical Resource Blocks (PRBs), non-contiguous.</em></strong></p><p><strong><em>3C:<br>3</em></strong><em> = LTE Band 3 | </em><strong><em>C</em></strong><em> = Two contiguous CCs, with a total of up to 200 PRBs.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*DtsdPMWR8lbaayEC" /></figure><h3>Understanding EN-DC Band Combinations</h3><p><strong>ENDC Band Combination Example:</strong></p><p><strong><em>DC Combination = B1A_B3A_B41C = 4 LTE CA + 1 NR</em></strong></p><p><strong>Explanation:</strong></p><p><strong><em>1A: <br>1</em></strong><em> = LTE Band 1 | </em><strong><em>A</em></strong><em> = A single CC of up to 100 PRBs, non-contiguous.</em></p><p><strong><em>3A: <br>3</em></strong><em> = LTE Band 3 | </em><strong><em>A</em></strong><em> = A single CC of up to 100 PRBs, non-contiguous.</em></p><p><strong><em>41C: <br>41</em></strong><em> = LTE Band 41 | </em><strong><em>C</em></strong><em> = Two contiguous CCs, with a total of up to 200 PRBs.</em></p><p><strong><em>77A: <br>77</em></strong><em> = NR Band 77 | </em><strong><em>A</em></strong><em> = A single CC.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*OFNalPVl1i37ZV6J" /></figure><h3>UE Capability Signaling Limitation and the 3GPP Proposed Solution</h3><h4>Background</h4><p>In the early stages of Carrier Aggregation (CA), only two Component Carrier (2CC) aggregation was supported, making band combinations relatively simple. However, with the evolution towards higher carrier aggregation configurations, such as 3CC CA, 4CC CA, and 5CC CA, the number of possible band combinations has significantly increased. This complexity has led to an explosion in the size of the UE Capability Information messages.</p><h4>Limitation</h4><p>The primary limitation arises from the size constraint on the Packet Data Convergence Protocol (PDCP) Service Data Unit (SDU) / Protocol Data Unit (PDU), which is capped at 8188 octets. When the UE Capability Information message exceeds this limit, essential capability details can be omitted, leading to potential communication inefficiencies and degraded network performance.</p><h4>Solution</h4><p>To address this issue, the 3rd Generation Partnership Project (3GPP) has proposed a solution. The network can either:</p><ol><li><strong>Request Additional UE Capability Information:</strong> The network can prompt the UE to send further capability details if the initial message is insufficient.</li><li><strong>Streamlined Capability Information:</strong> The network can instruct the UE to transmit only the capability information relevant to the current network requirements, thus avoiding unnecessary data that contributes to message bloat.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/0*Mb6UlE2lrkZiHhF4" /></figure><p>These solutions aim to optimize the communication of UE capabilities, ensuring that all necessary information is conveyed without exceeding the size limitations of PDCP SDU/PDU.</p><blockquote>Thank You!</blockquote><p>#4G #5G #CarrierAggregation #UECapability #3GPP #NetworkOptimization #ENDC #Telecom #WirelessCommunication #NetworkManagement #DeviceTesting #RadioResourceControl #TelecomSolutions #NetworkPerformance #Bandwidth #TechBlog #TelecomInsights</p><h3>Useful Links</h3><ol><li><a href="https://uecapability.smartphonecombo.it/library/">UE Capability Library</a></li><li><a href="https://mail.sharetechnote.com/html/5G/5G_UE_Capability.html">5G UE Capability</a></li><li><a href="https://www.techplayon.com/5g-nr-nsa-mode-ue-network-and-radio-capability-enquiry/">5G NR NSA Mode: UE Network and Radio Capability Enquiry</a></li><li><a href="https://mail.sharetechnote.com/html/5G/5G_LTE_Interworking.html">5G LTE Interworking</a></li><li><a href="https://tech-academy.amarisoft.com/UeCapability.html">UE Capability — Amarisoft Tech Academy</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d9bdef51d85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C Programming: The printf and scanf Family of Functions]]></title>
            <link>https://embedx.medium.com/c-programming-the-printf-and-scanf-family-of-functions-57026c4f05aa?source=rss-14c2d6c24d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/57026c4f05aa</guid>
            <dc:creator><![CDATA[Krunal Patel]]></dc:creator>
            <pubDate>Thu, 20 Apr 2023 08:40:33 GMT</pubDate>
            <atom:updated>2023-04-20T08:40:33.572Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="http://www.nerdkits.com/videos/printf_and_scanf/">http://www.nerdkits.com/videos/printf_and_scanf/</a></p><p>In the course of computer programming, the idea of formatting a string comes up very often. When writing in any programming language, whether it be for a computer or a microcontroller, you are always storing data in specialized data structures (int, double, float, lists) that are not very readable for humans. This means that whenever you are taking input from a user or displaying data for the user, you need to be able to format a string in different ways to represent your data. Converting to a human-readable format can also be useful when passing information between devices, such as sending a sensor reading from a microcontroller to a PC.</p><p>The printf() and scanf() family of functions are part of the standard C library, and make it easy to take input from the user, and display data to the user. Learning how to effectively use these functions can open up a whole world of possibilities when building new projects.</p><p>We make extensive use of the printf and scanf functions in many of our other tutorials, and we highly suggest that you look at those for further examples.</p><p>These are some projects which highlight microcontroller output (printf_P and fprintf_P):</p><ul><li><a href="http://www.nerdkits.com/videos/weighscale/">Digital Scale Strain Gauge Weight Sensor</a></li><li><a href="http://www.nerdkits.com/videos/sound_meter/">Piezoelectric Sound Meter</a></li><li>the Temperature Sensor project described in <a href="http://www.nerdkits.com/kits/">The NerdKits Guide</a></li></ul><p>And here are some projects which highlight microcontroller input (scanf_P):</p><ul><li><a href="http://www.nerdkits.com/videos/rc_car/">iPhone-Controlled R/C Car</a></li><li><a href="http://www.nerdkits.com/videos/ledarray2/">Marquee LED Array Display</a></li><li><a href="http://www.nerdkits.com/videos/servosquirter/">USB Servo-Guided Water Squirter</a></li></ul><p><strong>printf Examples</strong></p><p>The printf function together with the idea of a format string is a very versatile combination, and can be used to display data in pretty much every way you might ever want to. Here, we present some simple examples of the ways printf is often used:</p><p>Variable Initializationprintf ExampleOutputDescriptionint8_t i = 42;printf_P(PSTR(“My Integer: %d”), i);My Integer: 42Printing a standard signed integeruint8_t u = 7;printf_P(PSTR(“My unsigned integer: %u”), u);My unsigned integer: 7Printing a standard unsigned integerint16_t i = 42;printf_P(PSTR(“My Integer: %d”), i);My Integer: 42Printing a standard 16-bit signed integerint32_t i = 42;printf_P(PSTR(“My Integer: %ld”), i);My Integer: 42Printing a standard 32-bit (“long”) signed integerdouble pi = 3.14159;printf_P(PSTR(“I like %lf”),pi);I like 3.14159Printing a double-precision floating point number double pi = 3.14159;printf_P(PSTR(“I like %.2lf”),pi);I like 3.14Printing a double-precision floating point number limited to two digits after the decimal pointuint8_t prime = 7;<br>double pi = 3.14159;printf_P(PSTR(“%u %.2lf”),prime,pi);7 3.14Using more than one variable in a single format string</p><p><strong>The Format String</strong></p><p>The real magic of the printf and scanf functions can be unleashed with effective use of the format string, and all it takes is a little basic understanding of how these special strings work. A format string is basically just a string with placeholders where data should be subsituted in. These placeholders contain all the information necesary about how to display the data. Here is the basic anatomy of a placeholder:</p><pre>&quot;%[flags][width][.precision][length]type&quot;</pre><p>All placeholders start with a % sign, they may then be followed by special flags, then a number representing the width then a. then a number representing the length and then finally the type of value you are representing.</p><p>The only required parts are the % and the type, and most of the time those are the only ones you will see used. For example “%d” means decimal integer, and “%f” means floating-point number. (NOTE: to read in a double with scanf, you must use “%lf” to indicate that it’s a long float. This is a common mistake for new microcontroller programmers — don’t get caught!) One or more of the other parameters can be specified if you want to have more fine tuned control over how the string looks. The tables below show the possible values of the parameters and what they do.</p><p>TypeUseExampledSigned decimal integer (int8_t, int16_t)-7uUnsigned decimal integer (uint8_t, uint16_t)7fFloating point number (float)7.4cCharacter (char)nx or XHexadecimal integerbeef or BEEFoOctal777e or EScientific notation6.022e23 or 2.99E9<br>FlagDescription#Forces “alternate form” of conversion. For %x and %X, it puts 0x or 0X before the hex output. It does not affect most of the other types.0Pads the conversion on the left with zeros (instead of spaces as usual)-The conversion is left-aligned within the display width (instead of right-aligned as usual)spacePuts a space in front of signed conversions (%d) if the number is positive (where a — sign would appear for a negative number).+Forces the conversion to display a sign (+ or -)</p><p>* Note that more than one flag can be used, but some do override others. Check the avr-libc documentation (linked below) for these special cases.</p><p>The width parameter specifies the minimum character width that conversion will take up. By default, the conversion will be as short as it can be to still accommodate the precision required. For example, “%d” with a 7 passed in will simply become “7”, however “%3d” specifies a minimum width of 3 so passing it 7 will result in “ 7” (two spaces followed by a 7). Flags can be used to specify how the number is adjusted and padded.</p><p>The precision specifies the number of digits after the decimal in a floating-point number. A “.” must precede the precision specifier: for example “%.2f” will force any decimal passed to it to have two digits after the decimal point.</p><p><strong>Escape Sequences</strong></p><p>Sometimes it is necessary to use special characters in your format string to get the characters you want past the compiler. For example, to put a “ double-quote in your string, you can’t just write it directly in your code, because the “ character is also used to denote the start and end of a string itself! So to get around this issue, we have to “escape” that character with a backslash. Here is a table of commonly used escape sequences:</p><p>escape codeoutput\””\\\\t[tab]\r\n[new line]</p><p>(Although technically not an escape character, %% in a format string will output a %, since a single % will indicate the start of a substitution placeholder.)</p><p>Newlines are different depending on the operating system. \r\n is the newline sequence on Windows files as well as the standard on serial connections. \n is used as the newline character on Unix and OSX.</p><p><strong>Program Memory versus RAM</strong></p><p>As we explain in the video, there is a slight difference between using printf in “normal” C programming for a computer, and in microcontroller programming. That has to do with the fact that strings are typically stored in program (flash) memory on a microcontroller, so we have to use a little bit of notation to indicate that. For example, on a normal PC you might write:</p><pre>printf(&quot;Hello, world!\r\n&quot;);</pre><p>But if you did this on your microcontroller, you’d probably be disappointed to see that it didn’t work as you expected. That’s because RAM is a precious resource on a microcontroller, and we would prefer to put something constant like that in our flash memory, instead of replicating it both in flash and in RAM each run. (A more detailed technical explanation can be found <a href="http://www.nerdkits.com/forum/thread/100/#post551">on our forum</a>.) So to do the same on the microcontroller, you would write:</p><pre>printf_P(PSTR(&quot;Hello, world!\r\n&quot;));</pre><p>We made two changes: first, by surrounding the string with PSTR(…), we indicate to the compiler that we want that string stored only in program memory. Second, we changed printf to printf_P, which indicates that we want a variant of the printf function that accepts a string stored in program memory instead of RAM like the “normal” printf function expects.</p><p><strong>Trying printf on your PC</strong></p><p>If you’ve got a C compiler such as <a href="http://gcc.gnu.org/">gcc</a> on your computer (Windows users — grab <a href="http://cygwin.com/">Cygwin</a>, Mac OS X and Linux users are probably ready to go), you can make a simple C file and try writing little programs to test your printf/scanf skills. For example, just make a file called “test1.c” and enter these contents:</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;</pre><pre>int main() {<br>  char x[32];<br>  int y = 0;<br>  double z = 0.0;</pre><pre>  printf(&quot;What&#39;s your name? &quot;);<br>  // note the use of fgets instead of scanf(&quot;%s&quot;,...)<br>  // to prevent buffer overflows by specifying a maximum length!<br>  fgets(x, 32, stdin);</pre><pre>  // remove newline<br>  x[strlen(x)-1] = &#39;\0&#39;;</pre><pre>  printf(&quot;Hi, %s!  How old are you? &quot;, x);<br>  scanf(&quot;%d&quot;, &amp;y);</pre><pre>  printf(&quot;What&#39;s your favorite number? &quot;);<br>  scanf(&quot;%lf&quot;, &amp;z);</pre><pre>  printf(&quot;Nice to meet you, %s!  You are %d years old and like the number %f.\n&quot;, x, y, z);<br>  return 0;<br>}</pre><p>Then, open a console, find that directory, and run:</p><pre>gcc -o test1 test1.c; ./test1</pre><p>to compile and run your program. This is an easy way to experiment with C programming even if you don’t have one of our <a href="http://www.nerdkits.com/kits/">educational microcontroller kits</a> yet.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57026c4f05aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5G : PDU Session Establishment]]></title>
            <link>https://embedx.medium.com/5g-pdu-session-establishment-de8daba27eaa?source=rss-14c2d6c24d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/de8daba27eaa</guid>
            <dc:creator><![CDATA[Krunal Patel]]></dc:creator>
            <pubDate>Thu, 20 Apr 2023 08:39:05 GMT</pubDate>
            <atom:updated>2023-04-20T08:39:05.262Z</atom:updated>
            <content:encoded><![CDATA[<h3>5G : PDU Session Establishment</h3><p><a href="https://www.linkedin.com/feed/hashtag/?keywords=5g&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7053427447018450944">#5</a>G <a href="https://www.linkedin.com/feed/hashtag/?keywords=5gc&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7053427447018450944">#</a>NGC #SA #NSA <a href="https://www.linkedin.com/feed/hashtag/?keywords=telecom&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7053427447018450944">#telecom</a> <a href="https://www.linkedin.com/feed/hashtag/?keywords=telecommunications&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A7053427447018450944">#telecommunications</a></p><p>For user plane connection, PDU Session establishment is required and may correspond to the:<br>- a UE initiated PDU Session Establishment procedure (depicted below)<br>- a UE initiated PDU Session handover from EPS to 5GS.<br>- a Network triggered PDU Session Establishment procedure.</p><p>1. From UE to AMF: NAS Message (contains S-NSSAI(s), PDU Session ID, Request type, Old PDU Session ID, N1 SM container (PDU Session Establishment Request)). In order to establish a new PDU Session, the UE generates a new PDU Session ID.</p><p>2. The AMF determines that the message corresponds to a request for a new PDU Session based on that Request Type indicates “initial request”</p><p>3. From AMF to SMF: Nsmf_PDUSession_CreateSMContext Request (contains SUPI, S-NSSAI(s), PDU Session ID, AMF ID, Request Type, PCF ID, Priority Access, , User location information, Access Type</p><p>4. If the SMF has not yet registered for this PDU Session ID, then the SMF registers with the UDM using Nudm_UECM_Registration (SUPI, PDU Session ID) for a given PDU Session.</p><p>5. From SMF to AMF: Either Nsmf_PDUSession_CreateSMContext Response (Cause, SM Context ID or N1 SM container (PDU Session Reject (Cause)) or an Nsmf_PDUSession_UpdateSMContext Response depending on the request received in step 3.</p><p>6. The SMF selects one or more UPFs. In the case of PDU Session Type IPv4 or IPv6 or IPv4v6, the SMF allocates an IP address/prefix for the PDU Session.</p><p>7. The SMF sends an N4 Session Establishment/Modification Request to the UPF and provides Packet detection, enforcement, and reporting rules to be installed on the UPF for this PDU Session.</p><p>8. The UPF acknowledges by sending an N4 Session Establishment or Modification Response.</p><p>9. SMF to AMF: Namf_Communication_N1N2MessageTransfer (PDU Session ID, N2 SM information (PDU Session ID, QFI(s), QoS Profile(s), CN Tunnel Info, S-NSSAI from the Allowed NSSAI, Session-AMBR, PDU Session Type, User Plane Security Enforcement information, UE Integrity Protection Maximum Data Rate)</p><p>10. AMF to (R)AN: N2 PDU Session Request (N2 SM information, NAS message (PDU Session ID, N1 SM container (PDU Session Establishment Accept))).</p><p>11. (R)AN to UE: The (R)AN may issue AN-specific signalling exchange with the UE that is related with the information received from SMF.</p><p>12. (R)AN to AMF: N2 PDU Session Response (PDU Session ID, Cause, N2 SM information (PDU Session ID, AN Tunnel Info, List of accepted/rejected QFI(s), User Plane Enforcement Policy Notification))</p><p>13. Uplink data started</p><p>14. Downlink data started</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtWoumfMKgDs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtWoumfMKgDs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FtWoumfMKgDs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/02425300b302a0d7f9f0d9a4641cc71a/href">https://medium.com/media/02425300b302a0d7f9f0d9a4641cc71a/href</a></iframe><p>Credit: <a href="https://www.linkedin.com/in/rahulkaundal/">https://www.linkedin.com/in/rahulkaundal/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de8daba27eaa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Fixed-Point Conversion in C]]></title>
            <link>https://embedx.medium.com/simple-fixed-point-conversion-in-c-bfd11aa05fd1?source=rss-14c2d6c24d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfd11aa05fd1</guid>
            <category><![CDATA[c]]></category>
            <category><![CDATA[floating-points]]></category>
            <category><![CDATA[fixed-point]]></category>
            <dc:creator><![CDATA[Krunal Patel]]></dc:creator>
            <pubDate>Tue, 26 Jul 2022 08:51:08 GMT</pubDate>
            <atom:updated>2022-07-26T08:51:08.808Z</atom:updated>
            <content:encoded><![CDATA[<p>Operating on <a href="https://en.wikipedia.org/wiki/Fixed-point_arithmetic"><strong>Fixed-Point Numbers</strong></a> is a common embedded systems task. Our microcontrollers may not have floating-point support, our sensors may provide data in fixed-point formats, or we may want to use fixed-point mathematics control a value’s range and precision.</p><p>There numerous fixed-point mathematics libraries around the internet, such as <a href="https://embeddedartistry.com/blog/2017/8/25/c11-fixed-point-arithemetic-library"><strong>fixed_point</strong></a> or the <a href="https://embeddedartistry.com/blog/2017/08/25/c11-fixed-point-arithmetic-library/"><strong>Compositinal Numeric Library for Cpp</strong></a>. If you are looking for a reliable solution to utilize long-term, spend some time to review these libraries to identify candidates for integration.</p><p>However, we don’t always have the time required to select a library. Perhaps you just need to convert a fixed-point number for prototyping purposes, or you need to do a quick implementation for Friday’s demo.</p><p>Below is a quick-and-dirty approach for converting between fixed-point and floating-point numbers. If you need to handle mathematical operations on fixed-point numbers, look for a library to integrate.</p><blockquote><strong><em>Lossy Conversion of Fixed-Point Numbers</em></strong></blockquote><p>First, we need to select our fixed-point type. For this example, we’ll be using 16-bit fixed-point numbers, in an 11.5 format (11 integral bits, 5 fractional bits):</p><pre>/// Fixed-point Format: 11.5 (16-bit) <br>typedef uint16_t fixed_point_t;</pre><pre>#define FIXED_POINT_FRACTIONAL_BITS 5<br></pre><pre>/// Converts 11.5 format -&gt; double <br>double fixed_to_float(fixed_point_t input);  <br>/// Converts double to 11.5 format <br>fixed_point_t float_to_fixed(double input);</pre><pre>inline double fixed_to_float(fixed_point_t input) <br>{<br>return ((double)input / (double)(1 &lt;&lt; FIXED_POINT_FRACTIONAL_BITS));<br>}</pre><pre>inline fixed_point_t float_to_fixed(double input)<br>{<br>return (fixed_point_t)(round(input * (1 &lt;&lt; FIXED_POINT_FRACTIONAL_BITS))); <br>}</pre><pre>inline fixed_point_t float_to_fixed(double input)<br>{<br>return (fixed_point_t)(input * (1 &lt;&lt; FIXED_POINT_FRACTIONAL_BITS));<br>}</pre><pre>// Convert 16-bit fixed-point to double <br>double fixed16_to_double(uint16_t input, uint8_t fractional_bits)<br>{<br>return ((double)input / (double)(1 &lt;&lt; fractional_bits));<br>}</pre><pre>// Equivalent of our 11.5 conversion function above<br>double r = fixed16_to_double(input, 5);</pre><ul><li><a href="https://www.pathpartnertech.com/representing-decimal-data-in-q-format/">Representing Decimal Data in Q-Format - PathPartnerTech</a></li><li><a href="https://medium.com/incredible-coder/converting-fixed-point-to-floating-point-format-and-vice-versa-6cbc0e32544e">Converting Fixed point to floating point format and vice versa.</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfd11aa05fd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to DPDK: Architecture and Principles]]></title>
            <link>https://embedx.medium.com/introduction-to-dpdk-architecture-and-principles-40db9a61a6f5?source=rss-14c2d6c24d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/40db9a61a6f5</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[dpdk]]></category>
            <dc:creator><![CDATA[Krunal Patel]]></dc:creator>
            <pubDate>Thu, 18 Mar 2021 12:31:16 GMT</pubDate>
            <atom:updated>2021-03-18T12:31:16.432Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6pMQCU55V4keFA1h.png" /><figcaption><em>[Source: https://blog.selectel.com/introduction-dpdk-architecture-principles/]</em></figcaption></figure><p>Linux network stack performance has become increasingly relevant over the past few years. This is perfectly understandable: the amount of data that can be transferred over a network and the corresponding workload has been growing not by the day, but by the hour.</p><p>Not even the widespread use of 10 GE network cards has resolved this issue; this is because a lot of bottlenecks that prevent packets from being quickly processed are found in the Linux kernel itself.</p><p>There have been many attempts to circumvent these bottlenecks with techniques called kernel bypasses (a short description can be found <a href="https://blog.cloudflare.com/kernel-bypass/">here</a>). They let you process packets without involving the Linux network stack and make it so that the application running in the user space communicates directly with the networking device. We’d like to discuss one of these solutions, the <a href="http://dpdk.org/">Intel DPDK</a> (Data Plane Development Kit), in today’s article.</p><p>A lot of posts have already been published about the DPDK and in a variety of languages. Although many of these are fairly informative, they don’t answer the most important questions: How does the DPDK process packets and what route does the packet take from the network device to the user?</p><p>Finding the answers to these questions was not easy; since we couldn’t find everything we needed in the official documentation, we had to look through a myriad of additional materials and thoroughly review their sources. But first thing’s first: before talking about the DPDK and the issues it can help resolve, we should review how packets are processed in Linux.</p><blockquote><strong>Processing Packets in Linux: Main Stages</strong></blockquote><p>When a network card first receives a packet, it sends it to a receive queue or RX. From there, it gets copied to the main memory via the DMA (Direct Memory Access) mechanism.</p><p>Afterwards, the system needs to be notified of the new packet and pass the data onto a specially allocated buffer (Linux allocates these buffers for every packet). To do this, Linux uses an interrupt mechanism: an interrupt is generated several times when a new packet enters the system. The packet then needs to be transferred to the userspace.</p><blockquote><strong>One bottleneck is already apparent:</strong> A<em>s more packets have to be processed, more resources are consumed, which negatively affects the overall system performance.</em></blockquote><p>As we’ve already said, these packets are saved to specially allocated buffers — more specifically, the <a href="https://www.kernel.org/doc/htmldocs/networking/API-struct-sk-buff.html"><strong><em>sk_buff</em></strong><em> struct</em></a>. This struct is allocated for each packet and becomes free when a packet enters the userspace. This operation consumes a lot of bus cycles (i.e. cycles that transfer data from the CPU to the main memory).</p><blockquote><strong>Synopsis (struct sk_buff — socket buffer)</strong></blockquote><pre>struct sk_buff {<br>  union {unnamed_union};<br>  __u16 inner_transport_header;<br>  __u16 inner_network_header;<br>  __u16 inner_mac_header;<br>  __be16 protocol;<br>  __u16 transport_header;<br>  __u16 network_header;<br>  __u16 mac_header;<br>  sk_buff_data_t tail;<br>  sk_buff_data_t end;<br>  unsigned char * head;<br>  unsigned char * data;<br>  unsigned int truesize;<br>  atomic_t users;<br>};</pre><p>There is another problem with the <strong><em>sk_buff</em></strong> struct: the Linux network stack was originally designed to be compatible with as many protocols as possible. As such, metadata for all of these protocols is included in the <strong><em>sk_buff</em></strong> struct, but that’s simply <strong>not necessary for processing specific packets</strong>. Because of this overly complicated struct, the processing is slower than it could be.</p><p>Another factor that negatively affects performance is context switching. When an application in the user space needs to send or receive a packet, it executes a system call. The context is switched to kernel mode and then back to user mode. This consumes a significant amount of system resources.</p><p>To solve some of these problems, all Linux kernels since version 2.6 have included <a href="https://wiki.linuxfoundation.org/networking/napi">NAPI</a> (New API), which combines interrupts with requests. Let’s take a quick look at how this works.</p><p>The network card first works in interrupt mode, but as soon as a packet enters the network interface, it registers itself in a poll queue and disables the interrupt. The system periodically checks the queue for new devices and gathers packets for further processing. As soon as the packets are processed, the card will be deleted from the queue and interrupts are again enabled.</p><p>This has been just a cursory description of how packets are processed. A more detailed look at this process can be found in <a href="https://www.privateinternetaccess.com/blog/2016/01/linux-networking-stack-from-the-ground-up-part-1/">an article series</a> from Private Internet Access. However, even a quick glance is enough to see the problems slowing down packet processing. In the next section, we’ll describe how these problems are solved using DPDK.</p><h3>DPDK: How It Works</h3><blockquote>General Features</blockquote><p>Let’s look at the following illustration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E6pvV9ebVYVCCC2L.png" /><figcaption>[source: https://blog.selectel.com/wp-content/uploads/2016/11/PR-3303.png]</figcaption></figure><p>On the left, you see the traditional way packets are processed, and on the right–with DPDK. As we can see, the kernel in the second example doesn’t step in at all: interactions with the network card are performed via special drivers and libraries.</p><p>If you’ve already read about DPDK or have ever used it, then you know that the ports receiving incoming traffic on network cards need to be unbound from Linux (the kernel driver). This is done using the dpdk_nic_bind (or dpdk-devbind) command, or ./dpdk_nic_bind.py in earlier versions.</p><p>How are ports then managed by DPDK? Every driver in Linux has bind and unbind files. That includes network card drivers:</p><pre>ls /sys/bus/pci/drivers/ixgbe<br>bind  module  new_id  remove_id  uevent  unbind</pre><p>To unbind a device from a driver, the device’s bus number needs to be written to the unbind file. Similarly, to bind a device to another driver, the bus number needs to be written to its bind file. More detailed information about this can be found <a href="https://lwn.net/Articles/143397/">here</a>.</p><p>The DPDK installation instructions <a href="http://dpdk.org/doc/guides-16.04/linux_gsg/build_dpdk.html#loading-modules-to-enable-userspace-io-for-dpdk">tell us</a> that our ports need to be managed by the vfio_pci, igb_uio, or uio_pci_generic driver. (We won’t be getting into details here, but we suggested interested readers look at the following articles on kernel.org: <a href="https://www.kernel.org/doc/Documentation/vfio.txt">1</a> and <a href="https://www.kernel.org/doc/htmldocs/uio-howto/about.html">2</a>.)</p><p>These drivers make it possible to interact with devices in the user space. Of course they include a kernel module, but that’s just to initialize devices and assign the PCI interface.</p><p>All further communication between the application and network card is organized by the DPDK poll mode driver (PMD) DPDK has poll mode drivers for all supported network cards and virtual devices.</p><p>The DPDK also requires hugepages to be configured. This is required for allocating large chunks of memory and writing data to them. We can say that hugepages does the same job in DPDK that DMA does in traditional packet processing.</p><p>We’ll discuss all of its nuances in more detail, but for now, let’s go over the main stages of packet processing with the DPDK:</p><ol><li>Incoming packets go to a ring buffer (we’ll look at its setup in the next section). The application periodically checks this buffer for new packets.</li><li>If the buffer contains new packet descriptors, the application will refer to the DPDK packet buffers in the specially allocated memory pool using the pointers in the packet descriptors.</li><li>If the ring buffer does not contain any packets, the application will queue the network devices under the DPDK and then refer to the ring again.</li></ol><p>Let’s take a closer look at the DPDK’s internal structure.</p><h3>EAL: Environment Abstraction</h3><p>The <a href="http://dpdk.org/doc/guides-16.04/prog_guide/env_abstraction_layer.html">EAL</a>, or Environment Abstraction Layer, is the main concept behind the DPDK.</p><p>The EAL is a set of programming tools that let the DPDK work in a specific hardware environment and under a specific operating system. In the official DPDK repository, libraries and drivers that are part of the EAL are saved in the rte_eal directory.</p><p>Drivers and libraries for Linux and the BSD system are saved in this directory. It also contains a set of header files for various processor architectures: ARM, x86, TILE64, and PPC64.</p><p>We access software in the EAL when we compile the DPDK from the source code:</p><pre>make config T=x86_64-native-linuxapp-gcc</pre><p>One can guess that this command will compile DPDK for Linux in an x86_64 architecture.</p><p>The EAL is what binds the DPDK to applications. All of the applications that use the DPDK (see <a href="http://dpdk.org/doc/guides-16.04/prog_guide/index.html">here</a> for examples) must include the EAL’s header files.</p><p>The most commonly of these include:</p><ul><li>rte_lcore.h — manages processor cores and sockets;</li><li>rte_memory.h — manages memory;</li><li>rte_pci.h — provides the interface access to PCI address space;</li><li>rte_debug.h — provides trace and debug functions (logging, dump_stack, and more);</li><li>rte_interrupts.h — processes interrupts.</li></ul><p>More details on this structure and EAL functions can be found in the <a href="http://dpdk.org/doc/guides/prog_guide/env_abstraction_layer.html">official documentation</a>.</p><h3>Managing Queues: rte_ring</h3><p>As we’ve already said, packets received by the network card are sent to a ring buffer, which acts as a receiving queue. Packets received in the DPDK are also sent to a queue implemented on the rte_ring library. The library’s description below comes from information gathered from the developer’s guide and comments in the source code.</p><p>The rte_ring was developed from the <a href="https://svnweb.freebsd.org/base/release/8.0.0/sys/sys/buf_ring.h?revision=199625&amp;view=markup">FreeBSD ring buffer</a>. If you look at the <a href="http://www.dpdk.org/browse/dpdk/plain/lib/librte_ring/rte_ring.c">source code</a>, you’ll see the following comment: Derived from FreeBSD’s bufring.c.</p><p>The queue is a lockless ring buffer built on the <a href="https://en.wikipedia.org/wiki/FIFO">FIFO</a> (First In, First Out) principle. The ring buffer is a table of pointers for objects that can be saved to the memory. Pointers can be divided into four categories: prod_tail, prod_head, cons_tail, cons_head.</p><p>Prods is short for producer, and cons for consumer. The <strong>producer</strong> is the process that writes data to the buffer at a given time, and the consumer is the process that removes data from the buffer.</p><p>The <strong>tail</strong> is where writing takes place on the ring buffer. The place the buffer is read from at a given time is called the <strong>head</strong>.</p><p>The idea behind the process for adding and removing elements from the queue is as follows: when a new object is added to the queue, the ring-&gt;prod_tail indicator should end up pointing to the location where ring-&gt;prod_head previously pointed to.</p><p>This is just a brief description; a more detailed account of how the ring buffer scripts work can be found in the <a href="http://dpdk.org/doc/guides-16.04/prog_guide/ring_lib.html">developer’s manual</a> on the DPDK site.</p><p>This approach has a number of advantages. Firstly, data is written to the buffer extremely quickly. Secondly, when adding or removing a large number of objects from the queue, cache misses occur much less frequently since pointers are saved in a table.</p><p>The drawback to DPDK’s ring buffer is its fixed size, which cannot be increased on the fly. Additionally, much more memory is spent working with the ring structure than in a linked queue since the buffer always uses the maximum number of pointers.</p><h3>Memory Management: rte_mempool</h3><p>We mentioned above that DPDK requires hugepages. The installation instructions recommend creating 2MB hugepages.</p><p>These pages are combined into segments, which are then divided into zones. Objects that are created by applications or other libraries, like queues and packet buffers, are placed in these zones.</p><p>These objects include memory pools, which are created by the rte_mempool library. These are fixed size object pools that use rte_ring for storing free objects and can be identified by a unique name.</p><p>Memory alignment techniques can be implemented to improve performance.</p><p>Even though access to free objects is designed on a lockless ring buffer, consumption of system resources may still be very high. As multiple cores have access to the ring, a <a href="https://en.wikipedia.org/wiki/Compare-and-swap">compare-and-set</a> (CAS) operation usually has to be performed each time it is accessed.</p><p>To prevent bottlenecking, every core is given an additional local cache in the memory pool. Using the locking mechanism, cores can fully access the free object cache. When the cache is full or entirely empty, the memory pool exchanges data with the ring buffer. This gives the core access to frequently used objects.</p><h3>Buffer Management: rte_mbuf</h3><p>In the Linux network stack, all network packets are represented by the the sk_buff data structure. In DPDK, this is done using the rte_mbuf struct, which is described in the <a href="http://dpdk.org/doc/api/rte__mbuf_8h_source.html">rte_mbuf.h</a> header file.</p><p>The buffer management approach in DPDK is reminiscent of the approach used in FreeBSD: instead of one big sk_buff struct, there are many smaller rte_mbuf buffers. The buffers are created before the DPDK application is launched and are saved in memory pools (memory is allocated by rte_mempool).</p><p>In addition to its own packet data, each buffer contains metadata (message type, length, data segment starting address). The buffer also contains pointers for the next buffer. This is needed when handling packets with large amounts of data. In cases like these, packets can be combined (as is done in FreeBSD; more detailed information about this can be found <a href="https://www.bsdcan.org/2004/papers/NetworkBufferAllocation.pdf">here</a>).</p><h3>Other Libraries: General Overview</h3><p>In previous sections, we talked about the most basic DPDK libraries. There’s a great deal of other libraries, but one article isn’t enough to describe them all. Thus, we’ll be limiting ourselves to just a brief overview.</p><p>With the <a href="http://dpdk.org/doc/guides/prog_guide/lpm_lib.html">LPM library</a>, DPDK runs the <a href="https://en.wikipedia.org/wiki/Longest_prefix_match">Longest Prefix Match</a> (LPM) algorithm, which can be used to forward packets based on their IPv4 address. The primary function of this library is to add and delete IP addresses as well as to search for new addresses using the LPM algorithm.</p><p>A similar function can be performed for IPv6 addresses using the <a href="http://dpdk.org/doc/guides/prog_guide/lpm6_lib.html">LPM6 library</a>.</p><p>Other libraries offer similar functionality based on hash functions. With <a href="http://dpdk.org/doc/guides/prog_guide/hash_lib.html">rte_hash</a>, you can search through a large record set using a unique key. This library can be used for classifying and distributing packets, for example.</p><p>The <a href="http://dpdk.org/doc/guides/prog_guide/timer_lib.html">rte_timer library</a> lets you execute functions asynchronously. The timer can run once or periodically.</p><h3>Conclusion</h3><p>In this article, we went over the internal device and principles of DPDK. This is far from comprehensive though; the subject is too complex and extensive to fit into one article. So sit tight, we will continue this topic in a future article, where we’ll discuss the practical aspects of using DPDK.</p><p>We’d be happy to answer your questions in the comments below. And if you’ve had any experience using DPDK, we’d love to hear your thoughts and impressions.</p><p>For anyone interested in learning more, please visit the following links:</p><ul><li><a href="http://dpdk.org/doc/guides/prog_guide/">http://dpdk.org/doc/guides/prog_guide/</a> — a detailed (but confusing in some places) description of all the DPDK libraries;</li><li><a href="https://www.net.in.tum.de/fileadmin/TUM/NET/NET-2014-08-1/NET-2014-08-1_15.pdf">https://www.net.in.tum.de/fileadmin/TUM/NET/NET-2014-08-1/NET-2014-08-1_15.pdf</a> — a brief overview of DPDK’s capabilities and comparison with other frameworks (netmap and PF_RING);</li><li><a href="http://www.slideshare.net/garyachy/dpdk-44585840">http://www.slideshare.net/garyachy/dpdk-44585840</a> — an introductory presentation to DPDK for beginners;</li><li><a href="http://www.it-sobytie.ru/system/attachments/files/000/001/102/original/LinuxPiter-DPDK-2015.pdf">http://www.it-sobytie.ru/system/attachments/files/000/001/102/original/LinuxPiter-DPDK-2015.pdf</a> — a presentation explaining the DPDK structure.</li></ul><p><a href="https://blog.selectel.com/introduction-dpdk-architecture-principles/">Introduction to DPDK: Architecture and Principles - Selectel Blog</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40db9a61a6f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strange Output while Comparing Floating-Point Numbers in C]]></title>
            <link>https://embedx.medium.com/strange-output-while-comparing-floating-point-numbers-in-c-93c68a245055?source=rss-14c2d6c24d69------2</link>
            <guid isPermaLink="false">https://medium.com/p/93c68a245055</guid>
            <category><![CDATA[floating-points]]></category>
            <category><![CDATA[floating-point-number]]></category>
            <dc:creator><![CDATA[Krunal Patel]]></dc:creator>
            <pubDate>Wed, 27 Jan 2021 08:04:56 GMT</pubDate>
            <atom:updated>2021-01-27T08:04:56.352Z</atom:updated>
            <content:encoded><![CDATA[<pre>float f = 0.1;<br>if( f == 0.1)<br>    printf(&quot;equal&quot;);<br>else<br>    printf(&quot;not equal&quot;);</pre><p><em>Why is the output </em><em>not equal ? Why does this happen?</em></p><p><strong>Floating-point</strong> math <strong>is not</strong> exact. Simple <strong>values</strong> like 0.1 <strong>cannot</strong> be precisely represented using binary <strong>floating-point</strong> numbers, and the limited precision of <strong>floating-point</strong> numbers means that slight changes in the order of operations <strong>can</strong> change the result.</p><pre>if( f == 0.1 )</pre><p>The values used in an expression are considered as double (double precision floating point format) unless a ‘f’ is specified at the end.</p><p>So the expression if( f == 0.7 )has a double on right side and float which are stored in a single-precision floating-point format on the left side. In such situations, the float is promoted to double. The <strong>double-precision format uses more bits for precision than single-precision format</strong>.</p><p>The binary equivalent of 0.1 can be written as (0.00011001100110011…) which goes up to infinity. Since the precision of float is less than the double therefore after a certain point(23 in float and 52 in double) it would truncate the result. Hence, after the promotion of float into double(at the time of comparison) compiler will pad the remaining bits with zeroes. Hence, we get the different result in which decimal equivalent of both would be different. For instance,</p><pre>In float <br>=&gt; (0.1)10 = (0.00011001100110011001100)2<br>In double after promotion of float ...(1)<br>=&gt; (0.1)10 = (0.00011001100110011001100000000000000000...)2<br>                                      ^ padding zeroes here<br>In double without promotion ... (2)<br>=&gt; (0.1)10 = (0.0001100110011001100110011001100110011001100110011001)2<br><br>Hence we can see the result of both equations are different.<br>Therefore &#39;if&#39; statement can never be executed.</pre><p>Try this way:</p><pre>#include&lt;stdio.h&gt;<br>int main()<br>{<br>  float f = 0.3; <br>  if(f == 0.3f)     //or if(a==(float)0.3)<br>    printf(&quot;Equal&quot;);<br>  else<br>    printf(&quot;Not Equal&quot;);<br> <br>  return 0;<br>}</pre><pre>o/p<br>: Equal</pre><p><a href="https://www.geeksforgeeks.org/comparison-float-value-c/">Comparison of a float with a value in C - GeeksforGeeks</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93c68a245055" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>