Tag: #networking
How to run Redis Sentinel
Redis Sentinel provides high availability for Redis. We start a Redis master, then three Redis Sentinel instances. They discover each other, then we trigger a failover. 2019-01-08
How to make a webserver with netcat (nc)
Use
nc
(netcat) to create a web server that returns custom HTTP responses. 2018-12-31What is HTTP keep-alive? What is HTTP request pipelining?
HTTP keep-alive allows reusing the same TCP connection for multiple requests, avoiding the overhead of opening a new connection. HTTP request pipelining sends multiple requests without waiting for their responses. 2018-03-27
Creating a UDP connection with netcat
nc
can create UDP connections. UDP connections are established when the first data packet is sent, and terminated when the server becomes unreachable. ICMP messages notify the client of an unreachable server. 2018-03-04How does network address translation work?
NAT allows multiple devices in a local network to share a single public IP address. Routers modify IP and port information in network packets, and manage a translation table. 2018-03-02
What does Linux do with a lost TCP connection?
Linux uses exponential backoff to retry dropped TCP connections, with a configurable retry limit. 2018-02-27
What are TCP sequence numbers?
TCP uses sequence numbers to map unordered IP packets to an ordered byte stream. The sequence number field is 32 bits, but wraps around to 0 after reaching the max value. The sender chooses a random “initial sequence number” during the connection handshake. 2018-02-24
Running
tcpdump
on a TCP connection tcpdump
captures network traffic. Capture and analysis of a TCP connection, including the 3-way handshake and message exchange. 2018-02-23How does an IP address get translated to a MAC address?
IP addresses are mapped to MAC addresses using the Address Resolution Protocol (ARP). The OS maintains an ARP cache to store these mappings. 2018-02-11
What is a subnet?
Subnets divide the IP address space hierarchically using bitstring prefixes. We check if an IP address is in a subnet using C. 2018-02-10
How does reverse DNS lookup work?
Reverse DNS lookup maps an IP address to a domain name by querying
PTR
records. The mapping is not always consistent with the forward DNS lookup. 2018-02-09How does
ping
work? ping
uses ICMP, or “Internet Control Message Protocol”, to send “echo request” packets and receive “echo reply” packets. 2018-02-07What is DHCP?
DHCP dynamically assigns IP addresses to hosts, using a client-server protocol over UDP. It involves a sequence of DORA (Discover, Offer, Request, Acknowledge) messages to obtain and configure a network lease. 2018-02-06
DNS resolution procedure
DNS resolution is a recursive procedure involving different record types like A, CNAME, and NS. Resolving a domain name can require multiple DNS queries to different nameservers. 2017-11-25
What is an authoritative DNS server? What is a recursive DNS server?
Authoritative DNS servers provide definitive responses for their domains, while recursive DNS servers consult other servers to serve responses, caching results to reduce load on authorities. 2017-08-20
How can I do DNS lookup in Go?
Using the Go
"net"
package to look up IP addresses for a given domain name, using either the C stdlib or a pure Go DNS resolver. 2017-08-03Redis Pub/Sub under the hood
Examines Redis’s source code to understand how it tracks subscriptions, handles disconnections, and implements pattern subscriptions, highlighting potential pitfalls and attack vectors. 2017-03-01
Monthly review: 2017-02
Focused on learning C, UNIX, and networking fundamentals. To avoid becoming a neckbeard, I’ll keep my projects grounded in real-world applications. March will be dedicated to Vidrio. 2017-03-01
How to write a TCP server with the
pthread
API A TCP server that uses
pthread
to serve multiple clients concurrently, with an “echo” server for each connection. 2017-02-28What are the
domain
and type
arguments to the socket
system call? The
domain
and type
arguments to socket()
describe the protocol family and socket type, respectively. The protocol
argument specifies the actual protocol to use, which may be inferred from the domain
and type
. 2017-02-27How to write a TCP server using the
fork
syscall A TCP server that uses the
fork
system call to create a new child process for each accepted connection, allowing it to handle multiple clients concurrently. 2017-02-25What is
lsof
? lsof
lists open system resources, including pipes, sockets, and yes, files. It shows their type, owner, and location. 2017-02-20How does GeoDNS work?
GeoDNS uses geo-IP to locate clients and connect them to the nearest server, reducing latency. 2017-02-08
FOSDEM: The Challenges and Secrets of the Realtime World
Realtime apps use protocols like HTTP streaming, long polling, WebSocket to enable live updates. Scaling pub/sub requires distributed servers and routing clients to the closest server. 2017-02-04
How does reliability work in
RTCDataChannel
? The
RTCDataChannel
API lets us configure the delivery guarantees, including the ordered
, maxPacketLifeTime
, and maxRetransmits
properties. 2017-01-17How to write a ‘hello world’ serverless WebRTC app
Including setting up the
RTCPeerConnection
, creating a data channel, handling ICE candidates, and generating an offer to be shared with the remote peer. The signaling channel is copy-paste! 2017-01-16What is STUN?
STUN is a protocol that allows clients to discover their public IP address and port, enabling peer-to-peer connections in WebRTC. 2017-01-15
How fast does an IP packet travel?
IP packets travel at ~20% the speed of light, with most time spent in routers rather than on the wire. 2017-01-01
What do DNS datagrams look like?
The structure and contents of a DNS request datagram, including the header, question section, and how to represent it in C. 2016-12-31
What are ‘protocol numbers’ in IP?
An IP packet contains a ‘protocol number’ that identifies the protocol (e.g. TCP, UDP) running over IP. The kernel uses this to determine how to handle the packet. 2016-12-23
What is
htons
in C? htons
and htonl
convert values between host and network byte order, where network order is big-endian. ntohl
and ntohs
are the inverse functions. 2016-12-21What syscalls does a UDP server need?
The syscalls needed for a simple UDP echo server are
socket
, bind
, recvfrom
, sendto
, and close
. 2016-12-19How to write a TCP server with the
kqueue
API Kqueue is a more efficient alternative to
select
for managing multiple TCP connections, providing a publish-subscribe model for tracking events in the kernel. 2016-12-18What syscalls does a TCP server need?
A minimal TCP server in C uses the
socket
, bind
, listen
, accept
, recv
, send
, and close
syscalls to manage connections. 2016-12-14How do I write a UDP server in Go?
A UDP server that listens for packets and prints the received messages. A UDP client that sends “hello” to the server. 2016-11-17
All content copyright James Fisher.