The one-time pad is one
of the simplest and well known secure encryption schemes. Suppose we
have a message \(m\), which is a sequence of \(L\) bits. The idea of the one-time pad is to take an additional \(L\) bits selected at random, called the key, and then create the ciphertext \(c\) by xor’ing the key and message together: 
 $$ c = k \oplus m. $$ 
 To decrypt this…
Last time I motivated BGP in the context
of inter-domain routing. This time, I’d like to describe a bit about
how BGP operates. 
 A basic requirement of any routing protocol is that it cope with
 routing loops . Recall that under the model of destination-based
forwarding, each router forwards a packet based on the packet’s
destination IP address. The sequence of…
The internet got its name from the fact that it is a “network of
networks”. Various businesses, universities, and government entities
developed networks but had to coordinate in order to communicate
across these. The challenges here are more than just technical; the
reality is that different organizations have different incentives. 
 In the jargon of computer…
There are several types of IETF
RFCs , including strict standards,
looser “best common practices”, as well as purely informational
documents. Today we’ll look at RFC
1180 , a tutorial on
how TCP/IP typically worked as of 1991 (when this document was
written). This RFC is more than 30 years old, so I’ll mention a few
possible updates that come to…
A few weeks ago I went through RFC
791 , which was the
original IPv4 specification. I thought it could be interesting to
follow up on this by looking at RFC
8200 which is the
latest specification for IPv6. 
 The primary rationale for IPv6 is to go beyond the limits of IPv4’s
address space. As you recall, IPv4 addresses are 32 bits, limiting the
protocol to…
Whether it is used for diagnosing connectivity issues or measuring
network latency, ping is an essential tool in any software
engineer’s toolkit. Under the hood, ping relies on
 ICMP 
echo messages. 1 
 But many network administrators disable ICMP, or at least certain
types of ICMP traffic. This is sometimes for security reasons, as ICMP
can be used to map out a…
A network router forwards IP packets from one network to another. In
 destination-based forwarding , the output port for a packet depends
entirely on the destination IP address. To enable this, routers manage
a forwarding table (also known as a forwarding information
base ). 
 Because there are a huge number of possible IP addresses, routers
typically work with ranges of…
Last time we talked about
HTTP/2 header compression. Today we’ll actually look at HTTP/2 in
action, using Wireshark . 
 For what follows, we’ll assume a simple client & server interaction
where the client makes two GET requests over a single, persistent
HTTP/2 connection. At first I tried to do this in Python using
 hyper-h2 but after fussing
around a bit I…
HTTP/1.1 requests and response typically carry a
 header 
which carries metadata about the HTTP message. The header contains
key-value pairs that appear right after the start line of the
message, but before the actual data. For example, the following
message (from the MDN
docs ) has
a header with three entries: 





 POST /users…
Last time we looked
at a HTTP/1.1 request and response using Wireshark. Over the next few
posts I’m building towards a better understanding of
 gRPC . gRPC uses HTTP/2, which departs from
HTTP/1.1 in several ways. Before getting into those changes, let’s
look at how HTTP can be used for secure communication. 
 Transport Layer
Security , or
TLS for short,…
Our recent foray into TCP/IP led us to look at HTTP as a prime example
of an application layer protocol. Today I thought it would be fun to
look at an HTTP request/response interaction with
 Wireshark . Let’s break it down step by
step and see exactly how HTTP/1.1 plays out over TCP. 
 When I run: 





 1 curl -v http://google.com -H 'Connection:…
In the past few posts we have been looking at the syntax and semantics
of TCP. There is still much more to be said on the subject
(e.g. congestion control), but to really understand TCP in action we
need to also consider an application level protocol. Perhaps the most
widely used of these is the Hypertext Transfer
Protocol , which was developed
alongside the World…
TCP provides a reliable stream abstraction on top of the underlying IP
layer. Although an application interacts with TCP as if it were a stream
of individual bytes, a TCP implementation packages a sequence of bytes
together into what is known as a TCP segment . A segment has a TCP
header, for the protocol to operate, and data, from the driving
application. Like those…
While reading the TCP specification in RFC
793 , it struck me how
important diagrammatic reasoning is in understanding such protocols. 
 Broadly speaking, a protocol is a set of rules describing how entities
(e.g. people, machines, processes) interact in a given system. Almost
inevitably these rules depend on whether certain circumstances are
met, and typically the entire…
Last time I wrote about UDP , a simple but unreliable
abstraction over IP. For reliable data transfer, the key protocol is
 TCP . However,
this reliability comes at a cost: TCP is significantly more complicated than UDP. 
 Rather than slog through RFC
793 , we can start by
looking at Python’s
 socket library. This
is just a Pythonic wrapper around…
Next stop in my whirlwind tour of various networking protocols is UDP
(RFC 768) . The spec is
only two pages so this post is going to be brief. 
 Whereas IP operates at the “network layer”, UDP sits at the “transport
layer”. Really, UDP adds just one key feature on top of the
basic IP datagram model: ports . A port lets you distinguish…
Yesterday I wrote about RFC 791 , but I didn’t
mention how errors get handled or reported. 
 Any conforming implementation of Internet Protocol must support its
companion, the Internet Control Message Protocol. Defined in RFC
792 , ICMP provides a
very lightweight mechanism for error reporting. 
 In essence, ICMP defines messages that are sent back to the source…
I’m going to be interviewing some network engineers in the near
future, so now is the time for me to brush up on the basics. Rather
than take the “shortest path” I decided it might be fun to read RFC
791 – and what a classic
this is. 
 Why has IP stood the test of time? My guess is that there are a few
factors. 
 
 As mentioned in the…
It’s been a few years since my last blog post, but I find myself
wanting to write again. Despite my previous attempts at blogging, I
never settled into a regular habit. So I’ve decided to reboot this
blog, with a goal: to write more, and more often. 
 There are really two things I hope to get out of this effort. The
first is to take seriously the idea of
…