<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Anmol Sarma</title>
    <link>https://www.anmolsarma.in/</link>
    
    <language>en-in</language>
    
    
    <atom:link href="https://www.anmolsarma.in/" rel="self" type="application/rss+xml" />
    
    
    
    <item>
      <title>A DIY USB Mouse Jiggler</title>
      <link>https://www.anmolsarma.in/post/mouse-jiggler/</link>
      <pubDate>Sun, 21 Jun 2020 21:24:50 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/mouse-jiggler/</guid>
      <description>&lt;p&gt;The Great Pandemic Lockdown of 2020 forced companies to adopt remote work. With no existing provisions for WFH, bizarre ad-hoc setups emerged. A case in point, my roommate was issued two laptops: One for development and a second locked down machine to connect to production servers. The second laptop was configured with a very aggressive lock screen timeout with no way to change or disable it. This made keeping an eye on prod rather annoying.&lt;/p&gt;
&lt;p&gt;One way to prevent Windows from locking the screen is by simulating user activity: say moving the mouse. This would have been trivial to accomplish in software if it wasn&amp;rsquo;t for the administrative policy restricting which applications could be run.&lt;/p&gt;
&lt;p&gt;This seems to be a common enough occurrence in corporate environments that there are companies that &lt;a href=&#34;https://www.cru-inc.com/products/wiebetech/mouse_jiggler_mj-3/&#34;&gt;sell&lt;/a&gt; purpose-built &lt;a href=&#34;http://www.keelog.com/mouse-jiggler/&#34;&gt;hardware&lt;/a&gt; to mitigate the situation. Basically, these devices pretend to be a USB mouse or keyboard and periodically send random mouse events or keystrokes to the connected host computer. Getting hold of one of these seems unlikely in the current situation. Building one was the only option. Fortunately, I had a &lt;a href=&#34;https://www.ti.com/tool/EK-LM4F120XL&#34;&gt;Stellaris Launchpad&lt;/a&gt; lying around, (literally) gathering dust that was perfect for this.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.anmolsarma.in/images/launchpad.jpg&#34; alt=&#34;Stellaris LM4F120 LaunchPad Evaluation Kit&#34;&gt;&lt;/p&gt;
&lt;p&gt;The board has a USB capable ARM Cortex microcontroller onboard and can be used with a &lt;a href=&#34;https://www.ti.com/licreg/docs/swlicexportcontrol.tsp?form_type=2&amp;amp;prod_no=SW-TM4C-USBL-2.2.0.295.exe&#34;&gt;USB stack that TI provides&lt;/a&gt; royalty-free. All I had to do was to figure out how to configure the USB stack to emulate a USB HID mouse. The &lt;a href=&#34;https://www.ti.com/lit/pdf/spmu297&#34;&gt;documentation&lt;/a&gt; refers to a &lt;code&gt;usb_dev_mouse&lt;/code&gt; example application but I for one was unable to find it in the TivaWare package. The TivaWare USB Library is fairly straightforward to use. Apart from the minimal boiler-plate, it is almost as simple as &lt;a href=&#34;https://www.arduino.cc/reference/en/language/functions/usb/mouse/&#34;&gt;Arduino&amp;rsquo;s Mouse library&lt;/a&gt;. Coupled with the &lt;a href=&#34;https://www.ti.com/licreg/docs/swlicexportcontrol.tsp?form_type=2&amp;amp;prod_no=SW-TM4C-DRL-2.2.0.295.exe&#34;&gt;Driverlib&lt;/a&gt; HAL to configure the timer, I was able to get a mouse jiggler working in short order. The USB string descriptors took up more lines of code than the actual application:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;void&lt;/span&gt;
&lt;span style=&#34;color:#00a000&#34;&gt;timerISR&lt;/span&gt; (&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;void&lt;/span&gt;)
{
  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Clear the timer interrupt source to avoid being triggered again 
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// immediately on exit
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;  TimerIntClear (TIMER0_BASE, TIMER_TIMA_TIMEOUT);
  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Disable interrupts so we can get some work done
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;  IntMasterDisable ();

  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Move the cursor by a pixel along each axis in a random direction
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;  int8_t x &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; (rand () &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#666&#34;&gt;?&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;;
  int8_t y &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; (rand () &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#666&#34;&gt;?&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;;
  USBDHIDMouseStateChange ((&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;void&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;) &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;g_jiggler, x, y, &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;);

  IntMasterEnable ();

}

&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;
&lt;span style=&#34;color:#00a000&#34;&gt;main&lt;/span&gt; (&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;void&lt;/span&gt;)
{

  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Configure the clock to directly run from the crysal oscillator
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;  SysCtlClockSet (SYSCTL_SYSDIV_1 &lt;span style=&#34;color:#666&#34;&gt;|&lt;/span&gt; SYSCTL_USE_OSC &lt;span style=&#34;color:#666&#34;&gt;|&lt;/span&gt; SYSCTL_OSC_MAIN &lt;span style=&#34;color:#666&#34;&gt;|&lt;/span&gt;
                  SYSCTL_XTAL_16MHZ);

  SysCtlPeripheralEnable (SYSCTL_PERIPH_TIMER0);

  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Enable the USB peripheral 
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;  SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOD);
  GPIOPinTypeUSBAnalog (GPIO_PORTD_BASE, GPIO_PIN_4 &lt;span style=&#34;color:#666&#34;&gt;|&lt;/span&gt; GPIO_PIN_5);

  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Configure the Timer to fire every 30 seconds
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;  TimerConfigure (TIMER0_BASE, TIMER_CFG_PERIODIC);
  TimerLoadSet (TIMER0_BASE, TIMER_A, SysCtlClockGet () &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;30&lt;/span&gt;);

  IntEnable (INT_TIMER0A);
  TimerIntEnable (TIMER0_BASE, TIMER_TIMA_TIMEOUT);
  TimerEnable (TIMER0_BASE, TIMER_A);

  USBStackModeSet (&lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;, USB_MODE_DEVICE, &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;);
  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Initialize the USB controller and attach the mouse jiggler
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// device to the USB bus
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;  USBDHIDMouseInit (&lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;, (tUSBDHIDMouseDevice &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;) &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;g_jiggler );

  &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Enable processor interrupts
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;  IntMasterEnable ();

  &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;);

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, with the jiggler attached and the laptop hooked up to a TV screen, my roommate can monitor prod and continue to lose sleep in peace.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>File Creation Time in Linux</title>
      <link>https://www.anmolsarma.in/post/linux-file-creation-time/</link>
      <pubDate>Sun, 23 Jun 2019 19:24:22 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/linux-file-creation-time/</guid>
      <description>&lt;p&gt;The &lt;a href=&#34;http://man7.org/linux/man-pages/man1/stat.1.html&#34;&gt;&lt;code&gt;stat&lt;/code&gt;&lt;/a&gt; utility can be used to retrieve the Unix file timestamps namely &lt;code&gt;atime&lt;/code&gt;, &lt;code&gt;ctime&lt;/code&gt; and &lt;code&gt;mtime&lt;/code&gt;. Of these, the benefit of &lt;code&gt;mtime&lt;/code&gt; which records the last time when the file was modified is immediately apparent. On the other hand, &lt;code&gt;atime&lt;/code&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; which records the last time the file was accessed has been called &lt;a href=&#34;https://lore.kernel.org/lkml/20070804210351.GA9784@elte.hu/&#34;&gt;&amp;ldquo;perhaps the most stupid Unix design idea of all times&amp;rdquo;&lt;/a&gt;. Intuitively, one might expect &lt;code&gt;ctime&lt;/code&gt; to record the creation time of a file. However, &lt;code&gt;ctime&lt;/code&gt; records the last time when the metadata of a file was changed.&lt;/p&gt;
&lt;p&gt;Typically, Unices do not record file creation times. While some individual filesystems do record file creation times&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;, until recently Linux lacked a common interface to actually expose them to userspace applications. As a result, the output of &lt;code&gt;stat&lt;/code&gt; (GNU coreutils v8.30) on an ext4 filesystem (Which does record creation times) looks something like this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ stat .
  File: .
  Size: &lt;span style=&#34;color:#666&#34;&gt;4096&lt;/span&gt;            Blocks: &lt;span style=&#34;color:#666&#34;&gt;8&lt;/span&gt;          IO Block: &lt;span style=&#34;color:#666&#34;&gt;4096&lt;/span&gt;   directory
Device: 803h/2051d      Inode: &lt;span style=&#34;color:#666&#34;&gt;3588416&lt;/span&gt;     Links: &lt;span style=&#34;color:#666&#34;&gt;18&lt;/span&gt;
Access: &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;0775/drwxrwxr-x&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;  Uid: &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt; 1000/ anmol&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;   Gid: &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt; 1000/ anmol&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;
Access: 2019-06-23 10:49:04.056933574 +0000
Modify: 2019-05-19 13:29:59.609167627 +0000
Change: 2019-05-19 13:29:59.609167627 +0000
 Birth: -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With the &amp;ldquo;&lt;code&gt;Birth&lt;/code&gt;&amp;rdquo; field, meant to show the creation time, sporting a depressing &amp;ldquo;&lt;code&gt;-&lt;/code&gt;&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;The fact that &lt;code&gt;ctime&lt;/code&gt; does not mean creation time but change time coupled with the absence of a real creation time interface does lead to quite a bit of confusion. The confusion seems so pervasive that the &lt;code&gt;msdos&lt;/code&gt; driver in the Linux kernel &lt;a href=&#34;https://elixir.bootlin.com/linux/v5.1.14/source/fs/fat/inode.c#L883&#34;&gt;happily clobbers&lt;/a&gt; the FAT creation time with the Unix change time!&lt;/p&gt;
&lt;p&gt;The limitations of the current &lt;code&gt;stat()&lt;/code&gt; system call have been known for some time. A new system call providing extended attributes was &lt;a href=&#34;https://www.spinics.net/lists/linux-fsdevel/msg33831.html&#34;&gt;first proposed in 2010&lt;/a&gt; with the new &lt;a href=&#34;https://lwn.net/Articles/685791/#statx&#34;&gt;&lt;code&gt;statx()&lt;/code&gt;&lt;/a&gt; interface finally &lt;a href=&#34;https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a528d35e8bfcc521d7cb70aaf03e1bd296c8493f&#34;&gt;being merged into Linux 4.11 in 2017&lt;/a&gt;. It took so long at least in part because kernel developers quickly ran into one of the hardest problems in Computer Science: &lt;a href=&#34;https://lkml.org/lkml/2010/7/22/249&#34;&gt;naming things&lt;/a&gt;. Because there was no standard to guide them, each filesystem took to calling creation time by a different name. &lt;a href=&#34;https://elixir.bootlin.com/linux/v5.1.14/source/fs/ext4/ext4.h#L744&#34;&gt;Ext4&lt;/a&gt; and &lt;a href=&#34;https://elixir.bootlin.com/linux/v5.1.14/source/fs/xfs/libxfs/xfs_inode_buf.h#L40&#34;&gt;XFS&lt;/a&gt; called it &lt;code&gt;crtime&lt;/code&gt; while &lt;a href=&#34;https://elixir.bootlin.com/linux/v5.1.14/source/fs/btrfs/btrfs_inode.h#L187&#34;&gt;Btrfs&lt;/a&gt; and &lt;a href=&#34;https://elixir.bootlin.com/linux/v5.1.14/source/fs/jfs/jfs_incore.h#L46&#34;&gt;JFS&lt;/a&gt; called it &lt;code&gt;otime&lt;/code&gt;. Implementations also have slightly different semantics with JFS storing creation time only with the &lt;a href=&#34;https://elixir.bootlin.com/linux/v5.1.14/source/fs/jfs/jfs_imap.c#L3166&#34;&gt;precision of seconds&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Glibc took a while to add a wrapper for statx() with support landing in &lt;a href=&#34;https://www.sourceware.org/ml/libc-alpha/2018-08/msg00003.html&#34;&gt;version 2.28&lt;/a&gt; which was released in 2018. Fast forward to March 2019 when GNU &lt;a href=&#34;https://lists.gnu.org/archive/html/coreutils-announce/2019-03/msg00000.html&#34;&gt;coreutils 8.31&lt;/a&gt; was released with &lt;code&gt;stat&lt;/code&gt; finally gaining support for reading the file creation time:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ stat .
  File: .
  Size: &lt;span style=&#34;color:#666&#34;&gt;4096&lt;/span&gt;            Blocks: &lt;span style=&#34;color:#666&#34;&gt;8&lt;/span&gt;          IO Block: &lt;span style=&#34;color:#666&#34;&gt;4096&lt;/span&gt;   directory
Device: 803h/2051d      Inode: &lt;span style=&#34;color:#666&#34;&gt;3588416&lt;/span&gt;     Links: &lt;span style=&#34;color:#666&#34;&gt;18&lt;/span&gt;
Access: &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;0775/drwxrwxr-x&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;  Uid: &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt; 1000/ anmol&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;   Gid: &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt; 1000/ anmol&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;
Access: 2019-06-23 10:49:04.056933574 +0000
Modify: 2019-05-19 13:29:59.609167627 +0000
Change: 2019-05-19 13:29:59.609167627 +0000
 Birth: 2019-05-19 13:13:50.100925514 +0000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;section class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;The impact of &lt;code&gt;atime&lt;/code&gt; on disk performance is mitigated by the use of &lt;a href=&#34;https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/power_management_guide/relatime&#34;&gt;&lt;code&gt;relatime&lt;/code&gt;&lt;/a&gt; on modern Linux systems. &lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;For ext4, one can get the &lt;code&gt;crtime&lt;/code&gt; of a file using the &lt;code&gt;stat&lt;/code&gt; subcommand of the confusingly named &lt;a href=&#34;https://linux.die.net/man/8/debugfs&#34;&gt;&lt;code&gt;debugfs&lt;/code&gt;&lt;/a&gt; utility. &lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</description>
    </item>
    
    <item>
      <title>Talk @ Netdev 0x13: Improved System Call Batching for Network I/O</title>
      <link>https://www.anmolsarma.in/post/netdev-talk/</link>
      <pubDate>Sun, 26 May 2019 21:07:27 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/netdev-talk/</guid>
      <description>&lt;p&gt;My colleagues &lt;a href=&#34;http://blog.rjed.org/&#34;&gt;Rahul Jadhav&lt;/a&gt;, Zhen Cao and me had our talk for &lt;a href=&#34;https://netdevconf.info/0x13/&#34;&gt;Netdev 0x13&lt;/a&gt; accepted. Our basic idea is reducing the CPU cycles consumed by amortizing the system call overhead of network I/O operations.&lt;/p&gt;
&lt;p&gt;At the time we started our work, &lt;a href=&#34;https://lwn.net/Articles/776703/&#34;&gt;&lt;code&gt;io_uring&lt;/code&gt;&lt;/a&gt; was not yet a thing. With the benefit of hindsight however, it is clear that &lt;code&gt;io_uring&lt;/code&gt; is the way forward.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the video of Rahul delivering the talk:&lt;/p&gt;
&lt;center&gt;&lt;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#34;https://www.youtube.com/embed/hJrXbqttJC4&#34; frameborder=&#34;0&#34; allowfullscreen&gt;&lt;/iframe&gt;&lt;/center&gt;
&lt;p&gt;And the slides:&lt;/p&gt;
&lt;script async class=&#34;speakerdeck-embed&#34; data-id=&#34;99baab134b764ae18553842caef1876a&#34; data-ratio=&#34;1.33333333333333&#34; src=&#34;//speakerdeck.com/assets/embed.js&#34;&gt;&lt;/script&gt;
</description>
    </item>
    
    <item>
      <title>Books I Read in 2018</title>
      <link>https://www.anmolsarma.in/post/books-2018/</link>
      <pubDate>Sun, 12 May 2019 23:41:22 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/books-2018/</guid>
      <description>&lt;h3 id=&#34;the-information-a-history-a-theory-a-flood-by-james-gleick&#34;&gt;The Information: A History, a Theory, a Flood by James Gleick&lt;/h3&gt;
&lt;p&gt;Eclectic, engrossing and thoroughly enjoyable. From Ada Lovelace and Charles Babbage to Maxwell and Einstein to Shanon and Turing: Gleick&amp;rsquo;s masterful prose captures both the ideas and personalities of the men and women who made the world what it is today. Apart from the lucid explanation of the foundations of information theory, the book is packed full of fascinating historical accounts. To top it off is the brilliant synthesis and narrative. Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-white-tiger-by-aravind-adiga&#34;&gt;The White Tiger by Aravind Adiga&lt;/h3&gt;
&lt;p&gt;A parable new India relating individuality&amp;rsquo;s struggle for freedom from the societal forces of class and caste that seek to imprison it. The narrative while being deeply allegorical is at the same time raw, visceral and credulous. Devoid of any idealistic or ideological pretensions, the story of Balram Halwai&amp;rsquo;s rise paints a wholly unflattering yet undeniably accurate picture of modern India. Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;masters-of-doom-by-david-kushner&#34;&gt;Masters of Doom by David Kushner&lt;/h3&gt;
&lt;p&gt;A gushing homage from a DOOM fanboy meant for other video game fanboys. While the detailed technical discussions of early games are interesting, the book&amp;rsquo;s focus is on the behind the scenes drama between John Carmack and John Romero. An inordinate amount of prose is spent on trite character profiles which makes parts of the book an absolute chore to read. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;artemis-by-andy-weir&#34;&gt;Artemis by Andy Weir&lt;/h3&gt;
&lt;p&gt;Like &lt;em&gt;The Martian&lt;/em&gt; but on the moon and with added criminal intrigue. The action-packed plot is complemented by charming and extremely likeable characters. While the science is solid the writing is anything but. The mostly unambitious dialogue turns wince-inducing in places. Overall, a quick and enjoyable read. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;an-era-of-darkness-by-shashi-tharoor&#34;&gt;An Era of Darkness by Shashi Tharoor&lt;/h3&gt;
&lt;p&gt;Based on Tharoor&amp;rsquo;s virally popular Oxford Union debate, &lt;em&gt;An Era of Darkness&lt;/em&gt; is a breathless polemic about the horrors of British rule in India. While the book does not offer anything new &amp;ndash; something that the preface readily admits, it does offer a cogent rebuttal to revived colonial apologism. The work is assuredly nationalistic, not of a narrow, parochial or exclusionary sort but of the staunchly liberal, self-assured and inclusive variety. That being said, the book does feel a bit longer than necessary. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-girl-with-the-dragon-tattoo-by-stieg-larsson-as-translated-by-reg-keeland&#34;&gt;The Girl with the Dragon Tattoo by Stieg Larsson as translated by Reg Keeland&lt;/h3&gt;
&lt;p&gt;A slightly atypical murder mystery potboiler. The storyline while not entirely bad is chock full of genre cliches and the translated prose isn&amp;rsquo;t exactly exciting. The drawn-out novel is only redeemed by the character of Lisbeth Salander, the eponymous girl with the dragon tattoo. An entertaining read but not a particularly memorable one. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;flash-boys-by-michael-lewis&#34;&gt;Flash Boys by Michael Lewis&lt;/h3&gt;
&lt;p&gt;Part misguided hit piece on High Frequency Trading, part hagiography of Brad Katsuyama and part native advertisement for the IEX stock exchange: &lt;em&gt;Flash Boys&lt;/em&gt; is utterly without merit. Michel Lewis valiantly tries to project large institutional investors as heroic victims while repeatedly making the absurd claim that the markets are rigged. Even putting the bias aside, the book could be cut down to a long-form article while conveying exactly the same amount of information. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;flowers-for-algernon-by-daniel-keyes&#34;&gt;Flowers for Algernon by Daniel Keyes&lt;/h3&gt;
&lt;p&gt;A heart-wrenching science fiction tale that confronts the accepted notions of intelligence, humanity, love and kindness. Written as a series of progress reports by the protagonist Charlie Gordon as he experiences the full cycle of effects of an experimental cognitive enhancement operation. The journey is captivating and ultimately heartbreaking. Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;surely-youre-joking-mr-feynman-by-richard-feynman&#34;&gt;Surely You&amp;rsquo;re Joking, Mr. Feynman! by Richard Feynman&lt;/h3&gt;
&lt;p&gt;A collection of anecdotes and reminisces from the life of Richard Feynmanmann. While on the whole very amusing, the tone of the stories tends to be rather self-congratulatory with some episodes definitely stretching credulity. But it is a worthy read with the very last chapter, Cargo Cult Science deserving a special mention. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-old-man-and-the-sea-by-ernest-hemingway&#34;&gt;The Old Man and the Sea by Ernest Hemingway&lt;/h3&gt;
&lt;p&gt;True to its name almost the entirety of the novel is an account of a conspicuously unlucky old man and his struggle with the sea and its creatures. While it is over-romanticized to the point of unrealism, Hemmingway manages to capture the majestic force of nature, the raw physicality of a fisherman&amp;rsquo;s life and above all the indomitable force of the human spirit. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;countdown-to-zero-day-by-kim-zetter&#34;&gt;Countdown to Zero Day by Kim Zetter&lt;/h3&gt;
&lt;p&gt;A thoroughly journalistic account of the Stuxnet worm. Tightly written and technically sound, it focusses mostly on the heroic efforts of security researchers who discovered and reverse engineered the worm. The technical exposition is lucid with just the right amount of detail. No liberties are taken with mundane facts to craft a biased or misleading narrative. The geopolitics and circumstances surrounding Stuxnet too are dealt from a neutral perspective without the speculative hysteria that seems to permeate most cybersecurity reporting. Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-ministry-of-utmost-happiness-by-arundhati-roy&#34;&gt;The Ministry of Utmost Happiness by Arundhati Roy&lt;/h3&gt;
&lt;p&gt;A somewhat underwhelming comeback novel from Arundhati Roy after a gap of more than two decades. The sprawling plot line is unfolded mostly by telling and not by showing. And while Roy can effortlessly make the reader look where she wants, it&amp;rsquo;s not entirely clear as to what she wants us to see. In the hands of a lesser writer, such faults would have spelt doom but in Roy more than redeems the novel with her masterful prose. However, the perspective in some places is confusing and politics are inserted into the narrative with all the subtlety of a sledgehammer. While it&amp;rsquo;s no &lt;em&gt;God of Small Things&lt;/em&gt;, it makes for a decent read. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;factfulness-by--hans-rosling-ola-rosling-and-anna-rosling-rönnlund&#34;&gt;Factfulness by  Hans Rosling, Ola Rosling and Anna Rosling Rönnlund&lt;/h3&gt;
&lt;p&gt;Combating outdated perceptions, misleading generalizations and meaningless labels in the search for truth, &lt;em&gt;Factfulness&lt;/em&gt; is hands down the best book I&amp;rsquo;ve read in 2018. Measuredly staying away from hysteria, &lt;em&gt;Factfulness&lt;/em&gt; makes the case that not only is the world becoming a better place but also that the threat of overpopulation is overblown. The book provides a framework for better understanding of the world and offers specific advice on how to avoid being misled by information. Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;dune-by-frank-herbert&#34;&gt;Dune by Frank Herbert&lt;/h3&gt;
&lt;p&gt;An undeniable classic of science fiction, &lt;em&gt;Dune&lt;/em&gt; at its surface is about an interplanetary blood feud. But beyond the seemingly trite premise is a vivid account of a weird and wonderful world with a very unique zoology.  The world building with its myriad cultures is absolutely stellar, the political intrigue is captivating and the character dynamics are powerfully evocative. The only weakness of the novel is the tendency to use long winding speeches to explain the plot points. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;bad-blood-by-john-carreyrou&#34;&gt;Bad Blood by John Carreyrou&lt;/h3&gt;
&lt;p&gt;The riveting tale of the spectacular rise and epic fall of Silicon Valley&amp;rsquo;s Blood Unicorn. A behind-the-scenes account of how John Carreyrou&amp;rsquo;s explosive pieces in the Wall Street Journal came to be, &lt;em&gt;Bad Blood&lt;/em&gt; combines journalistic prowess with narrative flair. The lurid details of the puffery, duplicity and manipulation behind Theranos&amp;rsquo;s eye-watering valuation make for a satisfying sense of schadenfreude. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;sacred-games-by-vikram-chandra&#34;&gt;Sacred Games by Vikram Chandra&lt;/h3&gt;
&lt;p&gt;A story about a washed up gangster, a cynical cop and the city of Mumbai in peril. The main plot flows at a meandering pace while drawing in a staggering number of tributaries. And frankly, the tributaries are far more interesting. The sense of impending doom never really hits home and everything is a bit too well done. Too much time is spent on the protagonist&amp;rsquo;s backstory which is entirely uninteresting. The dialogue while interlaced with vernacular vocabulary simply does not carry any emotional force. At over 700 pages, the book just isn&amp;rsquo;t worth the effort. The Netflix show, while significantly different from the source material, is a much better proposition. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;born-a-crime-by-trevor-noah&#34;&gt;Born a Crime by Trevor Noah&lt;/h3&gt;
&lt;p&gt;A collection of stories from Trever Noah&amp;rsquo;s youth while growing up in of post-Apartheid South Africa. Yhe book is not meant to be a comprehensive treatise of that tumultuous period but a personal account of how it was to live through it all. The writing is both insightful and extremely humorous. Naturally, it deals with issues of racism, poverty and crime: But despite its heavy subject matter, it is a very pleasant read. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;tinker-tailor-soldier-spy-by-john-le-carré&#34;&gt;Tinker Tailor Soldier Spy by John le Carré&lt;/h3&gt;
&lt;p&gt;A dense novel with a convoluted plot and way too many named characters making cameos. The pacing is unsettlingly uneven and there are no sympathetic characters. The supposedly accurate jargon-laced description of spycraft makes for extremely dull reading. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;red-plenty-by-francis-spufford&#34;&gt;Red Plenty by Francis Spufford&lt;/h3&gt;
&lt;p&gt;The Soviet Union was founded on a dream. The talk about establishing the dictatorship of the proletariat was mostly bluster. The real dream was optimizing production by means of central planning. Such a system, it was presumed would avoid the inherent inefficiencies of the market.  Red Plenty is a genre-bending collection of vivid short stories that capture life under such a planned economy in all its triumphs and absurdities. While none of the stories is true, the details that back them are all very much real. Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-colour-of-magic-by-terry-pratchett&#34;&gt;The Colour of Magic by Terry Pratchett&lt;/h3&gt;
&lt;p&gt;An absurdist fantasy featuring an incompetent wizard. While the book definitely has its moments of brilliant humour, they feel few and far between. The world and the characters have a lot of potential which I am told is realized to full effect in the later &lt;em&gt;Discworld&lt;/em&gt; novels. Sadly, in &lt;em&gt;The Color of Magic&lt;/em&gt; though, Terry Prachet is yet to find his voice. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;thinking-fast-and-slow-by-daniel-kahneman&#34;&gt;Thinking, Fast and Slow by Daniel Kahneman&lt;/h3&gt;
&lt;p&gt;Really should have been subtitled &lt;em&gt;The Ludic Fallacy Run Amok&lt;/em&gt;. A collection of studies and anecdotal stories all around a central theme, suitably vulgarized for general consumption. Filled with grand generalisations based on dubious conclusions from small under-powered behavioural experiments. Much ado is made about the so-called &lt;em&gt;Priming Effect&lt;/em&gt; which has since been thoroughly been debunked. The central premise of there being two distinct modes of thinking is asserted with no evidence. One this the book does prove is that behavioural economics &amp;ndash;that bastard child of psychology &amp;ndash; is built on an edifice of fashionable nonsense. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-handmaids-tale-by-margaret-atwood&#34;&gt;The Handmaid&amp;rsquo;s Tale by Margaret Atwood&lt;/h3&gt;
&lt;p&gt;A speculative dystopian novel set in a deeply patriarchal world taken over by religious fundamentalists. The protagonist is a woman called &amp;lsquo;Offred&amp;rsquo;, her name signifying her status as a possession &amp;lsquo;of Fred&amp;rsquo;. Extremely well written, the book features a double narrative, with one chronicling the fall of the old order and the other dealing with life under the new. The intimate prose and visceral detail make reading The Handmaid&amp;rsquo;s Tale an almost physical experience. Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;mans-search-for-meaning-by-viktor-frankl&#34;&gt;Man&amp;rsquo;s Search for Meaning by Viktor Frankl&lt;/h3&gt;
&lt;p&gt;Literal survivorship bias taken to the absolute extreme. Frankl devises an entire theory of psychotherapy backed by the fact that he survived a concentration camp when so many others perished. The narrative deceptively suggests that Frankl spent months in the Auschwitz death camp when in reality he spent most of his time as a prisoner in the Dachau labour camp. Also conveniently left out are details about Frankl&amp;rsquo;s unqualified experiments with lobotomy on his fellow prisoners. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;em-and-the-big-hoom-by-jerry-pinto&#34;&gt;Em and the Big Hoom by Jerry Pinto&lt;/h3&gt;
&lt;p&gt;A moving tragicomic family drama centred around the bipolar manic-depressive mother Em. The story feels too authentic to not be true. While it does not intend to be a commentary on the state of mental health care in India, the parts that deal with it are heartbreaking. Despite the melancholy setting, the dialogue is equal parts brilliant and funny. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-inner-game-of-tennis-by-timothy-gallwey&#34;&gt;The Inner Game of Tennis by Timothy Gallwey&lt;/h3&gt;
&lt;p&gt;At 161 pages it might seem short but is in fact 160 pages too long. It boldly claims its advice isn&amp;rsquo;t applicable just to tennis but to all endeavours of life. While I can&amp;rsquo;t speak about its applicability to tennis, I did not find absolutely anything of value in the book which for the most part is trite and repetitive. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;lord-of-the-flies-by-william-golding&#34;&gt;Lord of the Flies by William Golding&lt;/h3&gt;
&lt;p&gt;On its surface, a Robinsonade featuring a group of schoolboys. But on a deeper level an allegorical commentary on civilization, the basis of cooperation and the memetic power of belief. While the premise is compelling enough, the characters are not particularly well developed, with each of them neatly fitting into an archetype for plot convenience. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-road-to-wigan-pier-by-george-orwell&#34;&gt;The Road to Wigan Pier by George Orwell&lt;/h3&gt;
&lt;p&gt;A Sociological investigation leading to an impassioned polemic. The first part is made up of Orwell&amp;rsquo;s journalistic reportage from his journey through the depressed areas of North England in the midst of the Great Depression. From the lives of miners to housing shortages to the sheer ugliness of industrial towns, Orwell&amp;rsquo;s writing is detailed, vivid and ultimately deeply disturbing. The second has Orwell playing the devil&amp;rsquo;s advocate pointing out the hypocrisies, pettiness and crankiness exhibited by self-avowed Socialists of the champagne drinking variety. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;poonachi-or-the-story-of-a-black-goat-by-perumal-murugan-as-translated-by-n-kalyan-raman&#34;&gt;Poonachi: Or the Story of a Black Goat by Perumal Murugan as translated by N Kalyan Raman&lt;/h3&gt;
&lt;p&gt;A brilliant political commentary dressed-up as a fable about a black goat. The story masterfully captures the trials and tribulations of life in an Indian village. Rich in allegory, Perumal Murugan captures the rebelliousness of the proletarian spirit. The spirit, however, is broken by the material deprivation and authoritarian subjugation that serve as the backdrop for a story that is fundamentally about love and tenderness. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;why-we-sleep-by-matthew-walker&#34;&gt;Why We Sleep by Matthew Walker&lt;/h3&gt;
&lt;p&gt;A  scholarly explanation of &lt;em&gt;Why We Sleep&lt;/em&gt; and an impassioned plea for &lt;em&gt;Why We Should Be Sleeping A Lot More Than We Currently Do&lt;/em&gt;. Be it improving cognitive performance, physical endurance, attractiveness or general well being, Dr Walker&amp;rsquo;s scientific remedy for everything is ensuring that one regularly gets 8 hours of sleep. He goes so far as to say that there is no human physiological process that is not improved by sufficient sleep. The book has more potential to be life changing that any self-help book out there, provided the sound advice is actually adhered to. The pithy takeaway being: &lt;em&gt;Sacrificing sleep does not make you hardworking or successful, it makes you fat and stupid.&lt;/em&gt; Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;ghachar-ghochar-by-vivek-shanbhag-as-translated-by-srinath-perur&#34;&gt;Ghachar Ghochar by Vivek Shanbhag as translated by Srinath Perur&lt;/h3&gt;
&lt;p&gt;A psychological drama about a dysfunctional family that is tangled up beyond repair. While the philosophical musings of the narrator make for amusing reading, the crux of the novel is the sequence of seemingly meaningless events and actions which capture the characters&amp;rsquo; state of mind. There isn&amp;rsquo;t a larger overarching theme apart from the possibility of money complicating and changing the dynamics of human relationships. The novel is more of an exploration rather than an explanation. Would recommend.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Network Redirections in Bash</title>
      <link>https://www.anmolsarma.in/post/bash-net-redirections/</link>
      <pubDate>Sat, 04 May 2019 20:59:15 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/bash-net-redirections/</guid>
      <description>&lt;p&gt;A few months ago, while reading the man page for &lt;code&gt;recvmmsg()&lt;/code&gt;, I came across this snippet:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;while&lt;/span&gt; true; &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;do&lt;/span&gt; &lt;span style=&#34;color:#a2f&#34;&gt;echo&lt;/span&gt; &lt;span style=&#34;color:#b8860b&#34;&gt;$RANDOM&lt;/span&gt; &amp;gt; /dev/udp/127.0.0.1/1234;
     sleep 0.25; &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And as advertised, it sends a UDP datagram containing a random number to port 1234 every 250 ms. I didn&amp;rsquo;t recall ever seeing a &lt;code&gt;/dev/udp&lt;/code&gt; and so was a bit surprised that it worked. And as it happens, &lt;code&gt;ls&lt;/code&gt; was not able to access the file that I had just written to:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;ls: cannot access &lt;span style=&#34;color:#b44&#34;&gt;&amp;#39;/dev/udp/127.0.0.1/1234&amp;#39;&lt;/span&gt;: No such file or directory
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Puzzled and intrigued, I &lt;code&gt;echoe&lt;/code&gt;d &lt;em&gt;Foo Bar Baz&lt;/em&gt; to &lt;code&gt;/dev/udp/127.0.0.1/1337&lt;/code&gt; and reached for &lt;code&gt;strace&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;...
&lt;span style=&#34;color:#666&#34;&gt;2423&lt;/span&gt; socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;4&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;12423&lt;/span&gt; connect(&lt;span style=&#34;color:#666&#34;&gt;4&lt;/span&gt;, {sa_family&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;AF_INET, sin_port&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;htons(&lt;span style=&#34;color:#666&#34;&gt;1337&lt;/span&gt;), sin_addr&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;inet_addr(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;127.0.0.1&amp;#34;&lt;/span&gt;)}, &lt;span style=&#34;color:#666&#34;&gt;16&lt;/span&gt;) &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;12423&lt;/span&gt; fcntl(&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;, F_GETFD)                 &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;12423&lt;/span&gt; fcntl(&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;, F_DUPFD, &lt;span style=&#34;color:#666&#34;&gt;10&lt;/span&gt;)             &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;10&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;12423&lt;/span&gt; fcntl(&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;, F_GETFD)                 &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;12423&lt;/span&gt; fcntl(&lt;span style=&#34;color:#666&#34;&gt;10&lt;/span&gt;, F_SETFD, FD_CLOEXEC)    &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;12423&lt;/span&gt; dup2(&lt;span style=&#34;color:#666&#34;&gt;4&lt;/span&gt;, &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;)                        &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;12423&lt;/span&gt; close(&lt;span style=&#34;color:#666&#34;&gt;4&lt;/span&gt;)                          &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;12423&lt;/span&gt; fstat(&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;, {st_mode&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;S_IFSOCK&lt;span style=&#34;color:#666&#34;&gt;|&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;0777&lt;/span&gt;, st_size&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;, ...}) &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;12423&lt;/span&gt; write(&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;Foo Bar Baz&lt;/span&gt;&lt;span style=&#34;color:#b62;font-weight:bold&#34;&gt;\n&lt;/span&gt;&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#666&#34;&gt;12&lt;/span&gt;)     &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;12&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Seemingly, a normal UDP socket was being created and written to using the regular sycall interface. That refuted my initial suspicion that some kind of a special file backed by the kernel was involved. But who was actually creating the socket?&lt;/p&gt;
&lt;p&gt;A peek at Bash&amp;rsquo;s code answered that question:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;redir.c:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;/* A list of pattern/value pairs for filenames that the redirection
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;   code handles specially. */&lt;/span&gt;
&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;static&lt;/span&gt; STRING_INT_ALIST _redir_special_filenames[] &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; {
&lt;span style=&#34;color:#080&#34;&gt;#if !defined (HAVE_DEV_FD)
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;  { &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;/dev/fd/[0-9]*&amp;#34;&lt;/span&gt;, RF_DEVFD },
&lt;span style=&#34;color:#080&#34;&gt;#endif
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#if !defined (HAVE_DEV_STDIN)
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;  { &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;/dev/stderr&amp;#34;&lt;/span&gt;, RF_DEVSTDERR },
  { &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;/dev/stdin&amp;#34;&lt;/span&gt;, RF_DEVSTDIN },
  { &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;/dev/stdout&amp;#34;&lt;/span&gt;, RF_DEVSTDOUT },
&lt;span style=&#34;color:#080&#34;&gt;#endif
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#if defined (NETWORK_REDIRECTIONS)
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;  { &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;/dev/tcp/*/*&amp;#34;&lt;/span&gt;, RF_DEVTCP },
  { &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;/dev/udp/*/*&amp;#34;&lt;/span&gt;, RF_DEVUDP },
&lt;span style=&#34;color:#080&#34;&gt;#endif
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;  { (&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;)&lt;span style=&#34;color:#a2f&#34;&gt;NULL&lt;/span&gt;, &lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt; }
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, redirection involving &lt;code&gt;/dev/udp/&lt;/code&gt; is handled specially by Bash&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; and it uses BSD Sockets API to create a socket:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;lib/sh/netopen.c:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;/*
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt; * Open a TCP or UDP connection to HOST on port SERV.  Uses the
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt; * traditional BSD mechanisms.  Returns the connected socket or -1 on error.
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt; */&lt;/span&gt;
&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;static&lt;/span&gt; &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;
&lt;span style=&#34;color:#00a000&#34;&gt;_netopen4&lt;/span&gt;(host, serv, typ)
     &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;host, &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;serv;
     &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; typ;
{
  &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; in_addr ina;
  &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; sockaddr_in sin;
  &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;unsigned&lt;/span&gt; &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;short&lt;/span&gt; p;
  &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; s, e;

  &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (_getaddr(host, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;ina) &lt;span style=&#34;color:#666&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;)
    {
      internal_error (_(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;%s: host unknown&amp;#34;&lt;/span&gt;), host);
      errno &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; EINVAL;
      &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;;
    }

  &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (_getserv(serv, typ, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;p) &lt;span style=&#34;color:#666&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;)
    {
      internal_error(_(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;%s: invalid service&amp;#34;&lt;/span&gt;), serv);
      errno &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; EINVAL;
      &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;;
    }

  memset ((&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;)&lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;sin, &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(sin));
  sin.sin_family &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; AF_INET;
  sin.sin_port &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; p;
  sin.sin_addr &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; ina;

  s &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; socket(AF_INET, (typ &lt;span style=&#34;color:#666&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#b44&#34;&gt;&amp;#39;t&amp;#39;&lt;/span&gt;) &lt;span style=&#34;color:#666&#34;&gt;?&lt;/span&gt; &lt;span style=&#34;color:#a0a000&#34;&gt;SOCK_STREAM&lt;/span&gt; : SOCK_DGRAM, &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;);
  &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (s &lt;span style=&#34;color:#666&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;)
    {
      sys_error (&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;socket&amp;#34;&lt;/span&gt;);
      &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;);
    }

  &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (connect (s, (&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; sockaddr &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;)&lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;sin, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt; (sin)) &lt;span style=&#34;color:#666&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;)
    {
      e &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; errno;
      sys_error(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;connect&amp;#34;&lt;/span&gt;);
      close(s);
      errno &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; e;
      &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;);
    }

  &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;return&lt;/span&gt;(s);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Which means we can actually make HTTP requests using Bash:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;color:#a2f&#34;&gt;exec&lt;/span&gt; 3&amp;lt;&amp;gt; /dev/tcp/checkip.amazonaws.com/80
&lt;span style=&#34;color:#a2f&#34;&gt;printf&lt;/span&gt; &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;GET / HTTP/1.1\r\nHost: checkip.amazonaws.com\r\nConnection: close\r\n\r\n&amp;#34;&lt;/span&gt; &amp;gt;&amp;amp;&lt;span style=&#34;color:#666&#34;&gt;3&lt;/span&gt;
tail -n1 &amp;lt;&amp;amp;&lt;span style=&#34;color:#666&#34;&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;No &lt;code&gt;curl&lt;/code&gt; needed! /jk&lt;/p&gt;
&lt;p&gt;Apart from Bash, in the versions and configurations packaged in Ubuntu 18.04, only &lt;code&gt;ksh&lt;/code&gt; supports network redirections &amp;ndash; &lt;code&gt;ash&lt;/code&gt;, &lt;code&gt;csh&lt;/code&gt;, &lt;code&gt;dash&lt;/code&gt;,  &lt;code&gt;fish&lt;/code&gt;,  and &lt;code&gt;zsh&lt;/code&gt; do not.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t think I will actually have any use for network redirections but this was a fun little rabbit hole to dive into.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Code snippets from Bash are licensed under GPLv3, the snippet from the man page is licensed &lt;a href=&#34;http://man7.org/linux/man-pages/man2/recvmmsg.2.license.html&#34;&gt;differently&lt;/a&gt;&lt;/p&gt;
&lt;section class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;At least on Linux, the other special patterns handled by bash like &lt;a href=&#34;http://www.informit.com/articles/article.aspx?p=99706&amp;amp;seqNum=15&#34;&gt;&lt;code&gt;/dev/fd&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;/dev/stdint&lt;/code&gt; actually are special files backed by the kernel. The &lt;a href=&#34;https://www.gnu.org/software/bash/manual/html_node/Redirections.html&#34;&gt;Bash manual&lt;/a&gt; notes that it may emulate them internally on platforms that do not support them. &lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</description>
    </item>
    
    <item>
      <title>Stop Memsetting Structures</title>
      <link>https://www.anmolsarma.in/post/stop-struct-memset/</link>
      <pubDate>Sat, 27 Apr 2019 23:59:42 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/stop-struct-memset/</guid>
      <description>&lt;p&gt;&lt;em&gt;TL;DR: Use C99&amp;rsquo;s designated initializers instead. Because it&amp;rsquo;s 2019!&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Edit:&lt;/strong&gt; This post was discussed on &lt;a href=&#34;https://news.ycombinator.com/item?id=19766930&#34;&gt;Hacker News&lt;/a&gt;, &lt;a href=&#34;https://lobste.rs/s/7aqidd/stop_memsetting_structures&#34;&gt;Lobste.rs&lt;/a&gt; and &lt;a href=&#34;https://www.reddit.com/r/C_Programming/comments/bi23w6/stop_memsetting_structures/&#34;&gt;/r/c_programming&lt;/a&gt;. It has been updated to address some of the concerns raised by commenters.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;One of the little things that annoy me when reading code is the unnecessary use of &lt;code&gt;memset()&lt;/code&gt; to zero-out a &lt;code&gt;struct&lt;/code&gt;. Something I see frequently in networking code that uses the BSD sockets API.&lt;/p&gt;
&lt;p&gt;Consider this snippet of code from the venerable &lt;a href=&#34;https://beej.us/guide/bgnet/html/single/bgnet.html#simpleserver&#34;&gt;Beej&amp;rsquo;s Guide to Network Programming&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; addrinfo hints;
...

memset(&lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;hints, &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt; hints);
hints.ai_family &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; AF_UNSPEC;
hints.ai_socktype &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; SOCK_STREAM;
hints.ai_flags &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; AI_PASSIVE; &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// use my IP
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, we first declare a struct, memset it to zero and then initialize the fields we are interested in. This is all fine except for the fact that the same result can be achieved with the following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; addrinfo hints &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; {
	.ai_family &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; AF_UNSPEC,
	.ai_socktype &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; SOCK_STREAM,
	.ai_flags &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; AI_PASSIVE &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// use my IP
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Which in my humble and very subjective opinion looks much cleaner.&lt;/p&gt;
&lt;p&gt;The second version uses a feature standardized in C99 called designated initializers. This allows initializing elements of an aggregate type in any order by specifying the array indices or structure field names. Elements that are not specified are initialized as if they are static objects: arithmetic types are initialized to &lt;code&gt;0&lt;/code&gt;; pointers are initialized to &lt;code&gt;NULL&lt;/code&gt;. This is also presumably less expensive than a &lt;code&gt;memset()&lt;/code&gt; as it avoids clearing memory that will be assigned to.&lt;/p&gt;
&lt;p&gt;If the structure has padding, using designated initializers will not initialize it to zero.  This is not &lt;em&gt;usually&lt;/em&gt; a problem. However, this may inadvertently lead to information leaks when passing a structure from a more privileged context to a less privileged one: &lt;a href=&#34;https://lwn.net/Articles/417989/&#34;&gt;Like when passing memory from the kernel back to userspace&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now to be fair to Beej, he first wrote &lt;em&gt;The Guide&lt;/em&gt; in 1995. But if you&amp;rsquo;re writing new code in 2019, there is really no reason to not use designated initializers&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;. Except to specifically avoid memory disclosures. &lt;em&gt;Cue the Rust Evangelism Strike Force chiming in to say that there is really no reason to be writing new C code in 2019.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;While we&amp;rsquo;re on the topic of little annoyances, another pattern I often see is using a variable just to pass what is effectively a literal to &lt;code&gt;setsockopt()&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; yes&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;;
setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;yes, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt; (yes)) ;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Which can instead be written as:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;) {&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;}, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This uses yet another C99 feature called compound literals. If the magic 1 value bothers you, you can always:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;) {&lt;span style=&#34;color:#a2f&#34;&gt;true&lt;/span&gt;}, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And finally, there is absolutely no reason to check if a pointer is &lt;code&gt;NULL&lt;/code&gt; just before calling &lt;code&gt;free()&lt;/code&gt; on it:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a2f&#34;&gt;NULL&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;!=&lt;/span&gt; ptr)
	free(ptr);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Quoting the &lt;a href=&#34;http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf&#34;&gt;standard Section 7.20.3.2 (p. 313)&lt;/a&gt;: &lt;em&gt;If ptr is a null pointer, no action occurs.&lt;/em&gt; If a system deviates from this expectation, it is clearly evil. It is advised to &lt;em&gt;Kill It With Fire&lt;/em&gt;.&lt;/p&gt;
&lt;section class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;If you were relying on &lt;code&gt;memcmp()&lt;/code&gt; to compare structs, that will probably no longer work. But you knew what you were getting yourself into, didn&amp;rsquo;t you? &lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</description>
    </item>
    
    <item>
      <title>Single-stepping through the Kernel</title>
      <link>https://www.anmolsarma.in/post/single-step-kernel/</link>
      <pubDate>Sun, 03 Feb 2019 18:57:45 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/single-step-kernel/</guid>
      <description>&lt;p&gt;There may come a time in a system programmer&amp;rsquo;s life when she needs to leave the civilized safety of the userland and confront the unspeakable horrors that dwell in the depths of the Kernel space. While &lt;a href=&#34;https://lkml.org/lkml/2000/9/6/65&#34;&gt;higher beings might pour scorn&lt;/a&gt; on the very idea of a Kernel debugger, us lesser mortals may have no other recourse but to single-step through Kernel code when the rivers begin to run dry. This guide will help you do just that. We hope you never actually have to.&lt;/p&gt;
&lt;p&gt;Ominous sounding intro-bait notwithstanding, setting up a virtual machine for Kernel debugging isn&amp;rsquo;t really that difficult.  It only needs a bit of preparation. If you just want a copypasta, &lt;a href=&#34;#copypasta&#34;&gt;skip to the end&lt;/a&gt;. If you&amp;rsquo;re interested in the predicaments involved and how to deal with them, read on.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;N.B.:&lt;/strong&gt; &amp;ldquo;But which kernel are you talking about?&amp;rdquo;, some heathens may invariably ask when it is obvious that Kernel with a capital K refers to the &lt;a href=&#34;https://www.kernel.org/&#34;&gt;One True Kernel&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;building-the-kernel&#34;&gt;Building the Kernel&lt;/h3&gt;
&lt;p&gt;Using a minimal Kernel configuration instead of the kitchen-sink one that distributions usually ship will make life a lot easier. You will first need to grab the source code for the Kernel you are interested in. We will use the latest Kernel release tarball from &lt;a href=&#34;https://www.kernel.org/&#34;&gt;kernel.org&lt;/a&gt;, which at the time of writing is &lt;a href=&#34;https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.20.6.tar.xz&#34;&gt;4.20.6&lt;/a&gt;. Inside the extracted source directory, invoke the following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;make defconfig
make kvmconfig
make -j4  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will build a minimal Kernel image that can be booted in QEMU like so:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;qemu-system-x86_64 -kernel linux-4.20.6/arch/x86/boot/bzImage
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This should bring up an ancient-looking window with a cryptic error message:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.anmolsarma.in/images/kernel_panic.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;You could try pasting the error message into &lt;del&gt;Google&lt;/del&gt; a search engine: Except for the fact that you can&amp;rsquo;t select the text in the window. And frankly, the window just looks annoying! So, ignoring the actual error for a moment, let&amp;rsquo;s try to get QEMU to print to the console instead of a spawning a new graphical window:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;qemu-system-x86_64 -kernel -nographic linux-4.20.6/arch/x86/boot/bzImage
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;QEMU spits out a single line:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;qemu-system-x86_64: warning: TCG doesn&lt;span style=&#34;&#34;&gt;&amp;#39;&lt;/span&gt;t support requested feature: CPUID.01H:ECX.vmx &lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;bit 5&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&#34;https://hisham.hm/htop/&#34;&gt;Htop&lt;/a&gt; tells me QEMU is using 100% of a CPU and my laptop fan agrees. But there is no output whatsoever and &lt;code&gt;Ctrl-c&lt;/code&gt; doesn&amp;rsquo;t work! What &lt;a href=&#34;https://superuser.com/a/1211516&#34;&gt;does work&lt;/a&gt;, however, is pressing &lt;code&gt;Ctrl-a&lt;/code&gt; and then hitting &lt;code&gt;x&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;QEMU: Terminated
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Turns out that by passing &lt;code&gt;-nographic&lt;/code&gt;, we have plugged out QEMU&amp;rsquo;s &lt;em&gt;virtual&lt;/em&gt; monitor. Now, to actually see any output, we need to tell the Kernel to write to a &lt;a href=&#34;https://www.kernel.org/doc/html/v4.20/admin-guide/serial-console.html&#34;&gt;serial port&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;qemu-system-x86_64 -nographic -kernel linux-4.20.6/arch/x86/boot/bzImage -append &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;console=ttyS0&amp;#34;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It worked! Now we can read error message in all its glory:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.333008&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt; VFS: Cannot open root device &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;(null)&amp;#34;&lt;/span&gt; or unknown-block&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;0,0&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;: error -6
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.334024&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt; Please append a correct &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;root=&amp;#34;&lt;/span&gt; boot option; here are the available partitions:
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.335152&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt; 0b00         &lt;span style=&#34;color:#666&#34;&gt;1048575&lt;/span&gt; sr0 
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.335153&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  driver: sr
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.335996&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt; Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;0,0&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.337104&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt; CPU: &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt; PID: &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt; Comm: swapper/0 Not tainted 4.20.6 &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;#1&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.337901&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt; Hardware name: QEMU Standard PC &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;i440FX + PIIX, 1996&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;, BIOS 1.10.2-1ubuntu1 04/01/2014
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.339091&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt; Call Trace:
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.339437&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  dump_stack+0x46/0x5b
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.339888&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  panic+0xf3/0x248
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.340295&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  mount_block_root+0x184/0x248
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.340838&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  ? set_debug_rodata+0xc/0xc
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.341357&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  mount_root+0x121/0x13f
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.341837&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  prepare_namespace+0x130/0x166
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.342378&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  kernel_init_freeable+0x1ed/0x1ff
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.342965&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  ? rest_init+0xb0/0xb0
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.343427&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  kernel_init+0x5/0x100
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.343888&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;  ret_from_fork+0x35/0x40
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.344526&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt; Kernel Offset: 0x1200000 from 0xffffffff81000000 &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;relocation range: 0xffffffff80000000-0xffffffffbfffffff&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;    1.345956&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt; ---&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt; end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;0,0&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;---
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, the Kernel didn&amp;rsquo;t find a root filesystem to kick off the user mode and panicked. Lets fix that by creating a root filesystem image.&lt;/p&gt;
&lt;h3 id=&#34;creating-a-root-filesystem&#34;&gt;Creating a Root Filesystem&lt;/h3&gt;
&lt;p&gt;Start by creating an empty image:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;qemu-img create rootfs.img 1G
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And then format it as &lt;a href=&#34;https://en.wikipedia.org/wiki/Ext4&#34;&gt;&lt;code&gt;ext4&lt;/code&gt;&lt;/a&gt; and mount it:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;mkfs.ext4 rootfs.img
mkdir mnt
sudo mount -o loop rootfs.img mnt/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can populate it using &lt;a href=&#34;https://wiki.debian.org/Debootstrap&#34;&gt;&lt;code&gt;debootstrap&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;sudo debootstrap bionic mnt/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will create a root filesystem based on Ubuntu 18.04 Bionic Beaver. Of course, feel free to replace &lt;code&gt;bionic&lt;/code&gt; with any release that you prefer.&lt;/p&gt;
&lt;p&gt;And unmount the filesystem once we&amp;rsquo;re done. &lt;strong&gt;This is important if you want to avoid corrupted images!&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;sudo umount mnt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now boot the Kernel with our filesystem. We need to tell QEMU to use our image as a virtual hard drive and we also need to tell the Kernel to use the hard drive as the root filesystem:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;qemu-system-x86_64 -nographic -kernel linux-4.20.6/arch/x86/boot/bzImage -hda rootfs.img -append &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;root=/dev/sda console=ttyS0&amp;#34;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This time the Kernel shouldn&amp;rsquo;t panic and you should eventually see a login prompt. We could have setup a user while creating the filesystem but it&amp;rsquo;s annoying to have to login each time we boot up the VM. Let&amp;rsquo;s enable auto login as root instead.&lt;/p&gt;
&lt;p&gt;Terminate QEMU (&lt;code&gt;Ctrl-a&lt;/code&gt;, &lt;code&gt;x&lt;/code&gt;), mount the filesystem image again and then create the configuration folder structure:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;sudo mount -o loop rootfs.img mnt/
sudo mkdir -p mnt/etc/systemd/system/serial-getty@ttyS0.service.d
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add the following lines to &lt;code&gt;mnt/etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;Service&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;
&lt;span style=&#34;color:#b8860b&#34;&gt;ExecStart&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;
&lt;span style=&#34;color:#b8860b&#34;&gt;ExecStart&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;-/sbin/agetty --noissue --autologin root %I &lt;span style=&#34;color:#b8860b&#34;&gt;$TERM&lt;/span&gt;
&lt;span style=&#34;color:#b8860b&#34;&gt;Type&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;idle
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Make sure to unmount the filesystem and then boot the Kernel again. This time you should be automatically logged in.&lt;/p&gt;
&lt;p&gt;Gracefully shutdown the VM:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;halt -p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;attaching-a-debugger&#34;&gt;Attaching a debugger&lt;/h3&gt;
&lt;p&gt;Let&amp;rsquo;s rebuild the Kernel with debugging symbols enabled:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;./scripts/config -e CONFIG_DEBUG_INFO
make -j4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, boot the Kernel again, this time passing the &lt;code&gt;-s&lt;/code&gt; flag which will make QEMU listen on TCP port 1234:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;qemu-system-x86_64 -nographic -kernel linux-4.20.6/arch/x86/boot/bzImage -hda rootfs.img -append &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;root=/dev/sda console=ttyS0&amp;#34;&lt;/span&gt; -s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, in another terminal start gdb and attach to QEMU:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;gdb ./linux-4.20.6/vmlinux 
...
Reading symbols from ./linux-4.20.6/vmlinux...done.
&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;gdb&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt; target remote :1234
Remote debugging using :1234
0xffffffff95a2f8f4 in ?? &lt;span style=&#34;color:#666&#34;&gt;()&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;gdb&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can set a breakpoint on Kernel function, for instance &lt;code&gt;do_sys_open()&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;gdb&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt; b do_sys_open 
Breakpoint &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt; at 0xffffffff811b2720: file fs/open.c, line 1049.
&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;gdb&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt; c
Continuing.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now try opening a file in VM which should result in &lt;code&gt;do_sys_open()&lt;/code&gt; getting invoked&amp;hellip; And nothing happens?! The breakpoint in gdb is not hit. This due to a Kernel security feature called &lt;a href=&#34;https://lwn.net/Articles/569635/&#34;&gt;KASLR&lt;/a&gt;. KASLR can be disabled at boot time by adding &lt;code&gt;nokaslr&lt;/code&gt; to the Kernel command line arguments. But, let&amp;rsquo;s actually rebuild the Kernel without KASLR. While we are at it, let&amp;rsquo;s also disable loadable module support as well which will save us the trouble of copying the modules to the filesystem.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;./scripts/config -e CONFIG_DEBUG_INFO -d CONFIG_RANDOMIZE_BASE -d CONFIG_MODULES
make olddefconfig &lt;span style=&#34;color:#080;font-style:italic&#34;&gt;# Resolve dependencies&lt;/span&gt;
make -j4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Reboot the Kernel again, attach gdb, set a breakpoint on &lt;code&gt;do_sys_open()&lt;/code&gt; and run &lt;code&gt;cat /etc/issue&lt;/code&gt; in the guest. This time the breakpoint should be hit. But probably not where you expected:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;Breakpoint 1, do_sys_open &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#b8860b&#34;&gt;dfd&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;-100, &lt;span style=&#34;color:#b8860b&#34;&gt;filename&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;0x7f96074ad428 &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;/etc/ld.so.cache&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#b8860b&#34;&gt;flags&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;557056, &lt;span style=&#34;color:#b8860b&#34;&gt;mode&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;0&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt; at fs/open.c:1049
&lt;span style=&#34;color:#666&#34;&gt;1049&lt;/span&gt;    &lt;span style=&#34;color:#666&#34;&gt;{&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;gdb&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt; c
Continuing.

Breakpoint 1, do_sys_open &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#b8860b&#34;&gt;dfd&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;-100, &lt;span style=&#34;color:#b8860b&#34;&gt;filename&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;0x7f96076b5dd0 &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;/lib/x86_64-linux-gnu/libc.so.6&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#b8860b&#34;&gt;flags&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;557056, &lt;span style=&#34;color:#b8860b&#34;&gt;mode&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;0&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt; at fs/open.c:1049
&lt;span style=&#34;color:#666&#34;&gt;1049&lt;/span&gt;    &lt;span style=&#34;color:#666&#34;&gt;{&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;gdb&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt; c
Continuing.

Breakpoint 1, do_sys_open &lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#b8860b&#34;&gt;dfd&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;-100, &lt;span style=&#34;color:#b8860b&#34;&gt;filename&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;0x7ffe9e630e8e &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;/etc/issue&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#b8860b&#34;&gt;flags&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;32768, &lt;span style=&#34;color:#b8860b&#34;&gt;mode&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;0&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt; at fs/open.c:1049
&lt;span style=&#34;color:#666&#34;&gt;1049&lt;/span&gt;    &lt;span style=&#34;color:#666&#34;&gt;{&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;gdb&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Congratulations! From this point, you can single-step away to your heart&amp;rsquo;s content.&lt;/p&gt;
&lt;p&gt;By default, the root filesystem is mounted read only. If you want to be able to write to it, add &lt;code&gt;rw&lt;/code&gt; after &lt;code&gt;root=/dev/sda&lt;/code&gt; in the Kernel parameters:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;qemu-system-x86_64 -nographic -kernel linux-4.20.6/arch/x86/boot/bzImage -hda rootfs.img -append &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;root=/dev/sda rw console=ttyS0&amp;#34;&lt;/span&gt; -s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;bonus-networking&#34;&gt;Bonus: Networking&lt;/h3&gt;
&lt;p&gt;You can create a point to point link between the QEMU VM and the host using a &lt;a href=&#34;https://en.wikipedia.org/wiki/TUN/TAP&#34;&gt;TAP interface&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;First install &lt;code&gt;tunctl&lt;/code&gt; and create a persistent TAP interface to avoid running QEMU as root:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;sudo apt install uml-utilities
sudo sudo tunctl -u &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;$(&lt;/span&gt;id -u&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;)&lt;/span&gt;
Set &lt;span style=&#34;color:#b44&#34;&gt;&amp;#39;tap0&amp;#39;&lt;/span&gt; persistent and owned by uid &lt;span style=&#34;color:#666&#34;&gt;1000&lt;/span&gt;
sudo ip link &lt;span style=&#34;color:#a2f&#34;&gt;set&lt;/span&gt; tap0 up
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now launch QEMU with a virtual &lt;code&gt;e1000&lt;/code&gt; interface connected the host&amp;rsquo;s tap0 interface:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;qemu-system-x86_64 -nographic -device e1000,netdev&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;net0 -netdev tap,id&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;net0,ifname&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;tap0 -kernel linux-4.20.6/arch/x86/boot/bzImage -hda rootfs.img -append &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;root=/dev/sda rw console=ttyS0&amp;#34;&lt;/span&gt; -s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Once the guest boots up, bring the network interface up:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;ip link &lt;span style=&#34;color:#a2f&#34;&gt;set&lt;/span&gt; enp0s3 up
ip a
1: lo: &amp;lt;LOOPBACK,UP,LOWER_UP&amp;gt; mtu &lt;span style=&#34;color:#666&#34;&gt;65536&lt;/span&gt; qdisc noqueue state UNKNOWN group default qlen &lt;span style=&#34;color:#666&#34;&gt;1000&lt;/span&gt;
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu &lt;span style=&#34;color:#666&#34;&gt;1500&lt;/span&gt; qdisc pfifo_fast state UP group default qlen &lt;span style=&#34;color:#666&#34;&gt;1000&lt;/span&gt;
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::5054:ff:fe12:3456/64 scope link 
       valid_lft forever preferred_lft forever
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;QEMU and the host can now communicate using their IPv6 Link-local addresses. After all, it is 2019.&lt;/p&gt;
&lt;h3 id=&#34;copypasta&#34;&gt;Copypasta&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;# Building a minimal debuggable Kernel&lt;/span&gt;
make defconfig
make kvmconfig
./scripts/config -e CONFIG_DEBUG_INFO -d CONFIG_RANDOMIZE_BASE -d CONFIG_MODULES
make olddefconfig
make -j4


&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;# Create root filesystem&lt;/span&gt;
qemu-img create rootfs.img 1G
mkfs.ext4 rootfs.img
mkdir mnt
sudo mount -o loop rootfs.img mnt/
sudo debootstrap bionic mnt/

&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;# Add following lines to mnt/etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf&lt;/span&gt;
&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;# START&lt;/span&gt;
&lt;span style=&#34;color:#666&#34;&gt;[&lt;/span&gt;Service&lt;span style=&#34;color:#666&#34;&gt;]&lt;/span&gt;
&lt;span style=&#34;color:#b8860b&#34;&gt;ExecStart&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;
&lt;span style=&#34;color:#b8860b&#34;&gt;ExecStart&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;-/sbin/agetty --noissue --autologin root %I &lt;span style=&#34;color:#b8860b&#34;&gt;$TERM&lt;/span&gt;
&lt;span style=&#34;color:#b8860b&#34;&gt;Type&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt;idle
&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;# END&lt;/span&gt;

&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;# Unmount the filesystem&lt;/span&gt;
sudo umount mnt

&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;# Boot Kernel with root file system in QEMU&lt;/span&gt;
qemu-system-x86_64 -nographic -kernel linux-4.20.6/arch/x86/boot/bzImage -hda rootfs.img -append &lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;root=/dev/sda rw console=ttyS0&amp;#34;&lt;/span&gt; -s

&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;# Attach gdb&lt;/span&gt;
gdb ./linux-4.20.6/vmlinux 
&lt;span style=&#34;color:#666&#34;&gt;(&lt;/span&gt;gdb&lt;span style=&#34;color:#666&#34;&gt;)&lt;/span&gt; target remote :1234
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Books I Read in 2017</title>
      <link>https://www.anmolsarma.in/post/books-2017/</link>
      <pubDate>Wed, 09 May 2018 20:28:40 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/books-2017/</guid>
      <description>&lt;h3 id=&#34;the-god-of-small-things-by-arundhati-roy&#34;&gt;The God of Small Things by Arundhati Roy&lt;/h3&gt;
&lt;p&gt;A beautifully heart-rending exploration of the human condition. The prose is almost lyrical and the narrative is dreamlike and completely immersing. All the little details add up to symbolise something bigger. The book is part political satire, part social commentary part psychological drama and part fairy tale. In the midst of all this, it manages to capture the thought process of children like no other book.  Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;how-to-win-friends-and-influence-people-by-dale-carnegie&#34;&gt;How To Win Friends And Influence People by Dale Carnegie&lt;/h3&gt;
&lt;p&gt;The original &amp;ldquo;self-help&amp;rdquo; book. Carnegie offers solid advice for dealing with business relationships and public speaking. While some of it may be obvious, it’s especially useful for introverts and people with social anxiety because it outlines a few simple techniques that make meeting new people a little easier. However, some of the techniques for conflict resolution come across as outright manipulative. I doubt it will be life-changing but if you&amp;rsquo;re going to read a self-help book, you could certainly do a lot worse than &lt;em&gt;How to Win Friends&lt;/em&gt;. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-martian-by-andy-weir&#34;&gt;The Martian by Andy Weir&lt;/h3&gt;
&lt;p&gt;While the movie was great, the book is just so much better. A gripping page-turner with a focus on realism and scientific accuracy. Anyone even remotely interested in science and technology would find an immensely relatable hero in Mark Watney. To top off the exciting plot, the writing is crisp, the pacing perfect and the dialogue is brilliant and funny. Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;restart-the-last-chance-for-the-indian-economy-by-mihir-sharma&#34;&gt;Restart: The last chance for the Indian Economy by Mihir Sharma&lt;/h3&gt;
&lt;p&gt;A blunt, irreverent and acerbic account of the long list of policy blunders which ail India&amp;rsquo;s economy. Probably the most well stated and researched rant you&amp;rsquo;ll ever read. The book is filled with anecdotes that are both insightful and funny. While Mihir Sharma jumps the gun with his suggestion in a few places, the work makes it absolutely clear that he knows what he&amp;rsquo;s talking about. He also breaks from the tradition of lionising India&amp;rsquo;s IT and pharma industries and calls them out for what they are. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-curious-incident-of-the-dog-in-the-night-time-by-mark-haddon&#34;&gt;The Curious Incident of the Dog in the Night-Time by Mark Haddon&lt;/h3&gt;
&lt;p&gt;A touching and poignant account of an autistic savant&amp;rsquo;s attempt to solve mysteries. The book does a wonderful job of capturing the perspective of someone with a thoroughly logical mind and difficulties interacting with other people. It also manages to convey the frustrations of those who care for children with special needs.  An excellent if psychologically dissociating read. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-emperor-of-all-maladies-by-siddhartha-mukherjee&#34;&gt;The Emperor of All Maladies by Siddhartha Mukherjee&lt;/h3&gt;
&lt;p&gt;A biography of cancer punctuated with the experiences of the author as a practising oncologist. A perfect blend of scientific exposition and dramatic narrative. The vivid descriptions of biological processes are accessible and the metaphors absolutely exemplary. Also included is a history of the propaganda war waged by tobacco companies and cancer researchers. If you were unaware of the state of contemporary cancer treatments, it will leave you a lot more informed but possibly also a bit worried. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;midnights-children-by-salman-rushdie&#34;&gt;Midnight&amp;rsquo;s Children by Salman Rushdie&lt;/h3&gt;
&lt;p&gt;A story that willfully defies description. Notionally about 1001 children whose destinies are magically intertwined with that of independent India. A narrative packed with digressions, deliberate false steps and allegorical insinuations coupled with immensely funny and brilliant prose. The book captures the essence of everyday Indian life with both the magnificent and the squalid. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;sapiens-a-brief-history-of-humankind-by-yuval-noah-harari&#34;&gt;Sapiens: A Brief History of Humankind by Yuval Noah Harari&lt;/h3&gt;
&lt;p&gt;Like Guns, Germs and Steel but even grander. The sort of book that completely changes one&amp;rsquo;s perspective. The book is full of big ideas ranging from the power of collective delusions, the relationship between wheat and humans and the deep unconscious effects of advertising. Hands down the best book I read in 2017. Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;norse-mythology-by-neil-gaiman&#34;&gt;Norse Mythology by Neil Gaiman&lt;/h3&gt;
&lt;p&gt;A short but gripping and suspenseful retelling of the foundational myths of the Norse pantheon; stories of how Odin, Thor and Loki came to be and how they would fall. The prose is full of witticisms and frequently blurs the distinction between metaphor and reality. Overall, a delightful read. Would Recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-selfish-gene-by-richard-dawkins&#34;&gt;The Selfish Gene by Richard Dawkins&lt;/h3&gt;
&lt;p&gt;An immensely readable treatise on the gene-centred view of evolution by the high priest of New Atheism. The title really does the book injustice, it deals as much with the altruism of individuals as it does with the selfishness of genes. Dawkins also introduces the concept of a meme: a unit for human cultural evolution. Would highly recommend.&lt;/p&gt;
&lt;h3 id=&#34;fahrenheit-451-by-ray-bradbury&#34;&gt;Fahrenheit 451 by Ray Bradbury&lt;/h3&gt;
&lt;p&gt;A dystopian novel about a future where books are outlawed and firemen burn any that are found. It can be read both as a criticism of censorship as well as that of mass media. Perhaps the second theme is more relevant today in the age of viral media than it was in Bradbury&amp;rsquo;s time. While a good read overall, the prose does come off as a bit snobbish. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;black-swan-by-nassim-taleb&#34;&gt;Black Swan by Nassim Taleb&lt;/h3&gt;
&lt;p&gt;An annoyingly long-winded, insufferably pompous and thoroughly grating account of the disproportionate effects of unforeseen events. Much of the book reads like a self-aggrandizing rant. While there are a few good ideas in the book, it could have easily been cut to a third of its size without losing anything of value. Skip the book and listen to one of Taleb&amp;rsquo;s lecture instead. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;foucaults-pendulum-by-umberto-eco-as-translated-by-william-weaver&#34;&gt;Foucault&amp;rsquo;s Pendulum by Umberto Eco as translated by William Weaver&lt;/h3&gt;
&lt;p&gt;Described as The Thinking Man&amp;rsquo;s Da Vinci Code, it&amp;rsquo;s a satirical exposition of people&amp;rsquo;s desire to believe their own version of the truth. Chock full of allusions and references, and incredibly dense, it certainly is not an easy or light read. The plot and characters are hilarious and the writing extremely clever. Reading this, one might end up feeling mentally inadequate. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-raj-at-war-by-yasmin-khan&#34;&gt;The Raj at War by Yasmin Khan&lt;/h3&gt;
&lt;p&gt;Subtitled A People’s History of India’s Second World War, Yasmin Khan does an excellent job collating the experiences of ordinary Indians caught up in the war. There are accounts of not just soldiers but also lascars, nurses, labourers and peasants. The horrors of the Bengal famine are captured in all its gory detail. Also shown is the birth of India&amp;rsquo;s all-powerful and hopelessly apathetic babudom and the police state. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;snow-crash-by-neal-stephenson&#34;&gt;Snow Crash by Neal Stephenson&lt;/h3&gt;
&lt;p&gt;An absurdist, dystopian science fiction novel dealing with elements of history, linguistics, anthropology, religion, computer science, politics, cryptography, memetics and philosophy. Primarily, the plot revolves around information and how it affects humans. The difference between the workings of a man (Or for that matter, a beast) and a machine is frequently blurred to great effect. The book also popularised the term avatar meaning a virtual persona. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;deep-work-by-cal-newport&#34;&gt;Deep Work by Cal Newport&lt;/h3&gt;
&lt;p&gt;The subtitle, Rules for Focused Success in a Distracted World is a definite oversell. It starts off decently. The premise of modern work environments that prioritize superficial and immediate metrics over creating actual value is spot on, as is the description of viral social media platforms stealing our attention and our ability to focus. The meat of the book though, the rules are the usual self-help claptrap full of anecdotes with a dash of survivorship bias. Nevertheless, the initial part of the book makes for good reading. Some might even find the rules useful. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;a-clockwork-orange-by-anthony-burgess&#34;&gt;A Clockwork Orange by Anthony Burgess&lt;/h3&gt;
&lt;p&gt;An unabashedly dark and satirical take on the morality of free will.  The many depictions of violence carry a sense of excitement from Alex, the central character but, the book does not in any way promote violence. Large parts of the book are written in a fictional Russian influence slang which feels very natural while not harming intelligibility. The writing has an almost lyrical quality to it, especially when describing music. A short but unsettling read. Would recommend.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Talk @ RFC&#39;s We Love: CoAPing with the Internet of Things</title>
      <link>https://www.anmolsarma.in/post/coap-talk/</link>
      <pubDate>Sat, 14 Oct 2017 11:56:27 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/coap-talk/</guid>
      <description>&lt;p&gt;Gave an introductory talk on CoAP at the &lt;a href=&#34;https://www.iiesoc.in/single-post/2017/11/02/RFCs-We-Love-HMAC-CoAP-Edition&#34;&gt;5th RFC&amp;rsquo;s We Love meetup&lt;/a&gt;. Turnout was low, probably owing to the rains and the festive season. It was still fun and had great discussions.&lt;/p&gt;
&lt;script async class=&#34;speakerdeck-embed&#34; data-id=&#34;652da89359ea40bab194a5607f4bed2b&#34; data-ratio=&#34;1.33333333333333&#34; src=&#34;//speakerdeck.com/assets/embed.js&#34;&gt;&lt;/script&gt;
</description>
    </item>
    
    <item>
      <title>DCCP: The socket type you probably never heard of</title>
      <link>https://www.anmolsarma.in/post/dccp/</link>
      <pubDate>Tue, 13 Dec 2016 23:10:50 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/dccp/</guid>
      <description>&lt;p&gt;&lt;em&gt;TL;DR: DCCP is a relatively newer transport layer protocol which draws from both TCP and UDP. Jump straight to the &lt;a href=&#34;#example-in-c&#34;&gt;example C code&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&#34;background&#34;&gt;Background&lt;/h2&gt;
&lt;p&gt;Historically, the majority of the traffic on the Internet has been over &lt;a href=&#34;https://en.wikipedia.org/wiki/Transmission_Control_Protocol&#34;&gt;TCP&lt;/a&gt; which provides a reliable connection-oriented stream between two hosts. &lt;a href=&#34;https://en.wikipedia.org/wiki/User_Datagram_Protocol&#34;&gt;UDP&lt;/a&gt; has been mainly used by applications whose brief transfers would be unacceptably slowed by TCP&amp;rsquo;s connection establishment overhead or those for which timeliness is more important than reliability. However, the increasing use of UDP for applications such as internet telephony and streaming media which transfer a large amount of data can lead to significant &lt;a href=&#34;https://en.wikipedia.org/wiki/Network_congestion&#34;&gt;network congestion&lt;/a&gt;. Since unlike TCP, UDP provides no inherent congestion control mechanism, an application can send UDP datagrams at a much higher rate than the available path capacity and cause congestion along the path. Increased congestion may lead to delays, packet loss and the degradation of the network&amp;rsquo;s quality of service.&lt;/p&gt;
&lt;p&gt;Applications and protocols that choose to use UDP as their transport must, therefore, employ mechanisms to prevent congestion and to establish some degree of fairness with concurrent traffic so that the network remains usable. A prominent example of such a congestion control scheme is &lt;a href=&#34;https://en.wikipedia.org/wiki/LEDBAT&#34;&gt;LEDBAT&lt;/a&gt; employed by &lt;a href=&#34;https://en.wikipedia.org/wiki/BitTorrent&#34;&gt;BitTorrent&lt;/a&gt;. However, implementing a congestion control scheme is difficult, time-consuming and error-prone. Multiple non-standard implementations also make it difficult to reason about how applications would respond to network congestion. &lt;a href=&#34;https://en.wikipedia.org/wiki/Datagram_Congestion_Control_Protocol&#34;&gt;DCCP&lt;/a&gt; - Datagram Congestion Control Protocol is intended to mitigate this problem as a transport for unreliable datagrams with built-in congestion control.&lt;/p&gt;
&lt;p&gt;From an application programmer&amp;rsquo;s perspective, DCCP differs from UDP by providing four additional features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Explicit connection establishment between hosts&lt;/li&gt;
&lt;li&gt;Selectable congestion control schemes&lt;/li&gt;
&lt;li&gt;Path MTU discovery to avoid fragmentation&lt;/li&gt;
&lt;li&gt;Service Codes for identifying applications&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;DCCP makes use of Explicit Congestion Notification but it is transparent the  application. DCCP is designed to leave additional functionality such as reliability or Forward Error Correction (FEC) to be layered on top, as and when required rather than at the protocol level itself.&lt;/p&gt;
&lt;h2 id=&#34;explicit-connection-establishment&#34;&gt;Explicit connection establishment&lt;/h2&gt;
&lt;p&gt;The connection establishment semantics of DCCP mirror those of TCP with a client that actively connects to a server that is passively listening on a port. DCCP connections are bidirectional. Logically, however, a DCCP connection consists of two separate unidirectional connections, called half-connections. Each half-connection is a one-way, unreliable datagram pipe. The rationale for this explained in the next section.&lt;/p&gt;
&lt;h2 id=&#34;selectable-congestion-control-schemes&#34;&gt;Selectable congestion control schemes&lt;/h2&gt;
&lt;p&gt;TCP implements congestion control entirely transparently to the application. While it is possible to configure the host to use a specific variant, there is no way for the application to discover which congestion control scheme is in force, let alone negotiate one. DCCP, however, can cater to the different needs of applications by allowing applications to negotiate the congestion control schemes. In fact, each of the half-connections can use a different scheme, allowing for greater control.&lt;/p&gt;
&lt;p&gt;Congesting the network by sending data at a rate that is faster than the slowest link between the endpoints will overwhelm it. This may lead to packet loss leading to retransmissions which may, in turn, lead to further congestion. The solution to this problem is to start transmitting data at a slow rate on a new connection and to then ramp up the speed until packet loss is detected. The transmission rate may then be scaled back until no further packet loss occurs. The optimum speed at which to transfer data  will change with network conditions over the life of the connection. Congestion control schemes differ in how packet loss is estimated and the rate at which is the transmission speed is ramped up or scaled back. DCCP congestion control schemes are denoted by Congestion Control Identifiers - CCIDs. Currently, three CCIDs have been formally specified:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&#34;https://tools.ietf.org/html/rfc4341&#34;&gt;CCID 2&lt;/a&gt; -  TCP-like Congestion Control:&lt;/strong&gt; A quick reacting scheme modelled after TCP which will rapidly ramp up speed to take advantage of available bandwidth and also rapidly scale back when congestion is detected. Suitable for applications that can handle large swings in transmission rates.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&#34;https://tools.ietf.org/html/rfc5348&#34;&gt;CCID 3&lt;/a&gt; - TCP-Friendly Rate Control (TFRC):&lt;/strong&gt; A slower reacting scheme intended to be friendly to concurrent TCP flows in the network. Provides a relatively smoother sending rate at the expense of possibly not utilising all available bandwidth. Suitable for media streaming applications that prefer to minimise abrupt changes in the sending rate.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&#34;https://tools.ietf.org/html/rfc4828&#34;&gt;CCID 4&lt;/a&gt; - TCP-Friendly Rate Control for Small Packets (TFRC-SP):&lt;/strong&gt; An experimental scheme for applications that use a small datagram size and those that change their sending rate by varying the datagram size.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition, the Linux kernel&amp;rsquo;s &lt;a href=&#34;https://github.com/uoaerg/linux-dccp&#34;&gt;DCCP Test Tree&lt;/a&gt; contains an experimental implementation of a scheme modelled after &lt;a href=&#34;https://en.wikipedia.org/wiki/CUBIC_TCP&#34;&gt;TCP CUBIC&lt;/a&gt;. There is also a mode that disables congestion control altogether for &lt;em&gt;UDP-like&lt;/em&gt; behaviour.&lt;/p&gt;
&lt;h2 id=&#34;pmtu-discovery&#34;&gt;PMTU discovery&lt;/h2&gt;
&lt;p&gt;Data between two internet hosts is transferred transmitted as a series of IP packets that pass through intermediate links. Each of these links has a maximum packet size or maximum transmission unit (MTU) that it can transmit without having to break it up into smaller fragments. The largest packet size that does not require fragmentation anywhere along a path is referred to as the path maximum transmission unit or PMTU. Applications can usually get better error tolerance by producing packets smaller than the PMTU. DCCP defines a maximum packet size (MPS) based on the PMTU and the congestion control scheme used for each connection. DCCP implementations will not send any packet bigger than the MPS and instead return an appropriate error to the application. The application can query the DCCP stack for the current MPS and restrict itself from sending datagrams larger than this value and thereby avoid &lt;a href=&#34;https://en.wikipedia.org/wiki/IP_fragmentation&#34;&gt;fragmentation&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;service-codes&#34;&gt;Service Codes&lt;/h2&gt;
&lt;p&gt;DCCP defines a 32 bit Service Code to disambiguate between multiple applications associated with a single a server port. The client specifies the Service Code it wants to connect to and this is used to identify the intended service or application to process a DCCP connection request. Essentially, Service Codes provide an additional level of indirection for connection multiplexing. A server listening on a port may be associated with multiple Service Codes but a client may have only one Service Code, indicating the application it wishes to connect to.&lt;/p&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;
&lt;p&gt;The mainline Linux kernel has included DCCP support since &lt;a href=&#34;https://lwn.net/Articles/149756/&#34;&gt;2.6.14&lt;/a&gt; and mainstream distributions like Ubuntu enable it by default. However, to get the newer experimental features, you will have to build the kernel from the DCCP Test Tree. Or you can also grab the latest stable kernel release merged with the experimental DCCP changes from &lt;a href=&#34;https://github.com/unmole/linux-dccp/releases/latest&#34;&gt;here&lt;/a&gt;. Be sure to enable all the CCIDs in the kernel configuration in &lt;em&gt;Networking Support&lt;/em&gt; &amp;ndash;&amp;gt; &lt;em&gt;Networking Options&lt;/em&gt; &amp;ndash;&amp;gt; &lt;em&gt;The DCCP Protocol&lt;/em&gt; &amp;ndash;&amp;gt; &lt;em&gt;DCCP CCIDs Configuration&lt;/em&gt;. Like the Debian Installation Guide Says, &amp;ldquo;&lt;em&gt;Don&amp;rsquo;t be afraid to try compiling the kernel. It&amp;rsquo;s fun and profitable.&lt;/em&gt;&amp;rdquo; For now, Linux is the only operating system supporting native DCCP, unless you count the patch for an ancient version of FreeBSD.&lt;/p&gt;
&lt;h2 id=&#34;example-in-c&#34;&gt;Example in C&lt;/h2&gt;
&lt;p&gt;The server and client look almost exactly the same as their TCP counterparts with the exception fo the socket type and setting of the service code. The client uses &lt;em&gt;getsockopt()&lt;/em&gt; to read the current maximum packet size. Reading the available CCIDs on the host is shown in &lt;strong&gt;probe.c&lt;/strong&gt;. As libc doesn&amp;rsquo;t still have a &lt;strong&gt;netinet/dccp.h&lt;/strong&gt; header, you will have to get the required constants from the kernel sources or directly use the &lt;strong&gt;dccp.h&lt;/strong&gt; header below. &lt;a href=&#34;https://www.anmolsarma.in/dl/dccp_socket_example.tar.gz&#34;&gt;Download Code&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;server.c&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;sys/socket.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;netinet/in.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;arpa/inet.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;errno.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;
&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;#34;dccp.h&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;
&lt;span style=&#34;color:#080&#34;&gt;#define PORT 1337
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define SERVICE_CODE 42
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;
&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; &lt;span style=&#34;color:#00a000&#34;&gt;error_exit&lt;/span&gt;(&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;str)
{
	perror(str);
	exit(errno);
}

&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; &lt;span style=&#34;color:#00a000&#34;&gt;main&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; argc, &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;**&lt;/span&gt;argv)
{
	&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; listen_sock &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; socket(AF_INET, SOCK_DCCP, IPPROTO_DCCP);
	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (listen_sock &lt;span style=&#34;color:#666&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;)
		error_exit(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;socket&amp;#34;&lt;/span&gt;);

	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; sockaddr_in servaddr &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; {
		.sin_family &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; AF_INET,
		.sin_addr.s_addr &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; htonl(INADDR_ANY),
		.sin_port &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; htons(PORT),
	};

	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;) {
		       &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;}, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;)))
		error_exit(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;setsockopt(SO_REUSEADDR)&amp;#34;&lt;/span&gt;);

	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (bind(listen_sock, (&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; sockaddr &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;)&lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;servaddr, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(servaddr)))
		error_exit(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;bind&amp;#34;&lt;/span&gt;);

	&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// DCCP mandates the use of a &amp;#39;Service Code&amp;#39; in addition the port
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (setsockopt(listen_sock, SOL_DCCP, DCCP_SOCKOPT_SERVICE, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;) {
		       htonl(SERVICE_CODE)}, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;)))
		error_exit(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;setsockopt(DCCP_SOCKOPT_SERVICE)&amp;#34;&lt;/span&gt;);

	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (listen(listen_sock, &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;))
		error_exit(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;listen&amp;#34;&lt;/span&gt;);

	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;for&lt;/span&gt; (;;) {

		printf(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;Waiting for connection...&lt;/span&gt;&lt;span style=&#34;color:#b62;font-weight:bold&#34;&gt;\n&lt;/span&gt;&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;&lt;/span&gt;);

		&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; sockaddr_in client_addr;
		socklen_t addr_len &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(client_addr);

		&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; conn_sock &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; accept(listen_sock, (&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; sockaddr &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;)&lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;client_addr, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;addr_len);
		&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (conn_sock &lt;span style=&#34;color:#666&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;) {
			perror(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;accept&amp;#34;&lt;/span&gt;);
			&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;continue&lt;/span&gt;;
		}

		printf(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;Connection received from %s:%d&lt;/span&gt;&lt;span style=&#34;color:#b62;font-weight:bold&#34;&gt;\n&lt;/span&gt;&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;&lt;/span&gt;,
		       inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port));

		&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;for&lt;/span&gt; (;;) {
			&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; buffer[&lt;span style=&#34;color:#666&#34;&gt;1024&lt;/span&gt;];
			&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Each recv() will read only one individual message.
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;			&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Datagrams, not a stream!
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;			&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; ret &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; recv(conn_sock, buffer, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(buffer), &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;);
			&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (ret &lt;span style=&#34;color:#666&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;)
				printf(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;Received: %s&lt;/span&gt;&lt;span style=&#34;color:#b62;font-weight:bold&#34;&gt;\n&lt;/span&gt;&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;&lt;/span&gt;, buffer);
			&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;else&lt;/span&gt;
				&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;break&lt;/span&gt;;

		}

		close(conn_sock);
	}
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;client.c&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;sys/socket.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;netinet/in.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;arpa/inet.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;errno.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;
&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;#34;dccp.h&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;
&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; &lt;span style=&#34;color:#00a000&#34;&gt;error_exit&lt;/span&gt;(&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;str)
{
	perror(str);
	exit(errno);
}

&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; &lt;span style=&#34;color:#00a000&#34;&gt;main&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; argc, &lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;char&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;argv[])
{
	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (argc &lt;span style=&#34;color:#666&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;5&lt;/span&gt;) {
		printf(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;Usage: ./client &amp;lt;server address&amp;gt; &amp;lt;port&amp;gt; &amp;lt;service code&amp;gt; &amp;lt;message 1&amp;gt; [message 2] ... &lt;/span&gt;&lt;span style=&#34;color:#b62;font-weight:bold&#34;&gt;\n&lt;/span&gt;&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;&lt;/span&gt;);
		exit(&lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;);
	}
	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; sockaddr_in server_addr &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; {
		.sin_family &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; AF_INET,
		.sin_port &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; htons(atoi(argv[&lt;span style=&#34;color:#666&#34;&gt;2&lt;/span&gt;])),
	};

	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#666&#34;&gt;!&lt;/span&gt;inet_pton(AF_INET, argv[&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;], &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;server_addr.sin_addr.s_addr)) {
		printf(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;Invalid address %s&lt;/span&gt;&lt;span style=&#34;color:#b62;font-weight:bold&#34;&gt;\n&lt;/span&gt;&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;&lt;/span&gt;, argv[&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;]);
		exit(&lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;);
	}

	&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; socket_fd &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; socket(AF_INET, SOCK_DCCP, IPPROTO_DCCP);
	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (socket_fd &lt;span style=&#34;color:#666&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;)
		error_exit(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;socket&amp;#34;&lt;/span&gt;);

	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (setsockopt(socket_fd, SOL_DCCP, DCCP_SOCKOPT_SERVICE, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;) {htonl(atoi(argv[&lt;span style=&#34;color:#666&#34;&gt;3&lt;/span&gt;]))}, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt;)))
		error_exit(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;setsockopt(DCCP_SOCKOPT_SERVICE)&amp;#34;&lt;/span&gt;);

	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (connect(socket_fd, (&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;struct&lt;/span&gt; sockaddr &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt;) &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;server_addr, &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(server_addr)))
		error_exit(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;connect&amp;#34;&lt;/span&gt;);

	&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Get the maximum packet size
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;	uint32_t mps;
	socklen_t res_len &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;sizeof&lt;/span&gt;(mps);
	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (getsockopt(socket_fd, SOL_DCCP, DCCP_SOCKOPT_GET_CUR_MPS, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;mps, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;res_len))
		error_exit(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;getsockopt(DCCP_SOCKOPT_GET_CUR_MPS)&amp;#34;&lt;/span&gt;);
	printf(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;Maximum Packet Size: %d&lt;/span&gt;&lt;span style=&#34;color:#b62;font-weight:bold&#34;&gt;\n&lt;/span&gt;&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;&lt;/span&gt;, mps);

	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;for&lt;/span&gt; (&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; i &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;4&lt;/span&gt;; i &lt;span style=&#34;color:#666&#34;&gt;&amp;lt;&lt;/span&gt; argc; i&lt;span style=&#34;color:#666&#34;&gt;++&lt;/span&gt;) {
		&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (send(socket_fd, argv[i], strlen(argv[i]) &lt;span style=&#34;color:#666&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#666&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;)
			error_exit(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;send&amp;#34;&lt;/span&gt;);
	}

	&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Wait for a while to allow all the messages to be transmitted
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;	usleep(&lt;span style=&#34;color:#666&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;1000&lt;/span&gt;);

	close(socket_fd);
	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;;
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;probe.c&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;sys/socket.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;lt;netinet/in.h&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;
&lt;span style=&#34;color:#080&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#080&#34;&gt;&amp;#34;dccp.h&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;
&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; &lt;span style=&#34;color:#00a000&#34;&gt;main&lt;/span&gt;()
{
	&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; sock_fd &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; socket(AF_INET, SOCK_DCCP, IPPROTO_DCCP);

	&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// Check the congestion control schemes available
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;	socklen_t res_len &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;6&lt;/span&gt;;
	uint8_t ccids[&lt;span style=&#34;color:#666&#34;&gt;6&lt;/span&gt;];
	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;if&lt;/span&gt; (getsockopt(sock_fd, SOL_DCCP, DCCP_SOCKOPT_AVAILABLE_CCIDS, ccids, &lt;span style=&#34;color:#666&#34;&gt;&amp;amp;&lt;/span&gt;res_len)) {
		perror(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;getsockopt(DCCP_SOCKOPT_AVAILABLE_CCIDS)&amp;#34;&lt;/span&gt;);
		&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#666&#34;&gt;1&lt;/span&gt;;
	}

	printf(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34;%d CCIDs available:&amp;#34;&lt;/span&gt;, res_len);
	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;for&lt;/span&gt; (&lt;span style=&#34;color:#0b0;font-weight:bold&#34;&gt;int&lt;/span&gt; i &lt;span style=&#34;color:#666&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#666&#34;&gt;0&lt;/span&gt;; i &lt;span style=&#34;color:#666&#34;&gt;&amp;lt;&lt;/span&gt; res_len; i&lt;span style=&#34;color:#666&#34;&gt;++&lt;/span&gt;)
		printf(&lt;span style=&#34;color:#b44&#34;&gt;&amp;#34; %d&amp;#34;&lt;/span&gt;, ccids[i]);

	&lt;span style=&#34;color:#a2f;font-weight:bold&#34;&gt;return&lt;/span&gt; res_len;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;dccp.h&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-C&#34; data-lang=&#34;C&#34;&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;/* This file only contains constants necessary for user space to call
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt; * into the kernel and thus, contains no copyrightable information. */&lt;/span&gt;

&lt;span style=&#34;color:#080&#34;&gt;#ifndef DCCP_DCCP_H
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_DCCP_H
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;
&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// From the kernel&amp;#39;s include/linux/socket.h
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define SOL_DCCP                        269
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;
&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;// From kernel&amp;#39;s include/uapi/linux/dccp.h
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_SERVICE            2
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_CHANGE_L           3
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_CHANGE_R           4
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_GET_CUR_MPS        5
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_SERVER_TIMEWAIT    6
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_SEND_CSCOV         10
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_RECV_CSCOV         11
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_AVAILABLE_CCIDS    12
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_CCID               13
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_TX_CCID            14
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_RX_CCID            15
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_QPOLICY_ID         16
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_QPOLICY_TXQLEN     17
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_CCID_RX_INFO       128
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;#define DCCP_SOCKOPT_CCID_TX_INFO       192
&lt;/span&gt;&lt;span style=&#34;color:#080&#34;&gt;&lt;/span&gt;
&lt;span style=&#34;color:#080&#34;&gt;#endif &lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;//DCCP_DCCP_H
&lt;/span&gt;&lt;span style=&#34;color:#080;font-style:italic&#34;&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;caveats-and-conclusion&#34;&gt;Caveats and Conclusion&lt;/h2&gt;
&lt;p&gt;DCCP is not mainstream. It is not widely deployed or even supported. Documentation is sparse. Although Linux DCCP NAT is functional, many intermediate boxes will probably just drop DCCP traffic. DCCP is the Fixed-gear bicycle of Layer 4, it is the ultimate hipster transport.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Books I Read in 2015</title>
      <link>https://www.anmolsarma.in/post/books-2015/</link>
      <pubDate>Sun, 03 Jan 2016 21:36:15 +0530</pubDate>
      
      <guid>https://www.anmolsarma.in/post/books-2015/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://www.anmolsarma.in/images/2016/books-2015.jpg&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h3 id=&#34;india-after-gandhi-by-ramachandra-guha&#34;&gt;India After Gandhi by Ramachandra Guha&lt;/h3&gt;
&lt;p&gt;A thoroughly sourced, brilliantly written and mostly objective history of India. Guha’s scholarship and unbiased account really shines throughout the book. Save for one non-sequitur and one inaccurate and one might say unfair characterization there is nothing to complain about. The rare photographs included in the book are fascinating by themselves. Reading the book makes you wonder if it is Indian history itself or Guha’s writing that makes it such a page turner. Definitely the best book I’ve read this year. Would  recommend.&lt;/p&gt;
&lt;h3 id=&#34;patriots-and-partisans-by-ramachandra-guha&#34;&gt;Patriots and Partisans by Ramachandra Guha&lt;/h3&gt;
&lt;p&gt;A collection of essays on India from a self proclaimed liberal centrist. Chock full of telling anecdotes and witty insights.  While it is interesting on it’s own, it is nowhere as gripping as India After Gandhi. Guha is definitely a better scholar than he is a polemicist but he really excels as a storyteller. The chapter describing how the Congress Dynasty and its sychophants destroyed an insititution Guha personally cherished was probably the best of the lot. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;ramayana-by-valmiki-as-retold-by-c-rajagopalachari&#34;&gt;Ramayana by Valmiki as retold by C. Rajagopalachari&lt;/h3&gt;
&lt;p&gt;A highly condensed and simplified retelling of the timeless epic from one &lt;em&gt;bhakta&lt;/em&gt; intended for prospective young &lt;em&gt;bhaktas&lt;/em&gt;. But for me, Rajaji’s commentary and comparison between different versions of the epic are more interesting than the actual narrative. The standard trope of digressing to heap praise on the protagonist slackens the pace and gets rather irritating after the first few times. So irritating that finishing this book took me far longer than it should have, given its size. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;picture-of-dorian-grey-by-oscar-wilde&#34;&gt;Picture of Dorian Grey by Oscar Wilde&lt;/h3&gt;
&lt;p&gt;Beneath the endlessly quotable characters and beyond the absurd supernatural premise lies a much deeper message. Or possibly several such messages. Sadly, I for one have no idea what they are supposed to be. Wilde’s self-indulgent prose aside, I found the book incredibly difficult to read and had to force myself to finish it. Unlike almost everyone else I know who has read the book, it had no discernible impact on me except for making me a little more choosy about what I read. Would not recommend&lt;/p&gt;
&lt;h3 id=&#34;a-short-history-of-nearly-everything-by-bill-bryson&#34;&gt;A Short History Of Nearly Everything by Bill Bryson&lt;/h3&gt;
&lt;p&gt;A very lucid and easily digestible survey of what we know and how we know what we know. Funny, insightful and entertaining, Bryson’s curiosity and style makes even geology seem interesting. While doing a good job of explaining the science and the history behind the science, it also manages to capture the human side of the countless passionate men and women who dedicate their lives to advancing the state of human knowledge. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-ultimate-hitchhikers-guide-to-the-galaxy-by-douglas-adams&#34;&gt;The Ultimate Hitchhiker&amp;rsquo;s Guide to the Galaxy by Douglas Adams&lt;/h3&gt;
&lt;p&gt;Technically not one book but &lt;em&gt;&amp;ldquo;a trilogy of five&amp;rdquo;&lt;/em&gt;. The Hitchhiker&amp;rsquo;s Guide to the Galaxy and The Restaurant at the End of the Universe are absolutely hilarious. Life, the Universe and Everything, So Long, and Thanks for All the Fish and Mostly Harmless are slightly less so. It&amp;rsquo;s probably a bad idea to go through all of them in one go because the absurdity gets a little too much to handle. An otherwise brilliant collection. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;siddhartha-by-hermann-hesse-as-translated-by-hilda-rosner&#34;&gt;Siddhartha by Hermann Hesse as translated by Hilda Rosner&lt;/h3&gt;
&lt;p&gt;The best thing about this book is its size. At barely 150 pages, you don’t waste too much time on this New Age twaddle full of knowing smiles, hearts spontaneously bursting with joy and characters who for some reason resemble various fruit and vegetables. Much like the narrative, Hesse’s attempt at reproducing Sanskrit idioms feels jarring and pointless.  The only realization I had from reading this book was that the eponymous protagonist went about the ashramas of life in a vipareeta order. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;train-to-pakistan-by-khushwant-singh&#34;&gt;Train to Pakistan by Khushwant Singh&lt;/h3&gt;
&lt;p&gt;A fictional account of a very real disaster. Kushwant Singh’s prose is simple, engaging and very readable. The characters  and the setting feel all too familiar and real as do the norms and social memes. The book does a very good job of capturing the senselessness of the violence and the tribal rationalizations invoked to justify it. The ending, while a little over the top, does manage to leave an emotional impact. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;if-its-monday-it-must-be-madurai-by-srinath-perur&#34;&gt;If It&amp;rsquo;s Monday It Must Be Madurai by Srinath Perur&lt;/h3&gt;
&lt;p&gt;This was the first travel book I’ve ever read and it did not disappoint. Perur’s book is as much about the people he traveled with and their reasons  for travelling as it is bout the places themselves. The observations of the stereotypical Indian traits and notions are spot on and the commentary is effortlessly funny. The book is perhaps more accurately subtitled A Conducted tour of the Indian Traveler. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;brave-new-world-by-aldous-huxley&#34;&gt;Brave New World by Aldous Huxley&lt;/h3&gt;
&lt;p&gt;The book most frequently compared to and contrasted with George Orwell’s dystopian 1984. Huxley’s  take on dystopia is an anti-utopia centered around the cult of Henry Ford. While the premise is decent, the over the top caricature of Fordian society as the opposite of what is Huxley’s sense of morality does reduce the overall impact and the result is no where as haunting as 1984’s Big Brother. The book is short enough to finish in a couple of sittings and it is probably best to finish it quickly as I found it difficult to read when stretched out. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-accidental-prime-minister-by-sanjaya-baru&#34;&gt;The Accidental Prime Minister by Sanjaya Baru&lt;/h3&gt;
&lt;p&gt;After the 2008 financial crisis, as major economies of the world went into recession, the Indian growth story seemed to remain intact. International journalists looking for post hoc explanation began to hail Dr. Manmohan Singh as the economist prime minister who held it together. Unblemished by the taint of corruption that was to follow, at this point Dr. Singh enjoyed international recognition and renown. In this supposed tell-all book, Sanjaya Baru claims credit for the successful PR campaign he undertook as the PM’s spin doctor. While book is in no way a revelation, it does flesh out the details and put things into perspective about how the UPA government and the Congress party functioned. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;arthashastra-by-kautilya-as-translated-and-rearranged-by-ln-rangarajan&#34;&gt;Arthashastra by Kautilya as translated and rearranged by L.N. Rangarajan&lt;/h3&gt;
&lt;p&gt;As if taking a cue from the success of Art of War themed self-help books, distilled Kautilyan teachings re-purposed for the modern corporate have become popular of late. Not wanting to be given truisms of some random author’s reading into Kautilya, I went to the original source. While I couldn’t find any universally applicable ancient wisdom, reading the Arthashastra was enjoyable. Rather than the simplified, whitewashed and sometimes politically colored descriptions of ancient India of history books, the Arthashastra is a contemporary insider’s account of ancient Indian society or at least an idealized conception of it. But given its nature, the book is filled with lists and tables and permutations and gradations. Skimming through these and focusing on more subjective descriptions makes for a very interesting reading. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;burmese-days-by-george-orwell&#34;&gt;Burmese Days by George Orwell&lt;/h3&gt;
&lt;p&gt;Based on Orwell’s time as an officer of the Indian Imperial Police, Burmese Days pulls no punches while describing the colonial experience. The hypocrisy and cognitive dissonance of the British, the opportunism and corruption of native officials, the vanity and the pointless pursuit of prestige by everyone involved, the frustrated attempts at finding love an companionship and finally the frailty of the human condition, Orwell tackles it all. While nowhere near as popular as Orwell’s other books, Burmese Days is certainly an excellent book. Would recommend.&lt;/p&gt;
&lt;h3 id=&#34;who-was-shivaji-by-govind-pansare&#34;&gt;Who Was Shivaji by Govind Pansare&lt;/h3&gt;
&lt;p&gt;This was not meant to be a book. Expanded from an earlier speech, Who Was Shivaji would have remained a niche political pamphlet hadn’t Govind Pansare been murdered in cold blood. The comrades of Left World Books seemed to have no ethical or ideological qualms about exploiting the death of its author. Even when printed using the ridiculously large font, the book still doesn’t reach a hundred pages. There just isn&amp;rsquo;t enough material to justify turning into a book. As for the material that is there, it is mostly unremarkable stuff. The most interesting parts of the book were actually the letters written by Shivaji, reproduced in the appendix. By far, the most disappointing book of the year. Would not recommend.&lt;/p&gt;
&lt;h3 id=&#34;the-great-indian-novel-by-shashi-tharoor&#34;&gt;The Great Indian Novel by Shashi Tharoor&lt;/h3&gt;
&lt;p&gt;Puns, allusions and witticisms that&amp;rsquo;s what The Great Indian Novel is made of. The title being a reference to Mahabharata, Sashi Tharoor’s debut novel tells the story of modern India using characters from the epic. Tharoor’s style is engaging, extremely irreverent and incredibly funny. Taking shots at everyone from Gandhi to Nehru to the Indian media with a few self-referential jokes about NRI’s and diplomats thrown in for good measure. After an excellent start, and buildup, the plot sags a bit. Given the subject matter, there probably is no closure possible but the climax does feel a bit week. Overall a decent way to close the year. Would recommend.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Lazy Performance Comparison of WordPress and Ghost</title>
      <link>https://www.anmolsarma.in/post/lazy-performance-comparison-of-wordpress-and-ghost/</link>
      <pubDate>Sat, 04 Apr 2015 18:40:03 +0000</pubDate>
      
      <guid>https://www.anmolsarma.in/post/lazy-performance-comparison-of-wordpress-and-ghost/</guid>
      <description>&lt;p&gt;So, I switched to a new blogging platform. Again. After trying out a static approach, I moved back to a WordPress when I stumbled across &lt;a href=&#34;https://www.openshift.com/&#34;&gt;OpenShift&lt;/a&gt; (&lt;em&gt;And their fantastic &lt;a href=&#34;https://www.openshift.com/products/pricing/plan-comparison&#34;&gt;free plan&lt;/a&gt;&lt;/em&gt;). That was well over two years ago. In the meantime, I hardly blogged and didn&amp;rsquo;t really run into any issues but the blog did feel a tad sluggish.&lt;/p&gt;
&lt;p&gt;Fast-forward to yesterday when I had a sudden impulse to try something new. Ghost looked interesting so, I spun up an install using OpenShift&amp;rsquo;s &lt;a href=&#34;https://github.com/openshift-quickstart/openshift-ghost-quickstart&#34;&gt;Ghost Quick-Start&lt;/a&gt; and proceeded to &lt;a href=&#34;https://ghostforbeginners.com/how-to-transfer-blog-posts-from-wordpress-to-ghost/&#34;&gt;import data from my WordPress&lt;/a&gt; blog which turned out to be pretty painless.&lt;/p&gt;
&lt;p&gt;Given the same resources (&lt;em&gt;Small Gear&lt;/em&gt;) and same amount tweaking (i.e. none, using OpenShift&amp;rsquo;s quickstart installation defaults and using the default themes with no plugins), Ghost certainly &lt;em&gt;felt&lt;/em&gt; a lot faster but how fast was it really? To answer that (&lt;em&gt;And because I apparently have nothing better to do on a Friday night&lt;/em&gt;), I started a simultaneous stress test on WordPress and Ghost using &lt;a href=&#34;http://blazemeter.com/&#34;&gt;BlazeMeter&lt;/a&gt; with a maximum of 50 users. The answer, as turns out is a &lt;strong&gt;helluva lot faster!&lt;/strong&gt;&lt;/p&gt;
&lt;style type=&#34;text/css&#34;&gt;
table{
border-collapse: collapse;
border: 1px solid black;
width: 100%;
}
table td{
border: 1px solid black;
padding: 5px;
}
&lt;/style&gt;
&lt;table&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;Avg. Latency&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;Avg. Response Time&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;90%&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;95%&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;99%&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;Min&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;Max&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Ghost&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;255.05&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;752.28&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;739&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;793&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;4647&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;602&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;7240&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Wordpress&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;12129.55&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;21238.06&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;33641&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;37725&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;52178&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;2273&lt;/td&gt;
&lt;td align=&#34;right&#34;&gt;67093&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;On average, Ghost&amp;rsquo;s response is &lt;strong&gt;28 times faster&lt;/strong&gt; and its latency is &lt;strong&gt;47 times lower&lt;/strong&gt;. Looking at how the two respond to load is interesting:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.anmolsarma.in/images/2015/04/Ghost-wordpress-responsetime.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.anmolsarma.in/images/2015/04/Ghost_Wordpress_latency.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Ghost doesn&amp;rsquo;t even seem to break a sweat while WordPress starts panting quite early into the run. The longest it took for Ghost to respond was &lt;strong&gt;7240 ms&lt;/strong&gt; which is almost a whole order of a magnitude faster than Wondpress&amp;rsquo;s &lt;strong&gt;67093 ms&lt;/strong&gt;. The shortest time for Ghost is &lt;strong&gt;602 ms&lt;/strong&gt;, a comfortable &lt;strong&gt;3.77 times&lt;/strong&gt; better than &lt;strong&gt;2273 ms&lt;/strong&gt; it took WordPress.&lt;/p&gt;
&lt;p&gt;Basically Ghost crushes WordPress in this admittedly lazy and unscientific test. It is pretty similar to what others have reported. If your personal WordPress setup is struggling to keep up with traffic, you should at least consider Ghost. It doesn&amp;rsquo;t have anywhere near the number of plugins or themes as WordPress, it clearly is not as mature (&lt;em&gt;It&amp;rsquo;s still in version 0.5.10&lt;/em&gt;) but boy is it fast! As for the writing flow, I can only say its different. I&amp;rsquo;m not entirely sure if it is better than what we have been used to (&lt;em&gt;No spell check&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;I for one am quite happy I tried (&lt;em&gt;And switched to&lt;/em&gt;) Ghost. And I got a blog post out it to boot!&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Art of Living Foundation&#39;s Kurshed Batliwala Debunked</title>
      <link>https://www.anmolsarma.in/post/kurshed-batliwala-debunked/</link>
      <pubDate>Sun, 28 Jul 2013 10:07:52 +0000</pubDate>
      
      <guid>https://www.anmolsarma.in/post/kurshed-batliwala-debunked/</guid>
      <description>&lt;p&gt;A critical look at Khurshed Batliwala’s talk, “Technology of Spirituality” delivered at Ruia College, Mumbai.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;center&gt;&lt;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#34;https://www.youtube.com/embed/RSHFzZmQPj0&#34; frameborder=&#34;0&#34; allowfullscreen&gt;&lt;/iframe&gt;&lt;/center&gt;
&lt;p&gt;Mr. Batliwala makes a number of extraordinary claims about the state of ancient Indian science and technology. Most of them however, turn out to be exaggerations, misinterpretations or outright fabrications. He then attributes all scientific progress to ‘spirituality’.&lt;/p&gt;
&lt;p&gt;The talk is nothing more than a sales pitch for Mr. Mr. Ravi Shankar’s ‘Art of Living Foundation’.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Talk @ EmWare: Getting started with Linux</title>
      <link>https://www.anmolsarma.in/post/talk-emware/</link>
      <pubDate>Mon, 27 May 2013 06:30:00 +0000</pubDate>
      
      <guid>https://www.anmolsarma.in/post/talk-emware/</guid>
      <description>&lt;p&gt;Gave an introductory talk on Linux, basically a rehash of the &lt;a href=&#34;http://www.anmolsarma.in/talk-klu/&#34;&gt;talk I gave at KLU&lt;/a&gt; a couple of years ago.&lt;/p&gt;
&lt;script async class=&#34;speakerdeck-embed&#34; data-id=&#34;cfa24e0065b4491d8c06a71a514df295&#34; data-ratio=&#34;1.33333333333333&#34; src=&#34;//speakerdeck.com/assets/embed.js&#34;&gt;&lt;/script&gt;
</description>
    </item>
    
    <item>
      <title>Talk @ EmWare: Getting Started with Git</title>
      <link>https://www.anmolsarma.in/post/talk-emware-getting-started-with-git/</link>
      <pubDate>Fri, 17 May 2013 06:30:00 +0000</pubDate>
      
      <guid>https://www.anmolsarma.in/post/talk-emware-getting-started-with-git/</guid>
      <description>&lt;p&gt;Gave an introductory interactive tutorial on using Git. I couldn&amp;rsquo;t finish the slides on time but managed cover everything on the agenda.&lt;/p&gt;
&lt;p&gt;Now that the talk is done, I&amp;rsquo;m don&amp;rsquo;t feel especially inclined to complete the slides.&lt;/p&gt;
&lt;script async class=&#34;speakerdeck-embed&#34; data-id=&#34;0ed1c9358c2e4f42b4380758771770fc&#34; data-ratio=&#34;1.33333333333333&#34; src=&#34;//speakerdeck.com/assets/embed.js&#34;&gt;&lt;/script&gt;
</description>
    </item>
    
    <item>
      <title>Defeating India&#39;s Central Monitoring System</title>
      <link>https://www.anmolsarma.in/post/defeating-the-central-monitoring-system/</link>
      <pubDate>Thu, 09 May 2013 14:08:00 +0000</pubDate>
      
      <guid>https://www.anmolsarma.in/post/defeating-the-central-monitoring-system/</guid>
      <description>&lt;p&gt;The Government of India has rolled out the &lt;a href=&#34;http://en.wikipedia.org/wiki/Central_Monitoring_System&#34;&gt;Central Monitoring System&lt;/a&gt; which will allow it to access any piece of data passing through an Indian service provider. This means the government can now read all your text messages, emails and call records.&lt;/p&gt;
&lt;p&gt;Because &lt;em&gt;privacy&lt;/em&gt; does not bring in votes, it is highly unlikely that any political party will oppose this system. Circumventing this system however, is rather simple using &lt;a href=&#34;http://en.wikipedia.org/wiki/Pretty_Good_Privacy&#34;&gt;PGP&lt;/a&gt; or any other &lt;em&gt;munition grade&lt;/em&gt; cryptographic scheme. So, if anyone wishes to communicate with me securely, please encrypt your message using this &lt;a href=&#34;https://www.anmolsarma.in/pgp/anmol_pgp.asc&#34;&gt;key&lt;/a&gt;, whose fingerprint should be:&lt;/p&gt;
&lt;center&gt;```AA3C 18D8 88D6 EC67 6887  2B21 5D64 D65C 162D 0A3C```&lt;/center&gt;
&lt;p&gt;You may now put your tin-foil hat back on again.&lt;/p&gt;
&lt;p&gt;Edit: Replaced my old key with a 4096-bit RSA key.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Hello Again, World!</title>
      <link>https://www.anmolsarma.in/post/hello-again-world/</link>
      <pubDate>Tue, 19 Feb 2013 17:59:29 +0000</pubDate>
      
      <guid>https://www.anmolsarma.in/post/hello-again-world/</guid>
      <description>&lt;p&gt;Here it goes again: After a couple of attempts with Blogger, a dozen iterations with WordPress, a very brief tryst with Drupal and a false start with Bloggart, I’ve now decided to ditch dynamic content management systems and give Octopress a spin.&lt;/p&gt;
&lt;p&gt;I like the idea of a statically generated site I can deploy anywhere. I used Sphinx for a documentation once and the experience with was pretty good. However, getting Sphinx to work for a personal blog seemed to be too much work, so Octopress it is. So far I’m really happy with Octopress and with minimal tweaking, I have all the functionality I need. Hopefully, I will stick with it and actually blog this time around. Fingers crossed!&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Das Blinkenlights on the MSP430 Launchpad with Linux</title>
      <link>https://www.anmolsarma.in/post/msp430-launchpad-linux/</link>
      <pubDate>Sat, 12 Jan 2013 19:06:05 +0000</pubDate>
      
      <guid>https://www.anmolsarma.in/post/msp430-launchpad-linux/</guid>
      <description>&lt;p&gt;TI’s &lt;a href=&#34;http://www.ti.com/tool/msp-exp430g2&#34; title=&#34;MSP430 Launchpad&#34;&gt;MSP430 LaunchPad&lt;/a&gt; development kit offers some serious bang for the buck. You get two modern 16-bit microcontrollers, a programmer-cum-debugger with pins broken out and a USB cable for less than 5 USD inclusive of shipping. TI even provides two free (as in beer) IDE’s for Windows. Linux support though was a bit sketchy when the board was first released.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.anmolsarma.in/images/2015/09/LaunchPad.jpg&#34; alt=&#34;&#34;&gt;
 &lt;/p&gt;
&lt;p&gt;Things of course have greatly improved and getting the Launchpad to work with Linux is now a breeze. The versions of MSPGCC and MSPDebug in Ubuntu 11.10’s repositories seem to work just fine. There’s also functional Arduino fork for the MSP430 called &lt;a href=&#34;http://energia.nu/&#34; title=&#34;Energia&#34;&gt;Energia&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Mole Nama: A Linux Fantasy Saga</title>
      <link>https://www.anmolsarma.in/post/mole-nama-a-linux-fantasy-saga/</link>
      <pubDate>Sun, 19 Aug 2012 18:23:22 +0000</pubDate>
      
      <guid>https://www.anmolsarma.in/post/mole-nama-a-linux-fantasy-saga/</guid>
      <description>&lt;p&gt;&lt;strong&gt;Mole Nama&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;A historical account of the Mole’ani people in the Free Lands&lt;/em&gt;&lt;/p&gt;
&lt;p&gt; -Inestimabel Montcastellus&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;  We Mole’ani are a Geekic people, who like millions of other races call the Free Lands home. However, our people originally came from the other side; the Dark Lands that shall not be named. The Dark Lands were under monopolistic rule of the Borg and their brethren. Piracy was common and so were the viral diseases which accompanied the booty. Systemic crashes and ‘illegal operations’ were the order of the day. The Three Fingered Salute was often the only way out. But even then, there was the ever present danger of being crippled by a terrorizing bout of Blue Death.&lt;/p&gt;
&lt;p&gt;  In the midst of chaos, the Mole’ani saw hope. The communes of Firey Foxen and We El Sea brought some stability, the likes of which were never heard of in the Dark Lands. This coupled with the Enlightenment of Openness convinced our people that there was a better way.&lt;br&gt;
While the Mole’ani were eager to move to where there was freedom and openness, obtaining a passage to the other side was difficult. With their limited means, they could only go as far as the Isles of Pupey before being forced to return to the Dark Lands.&lt;/p&gt;
&lt;p&gt;  Then came redemption. The Mole’ani came to know that Benevolent Emperor of Ubunatia, determined to assist people like them, had declared the Shipet campaign and sent out his fleet. Finally, our people were able to cross the Vu’Bee Strait, landing on Ubunatian coasts in the era of the Heron.&lt;/p&gt;
&lt;p&gt;  There, they quickly assimilated and became Ubunatians in name and spirit, severing their last ties to Darkness. The Mole’ani turned into missionary paladins, helping bring in dozens of new ally races into the Free Lands. Our people and our allies traveled widely across the Free Lands, touring Ubunatia’s vassal states Kubunatia and Zubunatia and even as far as the lands of the Scarlet Caps and Green Lizards.&lt;/p&gt;
&lt;p&gt;  The Mole’ani however remained loyal Ubunatians. There was minimal dissent even during the Directional Reform of the Lynx era.Things changed with the stirring of the Unitarian Revolution. Hoping to preserve their way of life, our people sought refuge in the vassal state of Zubunatia. Their attempts to change the Zubunatian system proved disastrous, forcing them to flee North and defect to the Mint Realm.&lt;/p&gt;
&lt;p&gt;  And our people remained in peace. However, trouble started once more. The Genom clergy’s antics had caused massive outrage across the Free Lands. Ubunatia, the region’s dominant power had already parted ways with the Genom during the Revolution and refused to have anything to do with it. Refugees fled to the North in their hundreds of thousands and the Mint Realm rose in defiance.&lt;/p&gt;
&lt;p&gt;  In the far away Archinan Republic, a group of dissidents splintered from the Genom and proclaimed the Path of Mayte to defend their cherished old ways. The Mint Realm, although skeptical about Mayte’s future, immediately declared its support to the fledgling movement.&lt;br&gt;
At the same time, the Realm ennobled Sinamon to ensure the survival of the old ways.&lt;/p&gt;
&lt;p&gt;  In the midst of turmoil, the Mole’ani yearned for stability. They returned to the South and settled in the borderlands of Ubunatia and Zubunatia where they remain to this day.&lt;/p&gt;
&lt;p&gt;Inspired by the &lt;a href=&#34;http://www.dedoimedo.com/computers/linux-world-map.html&#34; title=&#34;Linux World Map&#34;&gt;Great Linux World Map&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Talk @ KLU: Linux? Say whaat?!</title>
      <link>https://www.anmolsarma.in/post/talk-klu/</link>
      <pubDate>Mon, 17 Oct 2011 21:20:38 +0000</pubDate>
      
      <guid>https://www.anmolsarma.in/post/talk-klu/</guid>
      <description>&lt;p&gt;Gave an introductory talk on Linux at &lt;a href=&#34;http://www.kluniversity.in/&#34;&gt;Koneru Lakshmiah University&lt;/a&gt;, with &lt;a href=&#34;http://www.elitenewb.wordpress.com/&#34;&gt;Vamsi&lt;/a&gt;following up with a talk on Bugs and Hacks as a part of the ‘workshop’ organised by the KLU Linux Users Group. With about 150 newbish students in attendance, it was fun albeit in a masochistic kind of a way.&lt;/p&gt;
&lt;p&gt;Here’s a shitty picture from the talk, courtesy of Vamsi:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.anmolsarma.in/images/2015/04/KLU-Linux-1.jpg&#34; alt=&#34;KLU Linux&#34;&gt;
And here are the sildes:
&lt;img src=&#34;https://www.anmolsarma.in/images/2015/04/Linux-Say-whaat--2.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Edit: I lost the slides. Only this sad screenshot remains :(&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Hello, World!</title>
      <link>https://www.anmolsarma.in/post/hello-world-2/</link>
      <pubDate>Sun, 16 Oct 2011 17:57:01 +0000</pubDate>
      
      <guid>https://www.anmolsarma.in/post/hello-world-2/</guid>
      <description>&lt;p&gt;This is the 11th iteration of my blog/homepage. I’ve finally found a setup that I like (Thanks to Bloggart!) and unless I run into any major issues, I’m probably going to stick with it. Maybe now I’ll finally stop resetting the site and get down to actually blogging!&lt;/p&gt;
&lt;p&gt;Watch this space!&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
