diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-30 09:17:15 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-30 09:17:15 +0300 |
| commit | 4069484ca68ad89ddc720b7fd70cd01922290c60 (patch) | |
| tree | b39fc35eccd923792f28a6cfcf2ae4691c459491 /gemfeed/atom.xml | |
| parent | b0667224747fd95a95ab1442b5c84920cda3f75b (diff) | |
Update content for gemtext
Diffstat (limited to 'gemfeed/atom.xml')
| -rw-r--r-- | gemfeed/atom.xml | 2174 |
1 files changed, 997 insertions, 1177 deletions
diff --git a/gemfeed/atom.xml b/gemfeed/atom.xml index e1157fb0..3b4f21af 100644 --- a/gemfeed/atom.xml +++ b/gemfeed/atom.xml @@ -1,12 +1,1008 @@ <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> - <updated>2026-03-28T00:29:48+02:00</updated> + <updated>2026-03-30T09:16:50+03:00</updated> <title>foo.zone feed</title> <subtitle>To be in the .zone!</subtitle> <link href="gemini://foo.zone/gemfeed/atom.xml" rel="self" /> <link href="gemini://foo.zone/" /> <id>gemini://foo.zone/</id> <entry> + <title>Distributed Systems Simulator - Part 3: Advanced Examples and Protocol API</title> + <link href="gemini://foo.zone/gemfeed/2026-04-02-distributed-systems-simulator-part-3.gmi" /> + <id>gemini://foo.zone/gemfeed/2026-04-02-distributed-systems-simulator-part-3.gmi</id> + <updated>2026-04-02T00:00:00+03:00</updated> + <author> + <name>Paul Buetow aka snonux</name> + <email>paul@dev.buetow.org</email> + </author> + <summary>This is the third and final blog post of the Distributed Systems Simulator series. This part covers advanced simulation examples, the Raft consensus protocol, and the extensible Protocol API.</summary> + <content type="xhtml"> + <div xmlns="http://www.w3.org/1999/xhtml"> + <h1 style='display: inline' id='distributed-systems-simulator---part-3-advanced-examples-and-protocol-api'>Distributed Systems Simulator - Part 3: Advanced Examples and Protocol API</h1><br /> +<br /> +<span class='quote'>Published at 2026-04-02T00:00:00+03:00</span><br /> +<br /> +<span>This is the third and final blog post of the Distributed Systems Simulator series. This part covers advanced simulation examples, the Raft consensus protocol, and the extensible Protocol API.</span><br /> +<br /> +<a class='textlink' href='https://codeberg.org/snonux/ds-sim'>ds-sim on Codeberg (modernized, English-translated version)</a><br /> +<br /> +<span>These are all the posts of this series:</span><br /> +<br /> +<a class='textlink' href='./2026-03-31-distributed-systems-simulator-part-1.html'>2026-03-31 Distributed Systems Simulator - Part 1: Introduction and GUI</a><br /> +<a class='textlink' href='./2026-04-01-distributed-systems-simulator-part-2.html'>2026-04-01 Distributed Systems Simulator - Part 2: Built-in Protocols</a><br /> +<a class='textlink' href='./2026-04-02-distributed-systems-simulator-part-3.html'>2026-04-02 Distributed Systems Simulator - Part 3: Advanced Examples and Protocol API (You are currently reading this)</a><br /> +<br /> +<a href='./distributed-systems-simulator/ds-sim-screenshot.png'><img alt='Screenshot: The Distributed Systems Simulator running a Broadcast protocol simulation with 6 processes. The visualization shows message lines between process bars, with blue indicating delivered messages and green indicating messages still in transit.' title='Screenshot: The Distributed Systems Simulator running a Broadcast protocol simulation with 6 processes. The visualization shows message lines between process bars, with blue indicating delivered messages and green indicating messages still in transit.' src='./distributed-systems-simulator/ds-sim-screenshot.png' /></a><br /> +<br /> +<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br /> +<br /> +<ul> +<li><a href='#distributed-systems-simulator---part-3-advanced-examples-and-protocol-api'>Distributed Systems Simulator - Part 3: Advanced Examples and Protocol API</a></li> +<li>⇢ <a href='#additional-examples'>Additional Examples</a></li> +<li>⇢ ⇢ <a href='#lamport-and-vector-timestamps'>Lamport and Vector Timestamps</a></li> +<li>⇢ ⇢ <a href='#simulating-slow-connections'>Simulating Slow Connections</a></li> +<li>⇢ ⇢ <a href='#raft-consensus-failover'>Raft Consensus Failover</a></li> +<li>⇢ <a href='#protocol-api'>Protocol API</a></li> +<li>⇢ ⇢ <a href='#class-hierarchy'>Class Hierarchy</a></li> +<li>⇢ ⇢ <a href='#implementing-a-custom-protocol'>Implementing a Custom Protocol</a></li> +<li>⇢ ⇢ <a href='#available-api-methods'>Available API Methods</a></li> +<li>⇢ ⇢ <a href='#example-reliable-multicast-implementation'>Example: Reliable Multicast Implementation</a></li> +<li>⇢ <a href='#project-statistics'>Project Statistics</a></li> +</ul><br /> +<h2 style='display: inline' id='additional-examples'>Additional Examples</h2><br /> +<br /> +<h3 style='display: inline' id='lamport-and-vector-timestamps'>Lamport and Vector Timestamps</h3><br /> +<br /> +<a href='./distributed-systems-simulator/lamport-timestamps.png'><img alt='Visualization: Lamport Timestamps displayed on the Berkeley Algorithm simulation. Each event on a process bar shows its Lamport timestamp as a number in parentheses. The timestamps increase monotonically and are updated according to the Lamport clock rules when messages are sent and received between P1, P2, and P3.' title='Visualization: Lamport Timestamps displayed on the Berkeley Algorithm simulation. Each event on a process bar shows its Lamport timestamp as a number in parentheses. The timestamps increase monotonically and are updated according to the Lamport clock rules when messages are sent and received between P1, P2, and P3.' src='./distributed-systems-simulator/lamport-timestamps.png' /></a><br /> +<br /> +<span class='quote'>"For many purposes, it is sufficient that all machines agree on the same time. It is not necessary that this time also agrees with real time, like every hour announced on the radio... For a certain class of algorithms, only the internal consistency of clocks is important." - Andrew Tanenbaum</span><br /> +<br /> +<span>Clocks that provide such a time are also known as logical clocks. Two implementations are realized in the simulator: Lamport timestamps and vector timestamps.</span><br /> +<br /> +<span>After activating the Lamport time switch in expert mode, the current Lamport timestamp appears at every event of a process. Each process has its own Lamport timestamp that is incremented when a message is sent or received. Each message carries the current Lamport time t_l(i) of the sending process i. When another process j receives this message, its Lamport timestamp t_l(j) is recalculated as:</span><br /> +<br /> +<pre> +t_l(j) := 1 + max(t_l(j), t_l(i)) +</pre> +<br /> +<span>The larger Lamport time of the sender and receiver process is used and then incremented by 1. After the Berkeley simulation shown here, P1 has Lamport timestamp 16, P2 has 14, and P3 has 15.</span><br /> +<br /> +<a href='./distributed-systems-simulator/vector-timestamps.png'><img alt='Visualization: Vector Timestamps displayed on the same Berkeley Algorithm simulation. Each event shows its vector timestamp as a tuple (v1,v2,v3) representing the known state of all three processes. The tuples grow as processes communicate and merge their knowledge of each other's progress.' title='Visualization: Vector Timestamps displayed on the same Berkeley Algorithm simulation. Each event shows its vector timestamp as a tuple (v1,v2,v3) representing the known state of all three processes. The tuples grow as processes communicate and merge their knowledge of each other's progress.' src='./distributed-systems-simulator/vector-timestamps.png' /></a><br /> +<br /> +<span>With the active vector time switch, all vector timestamps are displayed. Like the Lamport timestamp, each message includes the current vector timestamp of the sending process. With n participating processes, the vector timestamp v has size n. Each participating process i has its own index, accessible via v(i). When v is the vector timestamp of the receiving process j and w is the vector timestamp of the sending process, the new local vector timestamp of process j is calculated as follows:</span><br /> +<br /> +<pre> +for (i := 0; i < n; i++) { + if (i = j) { + v(i)++; + } else if (v(i) < w(i)) { + v(i) := w(i); + } +} +</pre> +<br /> +<span>By default, the vector timestamp is only incremented when a message is sent or received. In both cases, the sender and receiver each increment their own index in the vector timestamp by 1. Upon receiving a message, the local vector timestamp is then compared with the sender's, and the larger value is taken for all indices.</span><br /> +<br /> +<span>After the simulation, P1 has vector timestamp (8,10,6), P2 has (6,10,6), and P3 has (6,10,8).</span><br /> +<br /> +<span>The simulation settings include boolean variables "Lamport times affect all events" and "Vector times affect all events" (both default to false). When set to true, all events (not just message send/receive) will update the timestamps.</span><br /> +<br /> +<h3 style='display: inline' id='simulating-slow-connections'>Simulating Slow Connections</h3><br /> +<br /> +<a href='./distributed-systems-simulator/slow-connection.png'><img alt='Visualization: Slow connection simulation comparing Internal Synchronization (P1) and Christian's Method (P3) with P2 as server. P3 has high transmission times (2000-8000ms) simulating a slow network connection. P1 synchronizes to 21446ms (error: -1446ms) while P3 only reaches 16557ms (error: -3443ms), showing how slow connections degrade synchronization quality.' title='Visualization: Slow connection simulation comparing Internal Synchronization (P1) and Christian's Method (P3) with P2 as server. P3 has high transmission times (2000-8000ms) simulating a slow network connection. P1 synchronizes to 21446ms (error: -1446ms) while P3 only reaches 16557ms (error: -3443ms), showing how slow connections degrade synchronization quality.' src='./distributed-systems-simulator/slow-connection.png' /></a><br /> +<br /> +<span>The simulator can also simulate slow connections to a specific process. This example revisits the comparison of Internal Synchronization (P1) and Christian's Method (P3), with P2 serving both. In this scenario, P3 has a poor network connection, so messages to and from P3 always require a longer transmission time.</span><br /> +<br /> +<span>P3's minimum transmission time is set to 2000ms and maximum to 8000ms, while P1 and P2 keep the defaults (500ms/2000ms). The simulation duration is 20000ms. With the "Average transmission times" setting enabled, the effective transmission time for messages involving P3 is:</span><br /> +<br /> +<pre> +1/2 * (rand(500,2000) + rand(2000,8000)) = 1/2 * rand(2500,10000) = rand(1250,5000)ms +</pre> +<br /> +<span>Because P3 starts a new request before receiving the answer to its previous one, and because it always associates server responses with its most recently sent request, its RTT calculations become incorrect on each round, and its local time is poorly synchronized. P1 synchronizes to 21446ms (error: -1446ms) while P3 only reaches 16557ms (error: -3443ms).</span><br /> +<br /> +<h3 style='display: inline' id='raft-consensus-failover'>Raft Consensus Failover</h3><br /> +<br /> +<a href='./distributed-systems-simulator/raft-consensus-failover.png'><img alt='Screenshot: A 60-second Raft simulation with three processes. P1 starts as the initial leader, crashes at 3500ms, later recovers, P2 wins the reelection and remains leader, and P3 crashes later. The blue and red message lines show the continuing heartbeat and acknowledgment traffic during and after failover.' title='Screenshot: A 60-second Raft simulation with three processes. P1 starts as the initial leader, crashes at 3500ms, later recovers, P2 wins the reelection and remains leader, and P3 crashes later. The blue and red message lines show the continuing heartbeat and acknowledgment traffic during and after failover.' src='./distributed-systems-simulator/raft-consensus-failover.png' /></a><br /> +<br /> +<span>While modernizing ds-sim, I also added a simplified Raft Consensus example. The simulation is intentionally small: three processes, one initial leader, one crash, a clean reelection, a recovery of the old leader, and then another crash later in the run. This makes it possible to see the most important Raft transitions without being overwhelmed by cluster size.</span><br /> +<br /> +<span>The event log tells a very readable story. At <span class='inlinecode'>0ms</span>, <span class='inlinecode'>P1</span> starts as the initial leader in <span class='inlinecode'>term 0</span>. It immediately sends a heartbeat and an <span class='inlinecode'>appendEntry</span> message carrying the log entry <span class='inlinecode'>cmd1</span>. <span class='inlinecode'>P2</span> joins at <span class='inlinecode'>100ms</span>, <span class='inlinecode'>P3</span> at <span class='inlinecode'>1700ms</span>, and both acknowledge the leader's traffic. At that point the cluster is healthy: one leader, two followers, successful heartbeats, and successful log replication.</span><br /> +<br /> +<span>At <span class='inlinecode'>3500ms</span>, <span class='inlinecode'>P1</span> crashes. The followers still process the last in-flight messages, but once the election timeout expires, <span class='inlinecode'>P2</span> becomes a candidate and sends a <span class='inlinecode'>voteRequest</span> for <span class='inlinecode'>term 1</span>. <span class='inlinecode'>P3</span> grants that vote, and at <span class='inlinecode'>9395ms</span> the log records the decisive line:</span><br /> +<br /> +<pre> +009395ms: PID: 2; ... Leader elected by majority vote: process 2 (term 1) +</pre> +<br /> +<span>That transition is followed immediately by new heartbeats and a new <span class='inlinecode'>appendEntry</span>, which is exactly what you want to see in a Raft simulation: leadership is not just declared, it is exercised.</span><br /> +<br /> +<span>At <span class='inlinecode'>12002ms</span>, the old leader <span class='inlinecode'>P1</span> recovers. Importantly, it does not try to reclaim control. Instead, it receives heartbeats from <span class='inlinecode'>P2</span> and answers with <span class='inlinecode'>heartbeatAck</span> messages, rejoining the cluster as a follower. That is one of the most useful teaching moments in the log, because it makes the term-based leadership model concrete: the recovered node does not become leader again just because it used to be one.</span><br /> +<br /> +<span>At <span class='inlinecode'>20000ms</span>, <span class='inlinecode'>P3</span> crashes. The cluster continues running with <span class='inlinecode'>P2</span> as leader and <span class='inlinecode'>P1</span> as follower for the rest of the 60-second simulation. The log remains dominated by periodic heartbeats from <span class='inlinecode'>P2</span> and acknowledgments from <span class='inlinecode'>P1</span>, showing that the system stays stable even after a second failure.</span><br /> +<br /> +<span>This single scenario demonstrates several core Raft properties in one replay:</span><br /> +<br /> +<ul> +<li>Stable startup leadership</li> +<li>Heartbeats and follower acknowledgments</li> +<li>Log replication</li> +<li>Leader failure detection</li> +<li>Majority-based reelection</li> +<li>Safe reintegration of a recovered former leader</li> +<li>Continued service after a later follower crash</li> +</ul><br /> +<span>It is also a good example of why a simulator is useful for distributed systems. In a real production system, reconstructing this sort of sequence would require stitching together logs from multiple nodes. Here, the message flow, the crashes, the recoveries, and the Lamport/vector timestamps are all visible in one place.</span><br /> +<br /> +<h2 style='display: inline' id='protocol-api'>Protocol API</h2><br /> +<br /> +<span>The simulator was designed from the ground up to be extensible. Users can implement their own protocols in Java by extending the <span class='inlinecode'>VSAbstractProtocol</span> base class. Each protocol has its own class in the <span class='inlinecode'>protocols.implementations</span> package.</span><br /> +<br /> +<h3 style='display: inline' id='class-hierarchy'>Class Hierarchy</h3><br /> +<br /> +<pre> +VSAbstractEvent + +-- VSAbstractProtocol (base class for all protocols) + +-- VSDummyProtocol + +-- VSPingPongProtocol + +-- VSBroadcastProtocol + +-- VSInternalTimeSyncProtocol + +-- VSExternalTimeSyncProtocol + +-- VSBerkeleyTimeProtocol + +-- VSOnePhaseCommitProtocol + +-- VSTwoPhaseCommitProtocol + +-- VSBasicMulticastProtocol + +-- VSReliableMulticastProtocol +</pre> +<br /> +<h3 style='display: inline' id='implementing-a-custom-protocol'>Implementing a Custom Protocol</h3><br /> +<br /> +<span>Each protocol class must implement the following methods:</span><br /> +<br /> +<ul> +<li>A public constructor: Must specify whether the client or the server initiates requests, using <span class='inlinecode'>VSAbstractProtocol.HAS_ON_CLIENT_START</span> or <span class='inlinecode'>VSAbstractProtocol.HAS_ON_SERVER_START</span>.</li> +<li><span class='inlinecode'>onClientInit()</span> / <span class='inlinecode'>onServerInit()</span>: Called once before the protocol is first used. Used to initialize protocol variables and attributes via the VSPrefs methods (e.g. <span class='inlinecode'>initVector</span>, <span class='inlinecode'>initLong</span>). Variables initialized this way appear in the process editor and can be configured by the user.</li> +<li><span class='inlinecode'>onClientReset()</span> / <span class='inlinecode'>onServerReset()</span>: Called each time the simulation is reset.</li> +<li><span class='inlinecode'>onClientStart()</span> / <span class='inlinecode'>onServerStart()</span>: Called when the client/server initiates a request. Typically creates and sends a <span class='inlinecode'>VSMessage</span> object.</li> +<li><span class='inlinecode'>onClientRecv(VSMessage)</span> / <span class='inlinecode'>onServerRecv(VSMessage)</span>: Called when a message arrives.</li> +<li><span class='inlinecode'>onClientSchedule()</span> / <span class='inlinecode'>onServerSchedule()</span>: Called when a scheduled alarm fires.</li> +<li><span class='inlinecode'>toString()</span>: Optional. Customizes log output for this protocol.</li> +</ul><br /> +<h3 style='display: inline' id='available-api-methods'>Available API Methods</h3><br /> +<br /> +<span>Methods inherited from <span class='inlinecode'>VSAbstractProtocol</span>:</span><br /> +<br /> +<ul> +<li><span class='inlinecode'>sendMessage(VSMessage message)</span>: Sends a protocol message (automatically updates Lamport and Vector timestamps)</li> +<li><span class='inlinecode'>hasOnServerStart()</span>: Whether the server or client initiates requests</li> +<li><span class='inlinecode'>isServer()</span> / <span class='inlinecode'>isClient()</span>: Whether the current process has the protocol activated as server/client</li> +<li><span class='inlinecode'>scheduleAt(long time)</span>: Creates an alarm that fires at the given local process time, triggering <span class='inlinecode'>onClientSchedule()</span> or <span class='inlinecode'>onServerSchedule()</span></li> +<li><span class='inlinecode'>removeSchedules()</span>: Cancels all pending alarms in the current context</li> +<li><span class='inlinecode'>getNumProcesses()</span>: Returns the total number of processes in the simulation</li> +</ul><br /> +<span>Process methods available via the inherited <span class='inlinecode'>process</span> attribute:</span><br /> +<br /> +<ul> +<li><span class='inlinecode'>getTime()</span> / <span class='inlinecode'>setTime(long)</span>: Get/set the local process time</li> +<li><span class='inlinecode'>getGlobalTime()</span>: Get the current global simulation time</li> +<li><span class='inlinecode'>getClockVariance()</span> / <span class='inlinecode'>setClockVariance(float)</span>: Get/set the clock drift</li> +<li><span class='inlinecode'>getLamportTime()</span> / <span class='inlinecode'>setLamportTime(long)</span>: Get/set the Lamport timestamp</li> +<li><span class='inlinecode'>getVectorTime()</span> / <span class='inlinecode'>updateVectorTime(VSVectorTime)</span>: Get/update the vector timestamp</li> +<li><span class='inlinecode'>getProcessID()</span>: Get the process PID</li> +<li><span class='inlinecode'>isCrashed()</span> / <span class='inlinecode'>isCrashed(boolean)</span>: Check or set crash state</li> +<li><span class='inlinecode'>getRandomPercentage()</span>: Get a random value between 0 and 100</li> +</ul><br /> +<span>Message methods (<span class='inlinecode'>VSMessage</span>):</span><br /> +<br /> +<ul> +<li><span class='inlinecode'>new VSMessage()</span>: Create a new message</li> +<li><span class='inlinecode'>getMessageID()</span>: Get the message NID</li> +<li><span class='inlinecode'>setBoolean(key, value)</span> / <span class='inlinecode'>getBoolean(key)</span>: Set/get boolean data</li> +<li><span class='inlinecode'>setInteger(key, value)</span> / <span class='inlinecode'>getInteger(key)</span>: Set/get integer data</li> +<li><span class='inlinecode'>setLong(key, value)</span> / <span class='inlinecode'>getLong(key)</span>: Set/get long data</li> +<li><span class='inlinecode'>setString(key, value)</span> / <span class='inlinecode'>getString(key)</span>: Set/get string data</li> +<li><span class='inlinecode'>getSendingProcess()</span>: Get a reference to the sending process</li> +<li><span class='inlinecode'>isServerMessage()</span>: Whether it's a server or client message</li> +</ul><br /> +<h3 style='display: inline' id='example-reliable-multicast-implementation'>Example: Reliable Multicast Implementation</h3><br /> +<br /> +<span>Here is a condensed example showing key parts of the Reliable Multicast Protocol implementation:</span><br /> +<br /> +<!-- Generator: GNU source-highlight 3.1.9 +by Lorenzo Bettini +http://www.lorenzobettini.it +http://www.gnu.org/software/src-highlite --> +<pre><b><u><font color="#000000">public</font></u></b> <b><u><font color="#000000">class</font></u></b> VSReliableMulticastProtocol <b><u><font color="#000000">extends</font></u></b> VSAbstractProtocol { + <b><u><font color="#000000">public</font></u></b> VSReliableMulticastProtocol() { + <i><font color="silver">// The client initiates requests</font></i> + <b><u><font color="#000000">super</font></u></b>(VSAbstractProtocol.HAS_ON_CLIENT_START); + <b><u><font color="#000000">super</font></u></b>.setClassname(<b><u><font color="#000000">super</font></u></b>.getClass().toString()); + } + + <b><u><font color="#000000">private</font></u></b> ArrayList<Integer> pids; + + <i><font color="silver">// Initialize protocol variables (editable in the process editor)</font></i> + <b><u><font color="#000000">public</font></u></b> <b><font color="#000000">void</font></b> onClientInit() { + Vector<Integer> vec = <b><u><font color="#000000">new</font></u></b> Vector<Integer>(); + vec.add(<font color="#000000">1</font>); vec.add(<font color="#000000">3</font>); + <b><u><font color="#000000">super</font></u></b>.initVector(<font color="#808080">"pids"</font>, vec, <font color="#808080">"PIDs of participating processes"</font>); + <b><u><font color="#000000">super</font></u></b>.initLong(<font color="#808080">"timeout"</font>, <font color="#000000">2500</font>, <font color="#808080">"Time until resend"</font>, <font color="#808080">"ms"</font>); + } + + <i><font color="silver">// Send multicast to all servers that haven't ACKed yet</font></i> + <b><u><font color="#000000">public</font></u></b> <b><font color="#000000">void</font></b> onClientStart() { + <b><u><font color="#000000">if</font></u></b> (pids.size() != <font color="#000000">0</font>) { + <b><font color="#000000">long</font></b> timeout = <b><u><font color="#000000">super</font></u></b>.getLong(<font color="#808080">"timeout"</font>) + process.getTime(); + <b><u><font color="#000000">super</font></u></b>.scheduleAt(timeout); + VSMessage message = <b><u><font color="#000000">new</font></u></b> VSMessage(); + message.setBoolean(<font color="#808080">"isMulticast"</font>, <b><u><font color="#000000">true</font></u></b>); + <b><u><font color="#000000">super</font></u></b>.sendMessage(message); + } + } + + <i><font color="silver">// Handle ACK from a server</font></i> + <b><u><font color="#000000">public</font></u></b> <b><font color="#000000">void</font></b> onClientRecv(VSMessage recvMessage) { + <b><u><font color="#000000">if</font></u></b> (pids.size() != <font color="#000000">0</font> && recvMessage.getBoolean(<font color="#808080">"isAck"</font>)) { + Integer pid = recvMessage.getIntegerObj(<font color="#808080">"pid"</font>); + <b><u><font color="#000000">if</font></u></b> (pids.contains(pid)) + pids.remove(pid); + <b><u><font color="#000000">super</font></u></b>.log(<font color="#808080">"ACK from Process "</font> + pid + <font color="#808080">" received!"</font>); + <b><u><font color="#000000">if</font></u></b> (pids.size() == <font color="#000000">0</font>) { + <b><u><font color="#000000">super</font></u></b>.log(<font color="#808080">"ACKs from all processes received!"</font>); + <b><u><font color="#000000">super</font></u></b>.removeSchedules(); + } + } + } + + <i><font color="silver">// Retry on timeout</font></i> + <b><u><font color="#000000">public</font></u></b> <b><font color="#000000">void</font></b> onClientSchedule() { onClientStart(); } +} +</pre> +<br /> +<h2 style='display: inline' id='project-statistics'>Project Statistics</h2><br /> +<br /> +<span>The original VS-Sim project (August 2008) was written in Java 6 and consisted of:</span><br /> +<br /> +<ul> +<li>61 source files across 12 Java packages</li> +<li>Approximately 15,710 lines of code</li> +<li>2.2 MB of generated Javadoc documentation</li> +<li>142 KB compiled JAR file</li> +<li>10 built-in protocols</li> +<li>163 configurable settings</li> +</ul><br /> +<span>The modernized successor ds-sim (version 1.1.0) has been updated to Java 21 and translated to English:</span><br /> +<br /> +<ul> +<li>146 source files (117 main + 29 test) across 19 Java packages</li> +<li>Approximately 27,900 lines of code (22,400 main + 5,500 test)</li> +<li>12 built-in protocols</li> +<li>208 unit tests</li> +<li>269 configurable settings</li> +</ul><br /> +<a class='textlink' href='https://codeberg.org/snonux/ds-sim'>ds-sim source code on Codeberg</a><br /> +<a class='textlink' href='https://codeberg.org/snonux/vs-sim'>vs-sim source code on Codeberg (original German version, 2008)</a><br /> +<br /> +<span>Other related posts are:</span><br /> +<br /> +<a class='textlink' href='./2026-03-01-loadbars-0.13.0-released.html'>2026-03-01 Loadbars 0.13.0 released</a><br /> +<a class='textlink' href='./2022-12-24-ultrarelearning-java-my-takeaways.html'>2022-12-24 (Re)learning Java - My takeaways</a><br /> +<a class='textlink' href='./2022-03-06-the-release-of-dtail-4.0.0.html'>2022-03-06 The release of DTail 4.0.0</a><br /> +<a class='textlink' href='./2016-11-20-object-oriented-programming-with-ansi-c.html'>2016-11-20 Object oriented programming with ANSI C</a><br /> +<br /> +<span>E-Mail your comments to <span class='inlinecode'>paul@nospam.buetow.org</span></span><br /> +<br /> +<a class='textlink' href='../'>Back to the main site</a><br /> + </div> + </content> + </entry> + <entry> + <title>Distributed Systems Simulator - Part 2: Built-in Protocols</title> + <link href="gemini://foo.zone/gemfeed/2026-04-01-distributed-systems-simulator-part-2.gmi" /> + <id>gemini://foo.zone/gemfeed/2026-04-01-distributed-systems-simulator-part-2.gmi</id> + <updated>2026-04-01T00:00:00+03:00</updated> + <author> + <name>Paul Buetow aka snonux</name> + <email>paul@dev.buetow.org</email> + </author> + <summary>This is the second blog post of the Distributed Systems Simulator series. This part covers all 10 built-in protocols with examples.</summary> + <content type="xhtml"> + <div xmlns="http://www.w3.org/1999/xhtml"> + <h1 style='display: inline' id='distributed-systems-simulator---part-2-built-in-protocols'>Distributed Systems Simulator - Part 2: Built-in Protocols</h1><br /> +<br /> +<span class='quote'>Published at 2026-04-01T00:00:00+03:00</span><br /> +<br /> +<span>This is the second blog post of the Distributed Systems Simulator series. This part covers all 10 built-in protocols with examples.</span><br /> +<br /> +<a class='textlink' href='https://codeberg.org/snonux/ds-sim'>ds-sim on Codeberg (modernized, English-translated version)</a><br /> +<br /> +<span>These are all the posts of this series:</span><br /> +<br /> +<a class='textlink' href='./2026-03-31-distributed-systems-simulator-part-1.html'>2026-03-31 Distributed Systems Simulator - Part 1: Introduction and GUI</a><br /> +<a class='textlink' href='./2026-04-01-distributed-systems-simulator-part-2.html'>2026-04-01 Distributed Systems Simulator - Part 2: Built-in Protocols (You are currently reading this)</a><br /> +<a class='textlink' href='./2026-04-02-distributed-systems-simulator-part-3.html'>2026-04-02 Distributed Systems Simulator - Part 3: Advanced Examples and Protocol API</a><br /> +<br /> +<a href='./distributed-systems-simulator/ds-sim-screenshot.png'><img alt='Screenshot: The Distributed Systems Simulator running a Broadcast protocol simulation with 6 processes. The visualization shows message lines between process bars, with blue indicating delivered messages and green indicating messages still in transit.' title='Screenshot: The Distributed Systems Simulator running a Broadcast protocol simulation with 6 processes. The visualization shows message lines between process bars, with blue indicating delivered messages and green indicating messages still in transit.' src='./distributed-systems-simulator/ds-sim-screenshot.png' /></a><br /> +<br /> +<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br /> +<br /> +<ul> +<li><a href='#distributed-systems-simulator---part-2-built-in-protocols'>Distributed Systems Simulator - Part 2: Built-in Protocols</a></li> +<li>⇢ <a href='#protocols-and-examples'>Protocols and Examples</a></li> +<li>⇢ ⇢ <a href='#dummy-protocol'>Dummy Protocol</a></li> +<li>⇢ ⇢ <a href='#ping-pong-protocol'>Ping-Pong Protocol</a></li> +<li>⇢ ⇢ <a href='#broadcast-protocol'>Broadcast Protocol</a></li> +<li>⇢ ⇢ <a href='#internal-synchronization-protocol'>Internal Synchronization Protocol</a></li> +<li>⇢ ⇢ <a href='#christian-s-method-external-synchronization'>Christian's Method (External Synchronization)</a></li> +<li>⇢ ⇢ <a href='#berkeley-algorithm'>Berkeley Algorithm</a></li> +<li>⇢ ⇢ <a href='#one-phase-commit-protocol'>One-Phase Commit Protocol</a></li> +<li>⇢ ⇢ <a href='#two-phase-commit-protocol'>Two-Phase Commit Protocol</a></li> +<li>⇢ ⇢ <a href='#basic-multicast-protocol'>Basic Multicast Protocol</a></li> +<li>⇢ ⇢ <a href='#reliable-multicast-protocol'>Reliable Multicast Protocol</a></li> +</ul><br /> +<h2 style='display: inline' id='protocols-and-examples'>Protocols and Examples</h2><br /> +<br /> +<span>The simulator comes with 10 built-in protocols. As described earlier, protocols are distinguished between server-side and client-side. Servers can respond to client messages, and clients can respond to server messages. Each process can support any number of protocols on both the client and server side. Users can also implement their own protocols using the simulator's Protocol API (see the Protocol API section).</span><br /> +<br /> +<span>The program directory contains a <span class='inlinecode'>saved-simulations</span> folder with example simulations for each protocol as serialized <span class='inlinecode'>.dat</span> files.</span><br /> +<br /> +<h3 style='display: inline' id='dummy-protocol'>Dummy Protocol</h3><br /> +<br /> +<span>The Dummy Protocol serves only as a template for creating custom protocols. When using the Dummy Protocol, only log messages are output when events occur. No further actions are performed.</span><br /> +<br /> +<h3 style='display: inline' id='ping-pong-protocol'>Ping-Pong Protocol</h3><br /> +<br /> +<a href='./distributed-systems-simulator/ping-pong.png'><img alt='Visualization: The Ping-Pong Protocol showing two processes (P1 and P2) exchanging messages in a continuous back-and-forth pattern. Blue lines represent delivered messages bouncing between the process bars over a 15-second simulation.' title='Visualization: The Ping-Pong Protocol showing two processes (P1 and P2) exchanging messages in a continuous back-and-forth pattern. Blue lines represent delivered messages bouncing between the process bars over a 15-second simulation.' src='./distributed-systems-simulator/ping-pong.png' /></a><br /> +<br /> +<span>In the Ping-Pong Protocol, two processes -- Client P1 and Server P2 -- constantly send messages back and forth. The Ping-Pong client starts the first request, to which the server responds to the client. The client then responds again, and so on. Each message includes a counter that is incremented at each station and logged in the log window.</span><br /> +<br /> +<pre> +Programmed Ping-Pong Events: + +| Time (ms) | PID | Event | +|-----------|-----|--------------------------------| +| 0 | 1 | Ping-Pong Client activate | +| 0 | 2 | Ping-Pong Server activate | +| 0 | 1 | Ping-Pong Client request start | +</pre> +<br /> +<span>It is important that Process 1 activates its Ping-Pong client before starting a Ping-Pong client request. Before a process can start a request, it must have the corresponding protocol activated. This also applies to all other protocols.</span><br /> +<br /> +<span>**Ping-Pong Storm Variant**</span><br /> +<br /> +<a href='./distributed-systems-simulator/ping-pong-storm.png'><img alt='Visualization: The Ping-Pong Storm variant with three processes. P1 is the client, P2 and P3 are both servers. The visualization shows an exponentially growing number of messages as each client message generates two server responses, creating a dense web of blue and green message lines.' title='Visualization: The Ping-Pong Storm variant with three processes. P1 is the client, P2 and P3 are both servers. The visualization shows an exponentially growing number of messages as each client message generates two server responses, creating a dense web of blue and green message lines.' src='./distributed-systems-simulator/ping-pong-storm.png' /></a><br /> +<br /> +<span>By adding a third process P3 as an additional Ping-Pong server, a Ping-Pong "Storm" can be realized. Since every client message now receives two server responses, the number of messages doubles with each round, creating an exponential message flood.</span><br /> +<br /> +<pre> +Programmed Ping-Pong Storm Events: + +| Time (ms) | PID | Event | +|-----------|-----|--------------------------------| +| 0 | 1 | Ping-Pong Client activate | +| 0 | 2 | Ping-Pong Server activate | +| 0 | 3 | Ping-Pong Server activate | +| 0 | 1 | Ping-Pong Client request start | +</pre> +<br /> +<h3 style='display: inline' id='broadcast-protocol'>Broadcast Protocol</h3><br /> +<br /> +<a href='./distributed-systems-simulator/broadcast.png'><img alt='Visualization: The Broadcast Protocol with 6 processes (P1-P6). Dense crossing message lines show how a broadcast from P1 propagates to all processes, with each process re-broadcasting to others. Blue lines indicate delivered messages, green lines indicate messages still in transit.' title='Visualization: The Broadcast Protocol with 6 processes (P1-P6). Dense crossing message lines show how a broadcast from P1 propagates to all processes, with each process re-broadcasting to others. Blue lines indicate delivered messages, green lines indicate messages still in transit.' src='./distributed-systems-simulator/broadcast.png' /></a><br /> +<br /> +<span>The Broadcast Protocol behaves similarly to the Ping-Pong Protocol. The difference is that the protocol tracks -- using a unique Broadcast ID -- which messages have already been sent. Each process re-broadcasts all received messages to others, provided it has not already sent them.</span><br /> +<br /> +<span>In this case, no distinction is made between client and server, so that the same action is performed when a message arrives at either side. This makes it possible, using multiple processes, to create a broadcast. P1 is the client and starts a request at 0ms and 2500ms. The simulation duration is exactly 5000ms. Since a client can only receive server messages and a server can only receive client messages, every process in this simulation is both server and client.</span><br /> +<br /> +<pre> +Programmed Broadcast Events: + +| Time (ms) | PID | Event | +|-----------|-----|----------------------------------| +| 0 | 1-6 | Broadcast Client activate | +| 0 | 1-6 | Broadcast Server activate | +| 0 | 1 | Broadcast Client request start | +| 2500 | 1 | Broadcast Client request start | +</pre> +<br /> +<h3 style='display: inline' id='internal-synchronization-protocol'>Internal Synchronization Protocol</h3><br /> +<br /> +<a href='./distributed-systems-simulator/int-sync.png'><img alt='Visualization: Internal Synchronization with 2 processes. P1 (client, clock drift 0.1) shows a faster-running clock reaching 15976ms by simulation end. The blue message lines show P1 periodically synchronizing with P2 (server, no drift), with the time corrections visible as slight adjustments in P1's timeline.' title='Visualization: Internal Synchronization with 2 processes. P1 (client, clock drift 0.1) shows a faster-running clock reaching 15976ms by simulation end. The blue message lines show P1 periodically synchronizing with P2 (server, no drift), with the time corrections visible as slight adjustments in P1's timeline.' src='./distributed-systems-simulator/int-sync.png' /></a><br /> +<br /> +<span>The Internal Synchronization Protocol is used for synchronizing the local process time, which can be applied when a process time is running incorrectly due to clock drift. When the client wants to synchronize its (incorrect) local process time t_c with a server, it sends a client request. The server responds with its own local process time t_s, allowing the client to calculate a new, more accurate time for itself.</span><br /> +<br /> +<span>After receiving the server response, the client P1 calculates its new local process time as:</span><br /> +<br /> +<pre> +t_c := t_s + 1/2 * (t'_min + t'_max) +</pre> +<br /> +<span>This synchronizes P1's local time with an error of less than 1/2 * (t'_max - t'_min), where t'_min and t'_max are the assumed minimum and maximum transmission times configured in the protocol settings.</span><br /> +<br /> +<span>In the example, the client process has a clock drift of 0.1 and the server has 0.0. The client starts a request at local process times 0ms, 5000ms, and 10000ms. By simulation end, P1's time is synchronized to 15976ms (an error of -976ms from the global 15000ms).</span><br /> +<br /> +<pre> +Programmed Internal Sync Events: + +| Time (ms) | PID | Event | +|-----------|-----|------------------------------------| +| 0 | 1 | Internal Sync Client activate | +| 0 | 2 | Internal Sync Server activate | +| 0 | 1 | Internal Sync Client request start | +| 5000 | 1 | Internal Sync Client request start | +| 10000 | 1 | Internal Sync Client request start | +</pre> +<br /> +<span>Protocol variables (client-side):</span><br /> +<br /> +<ul> +<li>Min. transmission time (Long: 500): The assumed t'_min in milliseconds</li> +<li>Max. transmission time (Long: 2000): The assumed t'_max in milliseconds</li> +</ul><br /> +<span>These can differ from the actual message transmission times t_min and t_max, allowing simulation of scenarios where the protocol is misconfigured and large synchronization errors occur.</span><br /> +<br /> +<h3 style='display: inline' id='christian-s-method-external-synchronization'>Christian's Method (External Synchronization)</h3><br /> +<br /> +<a href='./distributed-systems-simulator/christians.png'><img alt='Visualization: Comparison of Internal Synchronization (P1) and Christian's Method (P3) with P2 as shared server. Both P1 and P3 have clock drift 0.1. The visualization shows P1 synchronized to 14567ms (error: -433ms) while P3 synchronized to 15539ms (error: -539ms), demonstrating the different accuracy of the two methods.' title='Visualization: Comparison of Internal Synchronization (P1) and Christian's Method (P3) with P2 as shared server. Both P1 and P3 have clock drift 0.1. The visualization shows P1 synchronized to 14567ms (error: -433ms) while P3 synchronized to 15539ms (error: -539ms), demonstrating the different accuracy of the two methods.' src='./distributed-systems-simulator/christians.png' /></a><br /> +<br /> +<span>Christian's Method uses the RTT (Round Trip Time) to approximate the transmission time of individual messages. When the client wants to synchronize its local time t_c with a server, it sends a request and measures the RTT t_rtt until the server response arrives. The server response contains the local process time t_s from the moment the server sent the response. The client then calculates its new local time as:</span><br /> +<br /> +<pre> +t_c := t_s + 1/2 * t_rtt +</pre> +<br /> +<span>The accuracy is +/- (1/2 * t_rtt - u_min) where u_min is a lower bound for message transmission time.</span><br /> +<br /> +<span>The visualization compares both synchronization methods side by side: P1 uses Internal Synchronization and P3 uses Christian's Method, with P2 serving both. Both P1 and P3 have clock drift 0.1. In this particular run, Internal Synchronization achieved a better result (-433ms error vs. -539ms), though results vary between runs due to random transmission times.</span><br /> +<br /> +<pre> +Programmed Comparison Events: + +| Time (ms) | PID | Event | +|-----------|-----|--------------------------------------| +| 0 | 1 | Internal Sync Client activate | +| 0 | 1 | Internal Sync Client request start | +| 0 | 2 | Christian's Server activate | +| 0 | 2 | Internal Sync Server activate | +| 0 | 3 | Christian's Client activate | +| 0 | 3 | Christian's Client request start | +| 5000 | 1 | Internal Sync Client request start | +| 5000 | 3 | Christian's Client request start | +| 10000 | 1 | Internal Sync Client request start | +| 10000 | 3 | Christian's Client request start | +</pre> +<br /> +<h3 style='display: inline' id='berkeley-algorithm'>Berkeley Algorithm</h3><br /> +<br /> +<a href='./distributed-systems-simulator/berkeley.png'><img alt='Visualization: The Berkeley Algorithm with 3 processes. P2 is the server (coordinator) sending time requests to clients P1 and P3. After collecting responses, P2 calculates correction values and sends them back. Final times show P1=16823ms, P2=14434ms, P3=13892ms -- all brought closer together through averaging.' title='Visualization: The Berkeley Algorithm with 3 processes. P2 is the server (coordinator) sending time requests to clients P1 and P3. After collecting responses, P2 calculates correction values and sends them back. Final times show P1=16823ms, P2=14434ms, P3=13892ms -- all brought closer together through averaging.' src='./distributed-systems-simulator/berkeley.png' /></a><br /> +<br /> +<span>The Berkeley Algorithm is another method for synchronizing local clocks. This is the first protocol where the server initiates the requests. The server acts as a coordinator. The client processes are passive and must wait until a server request arrives. The server must know which client processes participate in the protocol, which is configured in the server's protocol settings.</span><br /> +<br /> +<span>When the server wants to synchronize its local time t_s and the process times t_i of the clients (i = 1,...,n), it sends a server request. n is the number of participating clients. The clients then send their local process times back to the server. The server measures the RTTs r_i for all client responses.</span><br /> +<br /> +<span>After all responses are received, the server sets its own time to the average t_avg of all known process times (including its own). The transmission time of a client response is estimated as half the RTT:</span><br /> +<br /> +<pre> +t_avg := 1/(n+1) * (t_s + SUM(r_i/2 + t_i)) +t_s := t_avg +</pre> +<br /> +<span>The server then calculates a correction value k_i := t_avg - t_i for each client and sends it back. Each client sets its new time to t'_i := t'_i + k_i.</span><br /> +<br /> +<pre> +Programmed Berkeley Events: + +| Time (ms) | PID | Event | +|-----------|-----|-----------------------------------| +| 0 | 1 | Berkeley Client activate | +| 0 | 2 | Berkeley Server activate | +| 0 | 3 | Berkeley Client activate | +| 0 | 2 | Berkeley Server request start | +| 7500 | 2 | Berkeley Server request start | +</pre> +<br /> +<span>Protocol variables (server-side):</span><br /> +<br /> +<ul> +<li>PIDs of participating processes (Integer[]: [1,3]): The PIDs of the Berkeley client processes. The protocol will not work if a non-existent PID is specified or if the process does not support the Berkeley protocol on the client side.</li> +</ul><br /> +<h3 style='display: inline' id='one-phase-commit-protocol'>One-Phase Commit Protocol</h3><br /> +<br /> +<a href='./distributed-systems-simulator/one-phase-commit.png'><img alt='Visualization: The One-Phase Commit Protocol with 3 processes. P1 crashes at 1000ms (shown in red) and recovers at 5000ms. P2 (server) periodically sends commit requests. The red lines show lost messages during P1's crash period, while blue lines show successful message exchanges after recovery.' title='Visualization: The One-Phase Commit Protocol with 3 processes. P1 crashes at 1000ms (shown in red) and recovers at 5000ms. P2 (server) periodically sends commit requests. The red lines show lost messages during P1's crash period, while blue lines show successful message exchanges after recovery.' src='./distributed-systems-simulator/one-phase-commit.png' /></a><br /> +<br /> +<span>The One-Phase Commit Protocol is designed to move any number of clients to a commit. In practice, this could be creating or deleting a file that each client has a local copy of. The server is the coordinator and initiates the commit request. The server periodically resends the commit request until every client has acknowledged it. For this purpose, the PIDs of all participating client processes and a timer for resending must be configured.</span><br /> +<br /> +<span>In the example, P1 and P3 are clients and P2 is the server. P1 crashes at 1000ms and recovers at 5000ms. The first two commit requests fail to reach P1 due to its crash. Only the third attempt succeeds. Each client acknowledges a commit request only once.</span><br /> +<br /> +<pre> +Programmed One-Phase Commit Events: + +| Time (ms) | PID | Event | +|-----------|-----|----------------------------------------| +| 0 | 1 | 1-Phase Commit Client activate | +| 0 | 2 | 1-Phase Commit Server activate | +| 0 | 3 | 1-Phase Commit Client activate | +| 0 | 2 | 1-Phase Commit Server request start | +| 1000 | 1 | Process crash | +| 5000 | 1 | Process revival | +</pre> +<br /> +<span>Protocol variables (server-side):</span><br /> +<br /> +<ul> +<li>Time until resend (Long: timeout = 2500): Milliseconds to wait before resending the commit request</li> +<li>PIDs of participating processes (Integer[]: pids = [1,3]): The client process PIDs that should commit</li> +</ul><br /> +<h3 style='display: inline' id='two-phase-commit-protocol'>Two-Phase Commit Protocol</h3><br /> +<br /> +<a href='./distributed-systems-simulator/two-phase-commit.png'><img alt='Visualization: The Two-Phase Commit Protocol with 3 processes. P2 (server) orchestrates a two-phase voting process with clients P1 and P3. The complex message pattern shows the voting phase followed by the commit/abort phase, with messages crossing between all three processes over a 10-second simulation.' title='Visualization: The Two-Phase Commit Protocol with 3 processes. P2 (server) orchestrates a two-phase voting process with clients P1 and P3. The complex message pattern shows the voting phase followed by the commit/abort phase, with messages crossing between all three processes over a 10-second simulation.' src='./distributed-systems-simulator/two-phase-commit.png' /></a><br /> +<br /> +<span>The Two-Phase Commit Protocol is an extension of the One-Phase Commit Protocol. The server first sends a request to all participating clients asking whether they want to commit. Each client responds with true or false. The server periodically retries until all results are collected. After receiving all votes, the server checks whether all clients voted true. If at least one client voted false, the commit process is aborted and a global result of false is sent to all clients. If all voted true, the global result true is sent. The global result is periodically resent until each client acknowledges receipt.</span><br /> +<br /> +<span>In the example, P1 and P3 are clients and P2 is the server. The server sends its first request at 0ms. Here both P1 and P3 vote true, so the commit proceeds.</span><br /> +<br /> +<pre> +Programmed Two-Phase Commit Events: + +| Time (ms) | PID | Event | +|-----------|-----|----------------------------------------| +| 0 | 1 | 2-Phase Commit Client activate | +| 0 | 2 | 2-Phase Commit Server activate | +| 0 | 3 | 2-Phase Commit Client activate | +| 0 | 2 | 2-Phase Commit Server request start | +</pre> +<br /> +<span>Example log extract showing the two-phase voting process:</span><br /> +<br /> +<pre> +000000ms: PID 2: Message sent; ID: 94; Protocol: 2-Phase Commit + Boolean: wantVote=true +000905ms: PID 3: Message received; ID: 94; Protocol: 2-Phase Commit +000905ms: PID 3: Message sent; ID: 95; Protocol: 2-Phase Commit + Integer: pid=3; Boolean: isVote=true; vote=true +000905ms: PID 3: Vote true sent +001880ms: PID 2: Message received; ID: 95; Protocol: 2-Phase Commit +001880ms: PID 2: Vote from Process 3 received! Result: true +001947ms: PID 1: Message received; ID: 94; Protocol: 2-Phase Commit +001947ms: PID 1: Vote true sent +003137ms: PID 2: Votes from all participating processes received! + Global result: true +003137ms: PID 2: Message sent; ID: 99; Protocol: 2-Phase Commit + Boolean: isVoteResult=true; voteResult=true +004124ms: PID 1: Global vote result received. Result: true +006051ms: PID 2: All participants have acknowledged the vote +010000ms: Simulation ended +</pre> +<br /> +<span>Protocol variables (server-side):</span><br /> +<br /> +<ul> +<li>Time until resend (Long: timeout = 2500): Milliseconds to wait before resending</li> +<li>PIDs of participating processes (Integer[]: pids = [1,3]): Client PIDs that should vote and commit</li> +</ul><br /> +<span>Protocol variables (client-side):</span><br /> +<br /> +<ul> +<li>Commit probability (Integer: ackProb = 50): The probability in percent that the client votes true (for commit)</li> +</ul><br /> +<h3 style='display: inline' id='basic-multicast-protocol'>Basic Multicast Protocol</h3><br /> +<br /> +<a href='./distributed-systems-simulator/basic-multicast.png'><img alt='Visualization: The Basic Multicast Protocol with 3 processes. P2 (client) sends periodic multicast messages to servers P1 and P3. P3 crashes at 3000ms (shown in red) and recovers at 6000ms. Red lines indicate lost messages, blue lines show delivered messages. Some messages to P1 are also lost due to the 30% message loss probability.' title='Visualization: The Basic Multicast Protocol with 3 processes. P2 (client) sends periodic multicast messages to servers P1 and P3. P3 crashes at 3000ms (shown in red) and recovers at 6000ms. Red lines indicate lost messages, blue lines show delivered messages. Some messages to P1 are also lost due to the 30% message loss probability.' src='./distributed-systems-simulator/basic-multicast.png' /></a><br /> +<br /> +<span>The Basic Multicast Protocol is very simple. The client always initiates the request, which represents a simple multicast message. The Basic Multicast servers serve only to receive the message. No acknowledgments are sent. The client P2 sends a multicast message every 2500ms to servers P1 and P3.</span><br /> +<br /> +<span>P1 can only receive multicast messages after 2500ms because it does not support the protocol before then. P3 is crashed from 3000ms to 6000ms and also cannot receive messages during that time. Each process has a 30% message loss probability, so some messages are lost in transit (shown in red).</span><br /> +<br /> +<span>In this example, the 3rd multicast message to P3 and the 5th and 6th messages to P1 were lost. Only the 4th multicast message reached both destinations.</span><br /> +<br /> +<pre> +Programmed Basic Multicast Events: + +| Time (ms) | PID | Event | +|-----------|-----|----------------------------------------| +| 0 | 2 | Basic Multicast Client activate | +| 0 | 3 | Basic Multicast Server activate | +| 0 | 2 | Basic Multicast Client request start | +| 2500 | 1 | Basic Multicast Server activate | +| 2500 | 2 | Basic Multicast Client request start | +| 3000 | 3 | Process crash | +| 5000 | 2 | Basic Multicast Client request start | +| 6000 | 3 | Process revival | +| 7500 | 2 | Basic Multicast Client request start | +| 10000 | 2 | Basic Multicast Client request start | +| 12500 | 2 | Basic Multicast Client request start | +</pre> +<br /> +<h3 style='display: inline' id='reliable-multicast-protocol'>Reliable Multicast Protocol</h3><br /> +<br /> +<a href='./distributed-systems-simulator/reliable-multicast.png'><img alt='Visualization: The Reliable Multicast Protocol with 3 processes. P2 (client) sends multicast messages to servers P1 and P3, retrying until acknowledgments are received from all servers. P3 crashes at 3000ms and recovers at 10000ms. Red lines show lost messages, blue lines show delivered ones. Despite failures, all servers eventually receive and acknowledge the multicast.' title='Visualization: The Reliable Multicast Protocol with 3 processes. P2 (client) sends multicast messages to servers P1 and P3, retrying until acknowledgments are received from all servers. P3 crashes at 3000ms and recovers at 10000ms. Red lines show lost messages, blue lines show delivered ones. Despite failures, all servers eventually receive and acknowledge the multicast.' src='./distributed-systems-simulator/reliable-multicast.png' /></a><br /> +<br /> +<span>In the Reliable Multicast Protocol, the client periodically resends its multicast message until it has received an acknowledgment from all participating servers. After each retry, the client "forgets" which servers have already acknowledged, so each new attempt must be acknowledged again by all participants.</span><br /> +<br /> +<span>In the example, P2 is the client and P1 and P3 are the servers. At 0ms, the client initiates its multicast message. The message loss probability is set to 30% on all processes. The client needs exactly 5 attempts until successful delivery:</span><br /> +<br /> +<ul> +<li>Attempt 1: P1 doesn't support the protocol yet. P3 receives the message but its ACK is lost.</li> +<li>Attempt 2: The message to P1 is lost. P3 receives it but is crashed and can't process it.</li> +<li>Attempt 3: P1 receives the message and ACKs successfully. The message to P3 is lost.</li> +<li>Attempt 4: P1 receives and ACKs again. P3 receives it but is still crashed.</li> +<li>Attempt 5: Both P1 and P3 receive the message and ACK successfully.</li> +</ul><br /> +<pre> +Programmed Reliable Multicast Events: + +| Time (ms) | PID | Event | +|-----------|-----|------------------------------------------| +| 0 | 3 | Reliable Multicast Server activate | +| 0 | 2 | Reliable Multicast Client activate | +| 0 | 2 | Reliable Multicast Client request start | +| 2500 | 1 | Reliable Multicast Server activate | +| 3000 | 3 | Process crash | +| 10000 | 3 | Process revival | +</pre> +<br /> +<span>Example log extract:</span><br /> +<br /> +<pre> +000000ms: PID 2: Reliable Multicast Client activated +000000ms: PID 2: Message sent; ID: 280; Protocol: Reliable Multicast + Boolean: isMulticast=true +000000ms: PID 3: Reliable Multicast Server activated +001590ms: PID 3: Message received; ID: 280; Protocol: Reliable Multicast +001590ms: PID 3: ACK sent +002500ms: PID 1: Reliable Multicast Server activated +002500ms: PID 2: Message sent; ID: 282; Protocol: Reliable Multicast + Boolean: isMulticast=true +003000ms: PID 3: Crashed +005000ms: PID 2: Message sent; ID: 283; Protocol: Reliable Multicast +005952ms: PID 1: Message received; ID: 283 +005952ms: PID 1: ACK sent +007937ms: PID 2: ACK from Process 1 received! +... +011813ms: PID 2: ACK from Process 3 received! +011813ms: PID 2: ACKs from all participating processes received! +015000ms: Simulation ended +</pre> +<br /> +<span>Protocol variables (server-side):</span><br /> +<br /> +<ul> +<li>Time until resend (Long: timeout = 2500): Milliseconds to wait before resending the multicast</li> +<li>PIDs of participating processes (Integer[]: pids = [1,3]): Server PIDs that should receive the multicast</li> +</ul><br /> +<span>Read the next post of this series:</span><br /> +<br /> +<a class='textlink' href='./2026-04-02-distributed-systems-simulator-part-3.html'>Distributed Systems Simulator - Part 3: Advanced Examples and Protocol API</a><br /> +<br /> +<span>Other related posts are:</span><br /> +<br /> +<a class='textlink' href='./2026-03-01-loadbars-0.13.0-released.html'>2026-03-01 Loadbars 0.13.0 released</a><br /> +<a class='textlink' href='./2022-12-24-ultrarelearning-java-my-takeaways.html'>2022-12-24 (Re)learning Java - My takeaways</a><br /> +<a class='textlink' href='./2022-03-06-the-release-of-dtail-4.0.0.html'>2022-03-06 The release of DTail 4.0.0</a><br /> +<a class='textlink' href='./2016-11-20-object-oriented-programming-with-ansi-c.html'>2016-11-20 Object oriented programming with ANSI C</a><br /> +<br /> +<span>E-Mail your comments to <span class='inlinecode'>paul@nospam.buetow.org</span></span><br /> +<br /> +<a class='textlink' href='../'>Back to the main site</a><br /> + </div> + </content> + </entry> + <entry> + <title>Distributed Systems Simulator - Part 1: Introduction and GUI</title> + <link href="gemini://foo.zone/gemfeed/2026-03-31-distributed-systems-simulator-part-1.gmi" /> + <id>gemini://foo.zone/gemfeed/2026-03-31-distributed-systems-simulator-part-1.gmi</id> + <updated>2026-03-31T00:00:00+03:00</updated> + <author> + <name>Paul Buetow aka snonux</name> + <email>paul@dev.buetow.org</email> + </author> + <summary>This is the first blog post of the Distributed Systems Simulator series, written for the recent v1.1.0 release. It explores the Java-based Distributed Systems Simulator program I created as my diploma thesis at the Aachen University of Applied Sciences (August 2008). The simulator offers both built-in implementations of common distributed systems algorithms and an extensible framework that allows researchers and practitioners to implement and test their own custom protocols within the simulation environment.</summary> + <content type="xhtml"> + <div xmlns="http://www.w3.org/1999/xhtml"> + <h1 style='display: inline' id='distributed-systems-simulator---part-1-introduction-and-gui'>Distributed Systems Simulator - Part 1: Introduction and GUI</h1><br /> +<br /> +<span class='quote'>Published at 2026-03-31T00:00:00+03:00</span><br /> +<br /> +<span>This is the first blog post of the Distributed Systems Simulator series, written for the recent v1.1.0 release. It explores the Java-based Distributed Systems Simulator program I created as my diploma thesis at the Aachen University of Applied Sciences (August 2008). The simulator offers both built-in implementations of common distributed systems algorithms and an extensible framework that allows researchers and practitioners to implement and test their own custom protocols within the simulation environment.</span><br /> +<br /> +<a class='textlink' href='https://codeberg.org/snonux/ds-sim'>ds-sim on Codeberg (modernized, English-translated version)</a><br /> +<br /> +<span>These are all the posts of this series:</span><br /> +<br /> +<a class='textlink' href='./2026-03-31-distributed-systems-simulator-part-1.html'>2026-03-31 Distributed Systems Simulator - Part 1: Introduction and GUI (You are currently reading this)</a><br /> +<a class='textlink' href='./2026-04-01-distributed-systems-simulator-part-2.html'>2026-04-01 Distributed Systems Simulator - Part 2: Built-in Protocols</a><br /> +<a class='textlink' href='./2026-04-02-distributed-systems-simulator-part-3.html'>2026-04-02 Distributed Systems Simulator - Part 3: Advanced Examples and Protocol API</a><br /> +<br /> +<a href='./distributed-systems-simulator/ds-sim-screenshot.png'><img alt='Screenshot: The Distributed Systems Simulator running a Broadcast protocol simulation with 6 processes. The visualization shows message lines between process bars, with blue indicating delivered messages and green indicating messages still in transit.' title='Screenshot: The Distributed Systems Simulator running a Broadcast protocol simulation with 6 processes. The visualization shows message lines between process bars, with blue indicating delivered messages and green indicating messages still in transit.' src='./distributed-systems-simulator/ds-sim-screenshot.png' /></a><br /> +<br /> +<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br /> +<br /> +<ul> +<li><a href='#distributed-systems-simulator---part-1-introduction-and-gui'>Distributed Systems Simulator - Part 1: Introduction and GUI</a></li> +<li>⇢ <a href='#motivation'>Motivation</a></li> +<li>⇢ <a href='#installation'>Installation</a></li> +<li>⇢ <a href='#fundamentals'>Fundamentals</a></li> +<li>⇢ ⇢ <a href='#clientserver-model'>Client/Server Model</a></li> +<li>⇢ ⇢ <a href='#processes-and-their-roles'>Processes and Their Roles</a></li> +<li>⇢ ⇢ <a href='#messages'>Messages</a></li> +<li>⇢ ⇢ <a href='#local-and-global-clocks'>Local and Global Clocks</a></li> +<li>⇢ ⇢ <a href='#events'>Events</a></li> +<li>⇢ ⇢ <a href='#protocols'>Protocols</a></li> +<li>⇢ <a href='#graphical-user-interface-gui'>Graphical User Interface (GUI)</a></li> +<li>⇢ ⇢ <a href='#simple-mode'>Simple Mode</a></li> +<li>⇢ ⇢ <a href='#the-menu-bar'>The Menu Bar</a></li> +<li>⇢ ⇢ <a href='#the-toolbar'>The Toolbar</a></li> +<li>⇢ ⇢ <a href='#the-visualization'>The Visualization</a></li> +<li>⇢ ⇢ <a href='#color-differentiation'>Color Differentiation</a></li> +<li>⇢ ⇢ <a href='#the-sidebar'>The Sidebar</a></li> +<li>⇢ ⇢ <a href='#the-log-window'>The Log Window</a></li> +<li>⇢ ⇢ <a href='#expert-mode'>Expert Mode</a></li> +<li>⇢ ⇢ <a href='#configuration-settings'>Configuration Settings</a></li> +</ul><br /> +<h2 style='display: inline' id='motivation'>Motivation</h2><br /> +<br /> +<span>Distributed systems are complex—interactions between nodes, network partitions, failure scenarios are hard to debug in production. A simulator lets you experiment with architectures, observe how systems behave under failure, and learn consensus algorithms, replication strategies, and fault tolerance in a controlled, repeatable environment. No operational overhead, no real infrastructure—just focused exploration of system design.</span><br /> +<br /> +<span>In the literature, one can find many different definitions of a distributed system. Many of these definitions differ from each other, making it difficult to find a single definition that stands alone as the correct one. Andrew Tanenbaum and Maarten van Steen chose the following loose characterization for describing a distributed system:</span><br /> +<br /> +<span class='quote'>"A distributed system is a collection of independent computers that appears to its users as a single coherent system" - Andrew Tanenbaum</span><br /> +<br /> +<span>The user only needs to interact with the local computer in front of them, while the software of the local computer ensures smooth communication with the other participating computers in the distributed system.</span><br /> +<br /> +<span>This thesis aims to make distributed systems easier to understand from a different angle. Instead of the end-user perspective, it focuses on the functional methods of protocols and their processes, making all relevant events of a distributed system transparent.</span><br /> +<br /> +<span>To achieve this, I developed a simulator, particularly for teaching and learning at the University of Applied Sciences Aachen. Protocols from distributed systems with their most important influencing factors can be replicated through simulations. At the same time, there's room for personal experiments—no restriction to a fixed number of protocols. Users can design their own.</span><br /> +<br /> +<span>The original simulator (VS-Sim) was written in Java 6 in 2008 with a German-language UI. In 2025, I revamped and modernized it as ds-sim: translated the entire codebase and UI from German to English, migrated the build system from hand-rolled Ant scripts to Maven, upgraded from Java 6 to Java 21 (adopting sealed class hierarchies, record types, formatted strings, pattern matching), introduced a proper exception hierarchy and consistent error handling, added comprehensive Javadoc documentation, implemented a headless testing framework (208 unit tests covering core components, the event system, and all protocol implementations), reorganized the project structure to follow standard Maven conventions, and added architecture documentation. Total: 199 files, over 15,000 lines of new code. Back in 2008, I wrote every line by hand in Vim. For the 2025 modernization, Claude Code did most of the heavy lifting—translation, refactoring, test generation, documentation. Times have changed.</span><br /> +<br /> +<h2 style='display: inline' id='installation'>Installation</h2><br /> +<br /> +<span>The modernized ds-sim requires Java 21 or higher and Maven 3.8 or higher.</span><br /> +<br /> +<pre> +# Clone the repository +git clone https://codeberg.org/snonux/ds-sim.git +cd ds-sim + +# Set JAVA_HOME if needed (e.g. on Fedora Linux) +export JAVA_HOME=/usr/lib/jvm/java-21-openjdk + +# Build the project +mvn clean package + +# Run the simulator +java -jar target/ds-sim-*.jar +</pre> +<br /> +<span>For a faster development build without running tests:</span><br /> +<br /> +<pre> +mvn package -DskipTests +</pre> +<br /> +<span>After building, the following artifacts are available in the <span class='inlinecode'>target/</span> directory:</span><br /> +<br /> +<ul> +<li><span class='inlinecode'>ds-sim-1.1.0.jar</span> - Executable JAR with all dependencies bundled</li> +<li><span class='inlinecode'>original-ds-sim-1.1.0.jar</span> - JAR without dependencies</li> +</ul><br /> +<span>The project also includes 208 unit tests that can be run with <span class='inlinecode'>mvn test</span>. Example simulation files for all built-in protocols are included in the <span class='inlinecode'>saved-simulations/</span> directory.</span><br /> +<br /> +<a class='textlink' href='https://codeberg.org/snonux/ds-sim'>ds-sim source code on Codeberg</a><br /> +<br /> +<h2 style='display: inline' id='fundamentals'>Fundamentals</h2><br /> +<br /> +<span>For basic understanding, some fundamentals are explained below. A deeper exploration will follow in later chapters.</span><br /> +<br /> +<h3 style='display: inline' id='clientserver-model'>Client/Server Model</h3><br /> +<br /> +<pre> ++-----------------------------------------+ +| | +| +--------+ +--------+ | +| | Client |<------->| Server | | +| +--------+ +--------+ | +| | +| Sending of Messages | +| | ++-----------------------------------------+ + +Figure 1.1: Client/Server Model +</pre> +<br /> +<span>The simulator is based on the client/server principle. Each simulation typically consists of a participating client and a server that communicate with each other via messages (see Fig. 1.1). In complex simulations, multiple clients and/or servers can also participate.</span><br /> +<br /> +<h3 style='display: inline' id='processes-and-their-roles'>Processes and Their Roles</h3><br /> +<br /> +<span>A distributed system is simulated using processes. Each process takes on one or more roles. For example, one process can take on the role of a client and another process the role of a server. The possibility of assigning both client and server roles to a process simultaneously is also provided. A process could also take on the roles of multiple servers and clients simultaneously. To identify a process, each one has a unique Process Identification Number (PID).</span><br /> +<br /> +<h3 style='display: inline' id='messages'>Messages</h3><br /> +<br /> +<span>In a distributed system, it must be possible to send messages. A message can be sent by a client or server process and can have any number of recipients. The content of a message depends on the protocol used. What is meant by a protocol will be covered later. To identify a message, each message has a unique Message Identification Number (NID).</span><br /> +<br /> +<h3 style='display: inline' id='local-and-global-clocks'>Local and Global Clocks</h3><br /> +<br /> +<span>In a simulation, there is exactly one global clock. It represents the current and always correct time. A global clock never goes wrong.</span><br /> +<br /> +<span>Additionally, each participating process has its own local clock. It represents the current time of the respective process. Unlike the global clock, local clocks can display an incorrect time. If the process time is not globally correct (not equal to the global time, or displays an incorrect time), then it was either reset during a simulation, or it is running incorrectly due to clock drift. The clock drift indicates by what factor the clock is running incorrectly. This will be discussed in more detail later.</span><br /> +<br /> +<pre> ++---------------------+ +---------------------+ +| Process 1 | | Process 2 | +| | | | +| +-----------------+ | | +-----------------+ | +| |Server Protocol A| | | |Client Protocol A| | +| +-----------------+ | | +-----------------+ | +| | | | +| +-----------------+ | +---------------------+ +| |Client Protocol B| | +| +-----------------+ | +---------------------+ +| | | Process 3 | ++---------------------+ | | + | +-----------------+ | + | |Server Protocol B| | + | +-----------------+ | + | | + +---------------------+ + +Figure 1.2: Client/Server Protocols +</pre> +<br /> +<span>In addition to normal clocks, vector timestamps and Lamport's logical clocks are also of interest. For vector and Lamport times, there are no global equivalents here, unlike normal time. Concrete examples of Lamport and vector times will be covered later in the "Additional Examples" section.</span><br /> +<br /> +<h3 style='display: inline' id='events'>Events</h3><br /> +<br /> +<span>A simulation consists of the sequential execution of finitely many events. For example, there can be an event that causes a process to send a message. A process crash event would also be conceivable. Each event occurs at a specific point in time. Events with the same occurrence time are executed directly one after another by the simulator. However, this does not hinder the simulator's users, as events are executed in parallel from their perspective.</span><br /> +<br /> +<span>Two main types of events are distinguished: programmable events and non-programmable events. Programmable events can be programmed and edited in the event editor, and their occurrence times depend on the local process clocks or the global clock. Non-programmable events, on the other hand, cannot be programmed in the event editor and do not occur because of a specific time, but due to other circumstances such as:</span><br /> +<br /> +<ul> +<li>Message receive events: Triggered when a message arrives at a recipient process</li> +<li>Protocol schedule events (alarms): Triggered by a timer set by a protocol, e.g. for retransmission timeouts</li> +<li>Random events: Such as random process crashes based on configured crash probability</li> +</ul><br /> +<h3 style='display: inline' id='protocols'>Protocols</h3><br /> +<br /> +<span>A simulation also consists of the application of protocols. It has already been mentioned that a process can take on the roles of servers and/or clients. For each server and client role, the associated protocol must also be specified. A protocol defines how a client and a server send messages, and how they react when a message arrives. A protocol also determines what data is contained in a message. A process only processes a received message if it understands the respective protocol.</span><br /> +<br /> +<span>In Figure 1.2, 3 processes are shown. Process 1 supports protocol "A" on the server side and protocol "B" on the client side. Process 2 supports protocol "A" on the client side and Process 3 supports protocol "B" on the server side. This means that Process 1 can communicate with Process 2 via protocol "A" and with Process 3 via protocol "B". Processes 2 and 3 are incompatible with each other and cannot process messages received from each other.</span><br /> +<br /> +<span>Clients cannot communicate with clients, and servers cannot communicate with servers. For communication, at least one client and one server are always required. However, this restriction can be circumvented by having processes support a given protocol on both the server and client sides (see Broadcast Protocol later).</span><br /> +<br /> +<h2 style='display: inline' id='graphical-user-interface-gui'>Graphical User Interface (GUI)</h2><br /> +<br /> +<h3 style='display: inline' id='simple-mode'>Simple Mode</h3><br /> +<br /> +<a href='./distributed-systems-simulator/ds-sim-screenshot2.png'><img alt='Screenshot: The simulator showing the settings dialog. The visualization area displays process bars with message lines between them. The settings window allows configuring simulation parameters like number of processes, simulation duration, clock drift, message loss probability, and more.' title='Screenshot: The simulator showing the settings dialog. The visualization area displays process bars with message lines between them. The settings window allows configuring simulation parameters like number of processes, simulation duration, clock drift, message loss probability, and more.' src='./distributed-systems-simulator/ds-sim-screenshot2.png' /></a><br /> +<br /> +<span>The simulator requires JDK 21 and can be started with the command <span class='inlinecode'>java -jar target/ds-sim-VERSION.jar</span></span><br /> +<br /> +<span>The simulator then presents itself with a main window. To create a new simulation, select "New Simulation" from the "File" menu, after which the settings window for the new simulation appears. The individual options will be discussed in more detail later, and for now, only the default settings will be used.</span><br /> +<br /> +<span>By default, the simulator starts in "simple mode". There is also an "expert mode", which will be discussed later.</span><br /> +<br /> +<h3 style='display: inline' id='the-menu-bar'>The Menu Bar</h3><br /> +<br /> +<span>In the File menu, you can create new simulations or close the currently open simulation. New simulations open by default in a new tab. However, you can also open or close new simulation windows that have their own tabs. Each tab contains a simulation that is completely independent from the others. This allows any number of simulations to be run in parallel. The menu items "Open", "Save" and "Save As" are used for loading and saving simulations.</span><br /> +<br /> +<span>Through the Edit menu, users can access the simulation settings, which will be discussed in more detail later. This menu also lists all participating processes for editing. If the user selects a process there, the corresponding process editor opens. The Simulator menu offers the same options as the toolbar, which is described in the next section.</span><br /> +<br /> +<span>Some menu items are only accessible when a simulation has already been created or loaded in the current window.</span><br /> +<br /> +<h3 style='display: inline' id='the-toolbar'>The Toolbar</h3><br /> +<br /> +<span>The toolbar is located at the top left of the simulator. The toolbar contains the functions most frequently needed by users. The toolbar offers four different functions:</span><br /> +<br /> +<ul> +<li>Reset simulation: can only be activated when the simulation has been paused or has finished</li> +<li>Repeat simulation: cannot be activated if the simulation has not yet been started</li> +<li>Pause simulation: can only be activated when the simulation is currently running</li> +<li>Start simulation: can only be activated when the simulation is not currently running and has not yet finished</li> +</ul><br /> +<h3 style='display: inline' id='the-visualization'>The Visualization</h3><br /> +<br /> +<span>The graphical simulation visualization is located in the center right. The X-axis shows the time in milliseconds, and all participating processes are listed on the Y-axis. The demo simulation ends after exactly 15 seconds. The visualization shows processes (with PIDs 1, 2, and 3), each with its own horizontal black bar. On these process bars, users can read the respective local process time. The vertical red line represents the global simulation time.</span><br /> +<br /> +<span>The process bars also serve as start and end points for messages. For example, if Process 1 sends a message to Process 2, a line is drawn from one process bar to the other. Messages that a process sends to itself are not visualized but are logged in the log window (more on this later).</span><br /> +<br /> +<span>Another way to open a process editor is to left-click on the process bar belonging to the process. A right-click, on the other hand, opens a popup window with additional options. A process can only be forced to crash or be revived via the popup menu during a running simulation.</span><br /> +<br /> +<span>In general, the number of processes can vary as desired. The simulation duration is at least 5 and at most 120 seconds. The simulation only ends when the global time reaches the specified simulation end time (here 15 seconds), not when a local process time reaches this end time.</span><br /> +<br /> +<h3 style='display: inline' id='color-differentiation'>Color Differentiation</h3><br /> +<br /> +<span>Colors help to better interpret the processes of a simulation. By default, processes (process bars) and messages are displayed with the following colors (these are only the default colors, which can be changed via the settings):</span><br /> +<br /> +<pre> +Process Colors: + Black - The simulation is not currently running + Green - The process is running normally + Orange - The mouse is over the process bar + Red - The process has crashed + +Message Colors: + Green - The message is still in transit + Blue - The message has successfully reached its destination + Red - The message was lost +</pre> +<br /> +<h3 style='display: inline' id='the-sidebar'>The Sidebar</h3><br /> +<br /> +<span>The sidebar is used to program process events. At the top, the process to be managed is selected (here with PID 1). In this process selection, there is also the option to select "All Processes", which displays all programmed events of all processes simultaneously. "Local events" are those events that occur when a certain local time of the associated process has been reached. The event table below lists all programmed events along with their occurrence times and PIDs.</span><br /> +<br /> +<span>To create a new event, the user can either right-click on a process bar and select "Insert local event", or select an event below the event table, enter the event occurrence time in the text field below, and click "Apply".</span><br /> +<br /> +<span>Right-clicking on the event editor allows you to either copy or delete all selected events. Using the Ctrl key, multiple events can be selected simultaneously. The entries in the Time and PID columns can be edited afterwards. This provides a convenient way to move already programmed events to a different time or assign them to a different process. However, users should ensure that they press the Enter key after changing the event occurrence time, otherwise the change will be ineffective.</span><br /> +<br /> +<span>In addition to the Events tab, the sidebar has another tab called "Variables". Behind this tab is the process editor of the currently selected process. There, all variables of the process can be edited, providing another way to access a process editor.</span><br /> +<br /> +<h3 style='display: inline' id='the-log-window'>The Log Window</h3><br /> +<br /> +<span>The log window (at the bottom) logs all occurring events in chronological order. At the beginning of each log entry, the global time in milliseconds is always logged. For each process, its local times as well as the Lamport and vector timestamps are also listed. After the time information, additional details are provided, such as which message was sent with what content and which protocol it belongs to. This will be demonstrated later with examples.</span><br /> +<br /> +<pre> +000000ms: New Simulation +000000ms: New Process; PID: 1; Local Time: 000000ms; Lamport time: 0; Vector time: (0,0,0) +000000ms: New Process; PID: 2; Local Time: 000000ms; Lamport time: 0; Vector time: (0,0,0) +000000ms: New Process; PID: 3; Local Time: 000000ms; Lamport time: 0; Vector time: (0,0,0) +</pre> +<br /> +<span>By deactivating the logging switch, message logging can be temporarily disabled. With logging deactivated, no new messages are written to the log window. After reactivating the switch, all omitted messages are subsequently written to the window. Deactivated logging can lead to improved simulator performance.</span><br /> +<br /> +<h3 style='display: inline' id='expert-mode'>Expert Mode</h3><br /> +<br /> +<a href='./distributed-systems-simulator/ds-sim-screenshot.png'><img alt='Screenshot: The Distributed Systems Simulator in expert mode, showing a Broadcast protocol simulation with 6 processes. The visualization shows message lines between process bars, with blue indicating delivered messages and green indicating messages still in transit.' title='Screenshot: The Distributed Systems Simulator in expert mode, showing a Broadcast protocol simulation with 6 processes. The visualization shows message lines between process bars, with blue indicating delivered messages and green indicating messages still in transit.' src='./distributed-systems-simulator/ds-sim-screenshot.png' /></a><br /> +<br /> +<span>The simulator can be operated in two different modes: simple mode and expert mode. The simulator starts in simple mode by default, so users don't have to deal with the simulator's full functionality all at once. Simple mode is clearer but offers fewer functions. Expert mode is more suitable for experienced users and accordingly offers more flexibility. Expert mode can be activated or deactivated via the switch of the same name below the log window or via the simulation settings.</span><br /> +<br /> +<span>In expert mode, the following additional features become available:</span><br /> +<br /> +<ul> +<li>Global events: In addition to local events, global events can now also be edited. Global events are triggered when a specific global simulation time is reached, rather than a local process time. This only makes a difference when local process times differ from the global time (e.g. due to clock drift).</li> +<li>Direct PID selection: The user can directly select the associated PID when programming a new event.</li> +<li>Lamport and Vector time switches: If the user activates one of these two switches, the Lamport or vector timestamps are displayed in the visualization. Only one can be active at a time to maintain clarity.</li> +<li>Anti-aliasing switch: Allows the user to activate or deactivate anti-aliasing for smoother graphics. Disabled by default for performance reasons.</li> +<li>Log filter: A regular expression filter (Java syntax) that makes it possible to filter only the essential data from the logs. For example, <span class='inlinecode'>"PID: (1|2)"</span> shows only log lines containing "PID: 1" or "PID: 2". The filter can be activated retroactively and during a running simulation.</li> +</ul><br /> +<h3 style='display: inline' id='configuration-settings'>Configuration Settings</h3><br /> +<br /> +<span>The simulation settings window allows configuring many aspects of the simulation. Key settings include:</span><br /> +<br /> +<ul> +<li>Processes receive own messages (default: false): Whether processes can receive messages they sent to themselves.</li> +<li>Average message loss probabilities (default: true): Whether to average the loss probabilities of sender and receiver processes.</li> +<li>Average transmission times (default: true): Whether to average the transmission times of sender and receiver processes.</li> +<li>Show only relevant messages (default: true): Hides messages sent to processes that don't support the protocol.</li> +<li>Expert mode (default: false): Enables expert mode features.</li> +<li>Simulation speed (default: 0.5): The playback speed factor. A value of 1 means real-time, 0.5 means half speed.</li> +<li>Number of processes (default: 3): Can also be changed during simulation via right-click.</li> +<li>Simulation duration (default: 15s): Between 5 and 120 seconds.</li> +</ul><br /> +<span>Each process also has individual settings:</span><br /> +<br /> +<ul> +<li>Clock drift (default: 0.0): By what factor the local clock deviates. A value of 0.0 means no deviation. A value of 1.0 means double speed. Values > -1.0 are allowed.</li> +<li>Random crash probability (default: 0%): Probability that the process crashes randomly during the simulation.</li> +<li>Message loss probability (default: 0%): Probability that a message sent by this process is lost in transit.</li> +<li>Min/Max transmission time (default: 500ms/2000ms): The range for random message delivery times.</li> +</ul><br /> +<span>Read the next post of this series:</span><br /> +<br /> +<a class='textlink' href='./2026-04-01-distributed-systems-simulator-part-2.html'>Distributed Systems Simulator - Part 2: Built-in Protocols</a><br /> +<br /> +<span>Other related posts are:</span><br /> +<br /> +<a class='textlink' href='./2026-03-01-loadbars-0.13.0-released.html'>2026-03-01 Loadbars 0.13.0 released</a><br /> +<a class='textlink' href='./2022-12-24-ultrarelearning-java-my-takeaways.html'>2022-12-24 (Re)learning Java - My takeaways</a><br /> +<a class='textlink' href='./2022-03-06-the-release-of-dtail-4.0.0.html'>2022-03-06 The release of DTail 4.0.0</a><br /> +<a class='textlink' href='./2016-11-20-object-oriented-programming-with-ansi-c.html'>2016-11-20 Object oriented programming with ANSI C</a><br /> +<br /> +<span>E-Mail your comments to <span class='inlinecode'>paul@nospam.buetow.org</span></span><br /> +<br /> +<a class='textlink' href='../'>Back to the main site</a><br /> + </div> + </content> + </entry> + <entry> <title>RCM: The Ruby Configuration Management DSL</title> <link href="gemini://foo.zone/gemfeed/2026-03-02-rcm-ruby-configuration-management-dsl.gmi" /> <id>gemini://foo.zone/gemfeed/2026-03-02-rcm-ruby-configuration-management-dsl.gmi</id> @@ -18348,1180 +19344,4 @@ jgs \\`_..---.Y.---.._`// </div> </content> </entry> - <entry> - <title>Random Weird Things - Part Ⅰ</title> - <link href="gemini://foo.zone/gemfeed/2024-07-05-random-weird-things.gmi" /> - <id>gemini://foo.zone/gemfeed/2024-07-05-random-weird-things.gmi</id> - <updated>2024-07-05T10:59:59+03:00</updated> - <author> - <name>Paul Buetow aka snonux</name> - <email>paul@dev.buetow.org</email> - </author> - <summary>Every so often, I come across random, weird, and unexpected things on the internet. I thought it would be neat to share them here from time to time. As a start, here are ten of them.</summary> - <content type="xhtml"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h1 style='display: inline' id='random-weird-things---part-'>Random Weird Things - Part Ⅰ</h1><br /> -<br /> -<span class='quote'>Published at 2024-07-05T10:59:59+03:00; Updated at 2025-02-08</span><br /> -<br /> -<span>Every so often, I come across random, weird, and unexpected things on the internet. I thought it would be neat to share them here from time to time. As a start, here are ten of them.</span><br /> -<br /> -<a class='textlink' href='./2024-07-05-random-weird-things.html'>2024-07-05 Random Weird Things - Part Ⅰ (You are currently reading this)</a><br /> -<a class='textlink' href='./2025-02-08-random-weird-things-ii.html'>2025-02-08 Random Weird Things - Part Ⅱ</a><br /> -<a class='textlink' href='./2025-08-15-random-weird-things-iii.html'>2025-08-15 Random Weird Things - Part Ⅲ</a><br /> -<br /> -<pre> - /\_/\ -WHOA!! ( o.o ) - > ^ < - / - \ - / \ - /______\ \ -</pre> -<br /> -<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br /> -<br /> -<ul> -<li><a href='#random-weird-things---part-'>Random Weird Things - Part Ⅰ</a></li> -<li>⇢ <a href='#1-badhorse-traceroute'>1. <span class='inlinecode'>bad.horse</span> traceroute</a></li> -<li>⇢ <a href='#2-ascii-cinema'>2. ASCII cinema</a></li> -<li>⇢ <a href='#3-netflix-s-hello-world-application'>3. Netflix's Hello World application</a></li> -<li>⇢ <a href='#c-programming'>C programming</a></li> -<li>⇢ ⇢ <a href='#4-indexing-an-array'>4. Indexing an array</a></li> -<li>⇢ ⇢ <a href='#5-variables-with-prefix-'>5. Variables with prefix <span class='inlinecode'>$</span></a></li> -<li>⇢ <a href='#6-object-oriented-shell-scripts-using-ksh'>6. Object oriented shell scripts using <span class='inlinecode'>ksh</span></a></li> -<li>⇢ <a href='#7-this-works-in-go'>7. This works in Go</a></li> -<li>⇢ <a href='#8-i-am-a-teapot-http-response-code'>8. "I am a Teapot" HTTP response code</a></li> -<li>⇢ <a href='#9-jq-is-a-functional-programming-language'>9. <span class='inlinecode'>jq</span> is a functional programming language</a></li> -<li>⇢ <a href='#10-regular-expression-to-verify-email-addresses'>10. Regular expression to verify email addresses</a></li> -</ul><br /> -<h2 style='display: inline' id='1-badhorse-traceroute'>1. <span class='inlinecode'>bad.horse</span> traceroute</h2><br /> -<br /> -<span>Run traceroute to get the poem (or song).</span><br /> -<br /> -<span class='quote'>Update: A reader hinted that by specifying <span class='inlinecode'>-n 60</span>, there will be even more output!</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre>❯ traceroute -m <font color="#000000">60</font> bad.horse -traceroute to bad.horse (<font color="#000000">162.252</font>.<font color="#000000">205.157</font>), <font color="#000000">60</font> hops max, <font color="#000000">60</font> byte packets - <font color="#000000">1</font> _gateway (<font color="#000000">192.168</font>.<font color="#000000">1.1</font>) <font color="#000000">5.237</font> ms <font color="#000000">5.264</font> ms <font color="#000000">6.009</font> ms - <font color="#000000">2</font> <font color="#000000">77</font>-<font color="#000000">85</font>-<font color="#000000">0</font>-<font color="#000000">2</font>.ip.btc-net.<b><u><font color="#000000">bg</font></u></b> (<font color="#000000">77.85</font>.<font color="#000000">0.2</font>) <font color="#000000">8.753</font> ms <font color="#000000">7.112</font> ms <font color="#000000">8.336</font> ms - <font color="#000000">3</font> <font color="#000000">212</font>-<font color="#000000">39</font>-<font color="#000000">69</font>-<font color="#000000">103</font>.ip.btc-net.<b><u><font color="#000000">bg</font></u></b> (<font color="#000000">212.39</font>.<font color="#000000">69.103</font>) <font color="#000000">9.434</font> ms <font color="#000000">9.268</font> ms <font color="#000000">9.986</font> ms - <font color="#000000">4</font> * * * - <font color="#000000">5</font> xe-<font color="#000000">1</font>-<font color="#000000">2</font>-<font color="#000000">0</font>.mpr1.fra4.de.above.net (<font color="#000000">80.81</font>.<font color="#000000">194.26</font>) <font color="#000000">39.812</font> ms <font color="#000000">39.030</font> ms <font color="#000000">39.772</font> ms - <font color="#000000">6</font> * ae12.cs1.fra6.de.eth.zayo.com (<font color="#000000">64.125</font>.<font color="#000000">26.172</font>) <font color="#000000">123.576</font> ms * - <font color="#000000">7</font> * * * - <font color="#000000">8</font> * * * - <font color="#000000">9</font> ae10.cr1.lhr15.uk.eth.zayo.com (<font color="#000000">64.125</font>.<font color="#000000">29.17</font>) <font color="#000000">119.097</font> ms <font color="#000000">119.478</font> ms <font color="#000000">120.767</font> ms -<font color="#000000">10</font> ae2.cr1.lhr11.uk.zip.zayo.com (<font color="#000000">64.125</font>.<font color="#000000">24.140</font>) <font color="#000000">120.398</font> ms <font color="#000000">121.147</font> ms <font color="#000000">120.948</font> ms -<font color="#000000">11</font> * * * -<font color="#000000">12</font> ae25.mpr1.yyz1.ca.zip.zayo.com (<font color="#000000">64.125</font>.<font color="#000000">23.117</font>) <font color="#000000">145.072</font> ms * <font color="#000000">181.773</font> ms -<font color="#000000">13</font> ae5.mpr1.tor3.ca.zip.zayo.com (<font color="#000000">64.125</font>.<font color="#000000">23.118</font>) <font color="#000000">168.239</font> ms <font color="#000000">168.158</font> ms <font color="#000000">168.137</font> ms -<font color="#000000">14</font> <font color="#000000">64.124</font>.<font color="#000000">217.237</font>.IDIA-<font color="#000000">265104</font>-ZYO.zip.zayo.com (<font color="#000000">64.124</font>.<font color="#000000">217.237</font>) <font color="#000000">168.026</font> ms <font color="#000000">167.999</font> ms <font color="#000000">165.451</font> ms -<font color="#000000">15</font> * * * -<font color="#000000">16</font> t00.toroc1.on.ca.sn11.net (<font color="#000000">162.252</font>.<font color="#000000">204.2</font>) <font color="#000000">131.598</font> ms <font color="#000000">131.308</font> ms <font color="#000000">131.482</font> ms -<font color="#000000">17</font> bad.horse (<font color="#000000">162.252</font>.<font color="#000000">205.130</font>) <font color="#000000">131.430</font> ms <font color="#000000">145.914</font> ms <font color="#000000">130.514</font> ms -<font color="#000000">18</font> bad.horse (<font color="#000000">162.252</font>.<font color="#000000">205.131</font>) <font color="#000000">136.634</font> ms <font color="#000000">145.295</font> ms <font color="#000000">135.631</font> ms -<font color="#000000">19</font> bad.horse (<font color="#000000">162.252</font>.<font color="#000000">205.132</font>) <font color="#000000">139.158</font> ms <font color="#000000">148.363</font> ms <font color="#000000">138.934</font> ms -<font color="#000000">20</font> bad.horse (<font color="#000000">162.252</font>.<font color="#000000">205.133</font>) <font color="#000000">145.395</font> ms <font color="#000000">148.054</font> ms <font color="#000000">147.140</font> ms -<font color="#000000">21</font> he.rides.across.the.nation (<font color="#000000">162.252</font>.<font color="#000000">205.134</font>) <font color="#000000">149.687</font> ms <font color="#000000">147.731</font> ms <font color="#000000">150.135</font> ms -<font color="#000000">22</font> the.thoroughbred.of.sin (<font color="#000000">162.252</font>.<font color="#000000">205.135</font>) <font color="#000000">156.644</font> ms <font color="#000000">155.155</font> ms <font color="#000000">156.447</font> ms -<font color="#000000">23</font> he.got.the.application (<font color="#000000">162.252</font>.<font color="#000000">205.136</font>) <font color="#000000">161.187</font> ms <font color="#000000">162.318</font> ms <font color="#000000">162.674</font> ms -<font color="#000000">24</font> that.you.just.sent.<b><u><font color="#000000">in</font></u></b> (<font color="#000000">162.252</font>.<font color="#000000">205.137</font>) <font color="#000000">166.763</font> ms <font color="#000000">166.675</font> ms <font color="#000000">164.243</font> ms -<font color="#000000">25</font> it.needs.evaluation (<font color="#000000">162.252</font>.<font color="#000000">205.138</font>) <font color="#000000">172.073</font> ms <font color="#000000">171.919</font> ms <font color="#000000">171.390</font> ms -<font color="#000000">26</font> so.<b><u><font color="#000000">let</font></u></b>.the.games.begin (<font color="#000000">162.252</font>.<font color="#000000">205.139</font>) <font color="#000000">175.386</font> ms <font color="#000000">174.180</font> ms <font color="#000000">175.965</font> ms -<font color="#000000">27</font> a.heinous.crime (<font color="#000000">162.252</font>.<font color="#000000">205.140</font>) <font color="#000000">180.857</font> ms <font color="#000000">180.766</font> ms <font color="#000000">180.192</font> ms -<font color="#000000">28</font> a.show.of.force (<font color="#000000">162.252</font>.<font color="#000000">205.141</font>) <font color="#000000">187.942</font> ms <font color="#000000">186.669</font> ms <font color="#000000">186.986</font> ms -<font color="#000000">29</font> a.murder.would.be.nice.of.course (<font color="#000000">162.252</font>.<font color="#000000">205.142</font>) <font color="#000000">191.349</font> ms <font color="#000000">191.939</font> ms <font color="#000000">190.740</font> ms -<font color="#000000">30</font> bad.horse (<font color="#000000">162.252</font>.<font color="#000000">205.143</font>) <font color="#000000">195.425</font> ms <font color="#000000">195.716</font> ms <font color="#000000">196.186</font> ms -<font color="#000000">31</font> bad.horse (<font color="#000000">162.252</font>.<font color="#000000">205.144</font>) <font color="#000000">199.238</font> ms <font color="#000000">200.620</font> ms <font color="#000000">200.318</font> ms -<font color="#000000">32</font> bad.horse (<font color="#000000">162.252</font>.<font color="#000000">205.145</font>) <font color="#000000">207.554</font> ms <font color="#000000">206.729</font> ms <font color="#000000">205.201</font> ms -<font color="#000000">33</font> he-s.bad (<font color="#000000">162.252</font>.<font color="#000000">205.146</font>) <font color="#000000">211.087</font> ms <font color="#000000">211.649</font> ms <font color="#000000">211.712</font> ms -<font color="#000000">34</font> the.evil.league.of.evil (<font color="#000000">162.252</font>.<font color="#000000">205.147</font>) <font color="#000000">212.657</font> ms <font color="#000000">216.777</font> ms <font color="#000000">216.589</font> ms -<font color="#000000">35</font> is.watching.so.beware (<font color="#000000">162.252</font>.<font color="#000000">205.148</font>) <font color="#000000">220.911</font> ms <font color="#000000">220.326</font> ms <font color="#000000">221.961</font> ms -<font color="#000000">36</font> the.grade.that.you.receive (<font color="#000000">162.252</font>.<font color="#000000">205.149</font>) <font color="#000000">225.384</font> ms <font color="#000000">225.696</font> ms <font color="#000000">225.640</font> ms -<font color="#000000">37</font> will.be.your.last.we.swear (<font color="#000000">162.252</font>.<font color="#000000">205.150</font>) <font color="#000000">232.312</font> ms <font color="#000000">230.989</font> ms <font color="#000000">230.919</font> ms -<font color="#000000">38</font> so.make.the.bad.horse.gleeful (<font color="#000000">162.252</font>.<font color="#000000">205.151</font>) <font color="#000000">235.761</font> ms <font color="#000000">235.291</font> ms <font color="#000000">235.585</font> ms -<font color="#000000">39</font> or.he-ll.make.you.his.mare (<font color="#000000">162.252</font>.<font color="#000000">205.152</font>) <font color="#000000">241.350</font> ms <font color="#000000">239.407</font> ms <font color="#000000">238.394</font> ms -<font color="#000000">40</font> o_o (<font color="#000000">162.252</font>.<font color="#000000">205.153</font>) <font color="#000000">246.154</font> ms <font color="#000000">247.650</font> ms <font color="#000000">247.110</font> ms -<font color="#000000">41</font> you-re.saddled.up (<font color="#000000">162.252</font>.<font color="#000000">205.154</font>) <font color="#000000">250.925</font> ms <font color="#000000">250.401</font> ms <font color="#000000">250.619</font> ms -<font color="#000000">42</font> there-s.no.recourse (<font color="#000000">162.252</font>.<font color="#000000">205.155</font>) <font color="#000000">256.071</font> ms <font color="#000000">251.154</font> ms <font color="#000000">255.340</font> ms -<font color="#000000">43</font> it-s.hi-ho.silver (<font color="#000000">162.252</font>.<font color="#000000">205.156</font>) <font color="#000000">260.152</font> ms <font color="#000000">261.775</font> ms <font color="#000000">261.544</font> ms -<font color="#000000">44</font> signed.bad.horse (<font color="#000000">162.252</font>.<font color="#000000">205.157</font>) <font color="#000000">262.430</font> ms <font color="#000000">261.410</font> ms <font color="#000000">261.365</font> ms -</pre> -<br /> -<h2 style='display: inline' id='2-ascii-cinema'>2. ASCII cinema</h2><br /> -<br /> -<span>Fancy watching Star Wars Episode IV in ASCII? Head to the ASCII cinema:</span><br /> -<br /> -<a class='textlink' href='https://asciinema.org/a/569727'>https://asciinema.org/a/569727</a><br /> -<br /> -<h2 style='display: inline' id='3-netflix-s-hello-world-application'>3. Netflix's Hello World application</h2><br /> -<br /> -<span>Netflix has got the Hello World application run in production 😱</span><br /> -<br /> -<ul> -<li>https://www.Netflix.com/helloworld</li> -</ul><br /> -<span class='quote'>By the time this is posted, it seems that Netflix has taken it offline... I should have created a screenshot!</span><br /> -<br /> -<h2 style='display: inline' id='c-programming'>C programming</h2><br /> -<br /> -<h3 style='display: inline' id='4-indexing-an-array'>4. Indexing an array</h3><br /> -<br /> -<span>In C, you can index an array like this: <span class='inlinecode'>array[i]</span> (not surprising). But this works as well and is valid C code: <span class='inlinecode'>i[array]</span>, 🤯 It's because after the spec <span class='inlinecode'>A[B]</span> is equivalent to <span class='inlinecode'>*(A + B)</span> and the ordering doesn't matter for the <span class='inlinecode'>+</span> operator. All 3 loops are producing the same output. Would be funny to use <span class='inlinecode'>i[array]</span> in a merge request of some code base on April Fool's day!</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><b><u><font color="#000000">#include</font></u></b> <font color="#808080"><stdio.h></font> - -<b><font color="#000000">int</font></b> main(<b><font color="#000000">void</font></b>) { - <b><font color="#000000">int</font></b> array[<font color="#000000">5</font>] = { <font color="#000000">1</font>, <font color="#000000">2</font>, <font color="#000000">3</font>, <font color="#000000">4</font>, <font color="#000000">5</font> }; - - <b><u><font color="#000000">for</font></u></b> (<b><font color="#000000">int</font></b> i = <font color="#000000">0</font>; i < <font color="#000000">5</font>; i++) - printf(<font color="#808080">"%d</font>\n<font color="#808080">"</font>, array[i]); - - <b><u><font color="#000000">for</font></u></b> (<b><font color="#000000">int</font></b> i = <font color="#000000">0</font>; i < <font color="#000000">5</font>; i++) - printf(<font color="#808080">"%d</font>\n<font color="#808080">"</font>, i[array]); - - <b><u><font color="#000000">for</font></u></b> (<b><font color="#000000">int</font></b> i = <font color="#000000">0</font>; i < <font color="#000000">5</font>; i++) - printf(<font color="#808080">"%d</font>\n<font color="#808080">"</font>, *(i + array)); -} -</pre> -<br /> -<h3 style='display: inline' id='5-variables-with-prefix-'>5. Variables with prefix <span class='inlinecode'>$</span></h3><br /> -<br /> -<span>In C you can prefix variables with <span class='inlinecode'>$</span>! E.g. the following is valid C code 🫠:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><b><u><font color="#000000">#include</font></u></b> <font color="#808080"><stdio.h></font> - -<b><font color="#000000">int</font></b> main(<b><font color="#000000">void</font></b>) { - <b><font color="#000000">int</font></b> $array[<font color="#000000">5</font>] = { <font color="#000000">1</font>, <font color="#000000">2</font>, <font color="#000000">3</font>, <font color="#000000">4</font>, <font color="#000000">5</font> }; - - <b><u><font color="#000000">for</font></u></b> (<b><font color="#000000">int</font></b> $i = <font color="#000000">0</font>; $i < <font color="#000000">5</font>; $i++) - printf(<font color="#808080">"%d</font>\n<font color="#808080">"</font>, $array[$i]); - - <b><u><font color="#000000">for</font></u></b> (<b><font color="#000000">int</font></b> $i = <font color="#000000">0</font>; $i < <font color="#000000">5</font>; $i++) - printf(<font color="#808080">"%d</font>\n<font color="#808080">"</font>, $i[$array]); - - <b><u><font color="#000000">for</font></u></b> (<b><font color="#000000">int</font></b> $i = <font color="#000000">0</font>; $i < <font color="#000000">5</font>; $i++) - printf(<font color="#808080">"%d</font>\n<font color="#808080">"</font>, *($i + $array)); -} -</pre> -<br /> -<h2 style='display: inline' id='6-object-oriented-shell-scripts-using-ksh'>6. Object oriented shell scripts using <span class='inlinecode'>ksh</span></h2><br /> -<br /> -<span>Experienced software developers are aware that scripting languages like Python, Perl, Ruby, and JavaScript support object-oriented programming (OOP) concepts such as classes and inheritance. However, many might be surprised to learn that the latest version of the Korn shell (Version 93t+) also supports OOP. In ksh93, OOP is implemented using user-defined types:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><i><font color="silver">#!/usr/bin/ksh93</font></i> - -<b><u><font color="#000000">typeset</font></u></b> -T Point_t=( - integer -h <font color="#808080">'x coordinate'</font> x=<font color="#000000">0</font> - integer -h <font color="#808080">'y coordinate'</font> y=<font color="#000000">0</font> - <b><u><font color="#000000">typeset</font></u></b> -h <font color="#808080">'point color'</font> color=<font color="#808080">"red"</font> - - function getcolor { - print -r ${_.color} - } - - function setcolor { - _.color=$1 - } - - setxy() { - _.x=$1; _.y=$2 - } - - getxy() { - print -r <font color="#808080">"(${_.x},${_.y})"</font> - } -) - -Point_t point - -echo <font color="#808080">"Initial coordinates are (${point.x},${point.y}). Color is ${point.color}"</font> - -point.setxy <font color="#000000">5</font> <font color="#000000">6</font> -point.setcolor blue - -echo <font color="#808080">"New coordinates are ${point.getxy}. Color is ${point.getcolor}"</font> - -<b><u><font color="#000000">exit</font></u></b> <font color="#000000">0</font> -</pre> -<br /> -<a class='textlink' href='https://blog.fpmurphy.com/2010/05/ksh93-using-types-to-create-object-orientated-scripts.html'>Using types to create object oriented Korn shell 93 scripts</a><br /> -<br /> -<h2 style='display: inline' id='7-this-works-in-go'>7. This works in Go</h2><br /> -<br /> -<span>There is no pointer arithmetic in Go like in C, but it is still possible to do some brain teasers with pointers 😧:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><b><u><font color="#000000">package</font></u></b> main - -<b><u><font color="#000000">import</font></u></b> <font color="#808080">"fmt"</font> - -<b><u><font color="#000000">func</font></u></b> main() { - <b><u><font color="#000000">var</font></u></b> i int - f := <b><u><font color="#000000">func</font></u></b>() *int { - <b><u><font color="#000000">return</font></u></b> &i - } - *f()++ - fmt.Println(i) -} -</pre> -<br /> -<a class='textlink' href='https://go.dev/play/p/sPRdyDvXefK?__s=mk8u899owb9yurl256gw'>Go playground</a><br /> -<br /> -<h2 style='display: inline' id='8-i-am-a-teapot-http-response-code'>8. "I am a Teapot" HTTP response code</h2><br /> -<br /> -<span>Defined in 1998 as one of the IETF's traditional April Fools' jokes (RFC 2324), the Hyper Text Coffee Pot Control Protocol specifies an HTTP status code that is not intended for actual HTTP server implementation. According to the RFC, this code should be returned by teapots when asked to brew coffee. This status code also serves as an Easter egg on some websites, such as Google.com's "I'm a teapot" feature. Occasionally, it is used to respond to a blocked request, even though the more appropriate response would be the 403 Forbidden status code.</span><br /> -<br /> -<a class='textlink' href='https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#418'>https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#418</a><br /> -<br /> -<h2 style='display: inline' id='9-jq-is-a-functional-programming-language'>9. <span class='inlinecode'>jq</span> is a functional programming language</h2><br /> -<br /> -<span>Many know of <span class='inlinecode'>jq</span>, the handy small tool and swiss army knife for JSON parsing. </span><br /> -<br /> -<a class='textlink' href='https://github.com/jqlang/jq'>https://github.com/jqlang/jq</a><br /> -<br /> -<span>What many don't know that <span class='inlinecode'>jq</span> is actually a full blown functional programming language <span class='inlinecode'>jqlang</span>, have a look at the language description: </span><br /> -<br /> -<a class='textlink' href='https://github.com/jqlang/jq/wiki/jq-Language-Description'>https://github.com/jqlang/jq/wiki/jq-Language-Description</a><br /> -<br /> -<span>As a matter of fact, the language is so powerful, that there exists an implementation of <span class='inlinecode'>jq</span> in <span class='inlinecode'>jq</span> itself:</span><br /> -<br /> -<a class='textlink' href='https://github.com/wader/jqjq'>https://github.com/wader/jqjq</a><br /> -<br /> -<span>Here some snipped from <span class='inlinecode'>jqjq</span>, to get a feel of <span class='inlinecode'>jqlang</span>:</span><br /> -<br /> -<pre> -def _token: - def _re($re; f): - ( . as {$remain, $string_stack} - | $remain - | match($re; "m").string - | f as $token - | { result: ($token | del(.string_stack)) - , remain: $remain[length:] - , string_stack: - ( if $token.string_stack == null then $string_stack - else $token.string_stack - end - ) - } - ); - if .remain == "" then empty - else - ( . as {$string_stack} - | _re("^\\s+"; {whitespace: .}) - // _re("^#[^\n]*"; {comment: .}) - // _re("^\\.[_a-zA-Z][_a-zA-Z0-9]*"; {index: .[1:]}) - // _re("^[_a-zA-Z][_a-zA-Z0-9]*"; {ident: .}) - // _re("^@[_a-zA-Z][_a-zA-Z0-9]*"; {at_ident: .}) - // _re("^\\$[_a-zA-Z][_a-zA-Z0-9]*"; {binding: .}) - # 1.23, .123, 123e2, 1.23e2, 123E2, 1.23e+2, 1.23E-2 or 123 - // _re("^(?:[0-9]*\\.[0-9]+|[0-9]+)(?:[eE][-\\+]?[0-9]+)?"; {number: .}) - // _re("^\"(?:[^\"\\\\]|\\\\.)*?\\\\\\("; - ( .[1:-2] - | _unescape - | {string_start: ., string_stack: ($string_stack+["\\("])} - ) - ) - . - . - . -</pre> -<br /> -<h2 style='display: inline' id='10-regular-expression-to-verify-email-addresses'>10. Regular expression to verify email addresses</h2><br /> -<br /> -<span>This is a pretty old meme, but still worth posting here (as some may be unaware). The RFC822 Perl regex to validate email addresses is 😱:</span><br /> -<br /> -<pre> -(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t] -)+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?: -\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:( -?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ -\t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0 -31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\ -](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+ -(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?: -(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z -|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n) -?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\ -r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ - \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n) -?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t] -)*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ - \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])* -)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t] -)+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*) -*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+ -|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r -\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?: -\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t -]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031 -]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\]( -?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(? -:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(? -:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(? -:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)? -[ \t]))*"(?:(?:\r\n)?[ \t])*)*:(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] -\000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]| -\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<> -@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|" -(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t] -)*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\ -".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(? -:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[ -\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000- -\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|( -?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,; -:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([ -^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\" -.\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\ -]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\ -[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\ -r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] -\000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\] -|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \0 -00-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\ -.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@, -;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(? -:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])* -(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\". -\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[ -^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\] -]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)(?:,\s*( -?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\ -".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:( -?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[ -\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t -])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t -])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(? -:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+| -\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?: -[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\ -]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n) -?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[" -()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n) -?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<> -@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ - \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@, -;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t] -)*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\ -".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)? -(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\". -\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?: -\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[ -"()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t]) -*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]) -+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\ -.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z -|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:( -?:\r\n)?[ \t])*))*)?;\s*) -</pre> -<br /> -<a class='textlink' href='https://pdw.ex-parrot.com/Mail-RFC822-Address.html'>https://pdw.ex-parrot.com/Mail-RFC822-Address.html</a><br /> -<br /> -<span>I hope you had some fun. E-Mail your comments to <span class='inlinecode'>paul@nospam.buetow.org</span> :-)</span><br /> -<br /> -<span>other related posts are:</span><br /> -<br /> -<a class='textlink' href='../'>Back to the main site</a><br /> - </div> - </content> - </entry> - <entry> - <title>Terminal multiplexing with `tmux` - Z-Shell edition</title> - <link href="gemini://foo.zone/gemfeed/2024-06-23-terminal-multiplexing-with-tmux.gmi" /> - <id>gemini://foo.zone/gemfeed/2024-06-23-terminal-multiplexing-with-tmux.gmi</id> - <updated>2024-06-23T22:41:59+03:00, last updated Fri 02 May 00:10:49 EEST 2025</updated> - <author> - <name>Paul Buetow aka snonux</name> - <email>paul@dev.buetow.org</email> - </author> - <summary>This is the Z-Shell version. There is also a Fish version:</summary> - <content type="xhtml"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h1 style='display: inline' id='terminal-multiplexing-with-tmux---z-shell-edition'>Terminal multiplexing with <span class='inlinecode'>tmux</span> - Z-Shell edition</h1><br /> -<br /> -<span class='quote'>Published at 2024-06-23T22:41:59+03:00, last updated Fri 02 May 00:10:49 EEST 2025</span><br /> -<br /> -<span>This is the Z-Shell version. There is also a Fish version:</span><br /> -<br /> -<a class='textlink' href='./2025-05-02-terminal-multiplexing-with-tmux-fish-edition.html'>./2025-05-02-terminal-multiplexing-with-tmux-fish-edition.html</a><br /> -<br /> -<span>Tmux (Terminal Multiplexer) is a powerful, terminal-based tool that manages multiple terminal sessions within a single window. Here are some of its primary features and functionalities:</span><br /> -<br /> -<ul> -<li>Session management</li> -<li>Window and Pane management</li> -<li>Persistent Workspace</li> -<li>Customization</li> -</ul><br /> -<a class='textlink' href='https://github.com/tmux/tmux/wiki'>https://github.com/tmux/tmux/wiki</a><br /> -<br /> -<pre> - _______ - |.-----.| - || Tmux|| - ||_.-._|| - `--)-(--` - __[=== o]___ - |:::::::::::|\ -jgs `-=========-`() - mod. by Paul B. -</pre> -<br /> -<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br /> -<br /> -<ul> -<li><a href='#terminal-multiplexing-with-tmux---z-shell-edition'>Terminal multiplexing with <span class='inlinecode'>tmux</span> - Z-Shell edition</a></li> -<li>⇢ <a href='#before-continuing'>Before continuing...</a></li> -<li>⇢ <a href='#shell-aliases'>Shell aliases</a></li> -<li>⇢ <a href='#the-tn-alias---creating-a-new-session'>The <span class='inlinecode'>tn</span> alias - Creating a new session</a></li> -<li>⇢ ⇢ <a href='#cleaning-up-default-sessions-automatically'>Cleaning up default sessions automatically</a></li> -<li>⇢ ⇢ <a href='#renaming-sessions'>Renaming sessions</a></li> -<li>⇢ <a href='#the-ta-alias---attaching-to-a-session'>The <span class='inlinecode'>ta</span> alias - Attaching to a session</a></li> -<li>⇢ <a href='#the-tr-alias---for-a-nested-remote-session'>The <span class='inlinecode'>tr</span> alias - For a nested remote session</a></li> -<li>⇢ ⇢ <a href='#change-of-the-tmux-prefix-for-better-nesting'>Change of the Tmux prefix for better nesting</a></li> -<li>⇢ <a href='#the-ts-alias---searching-sessions-with-fuzzy-finder'>The <span class='inlinecode'>ts</span> alias - Searching sessions with fuzzy finder</a></li> -<li>⇢ <a href='#the-tssh-alias---cluster-ssh-replacement'>The <span class='inlinecode'>tssh</span> alias - Cluster SSH replacement</a></li> -<li>⇢ ⇢ <a href='#the-tmuxtsshfromargument-helper'>The <span class='inlinecode'>tmux::tssh_from_argument</span> helper</a></li> -<li>⇢ ⇢ <a href='#the-tmuxtsshfromfile-helper'>The <span class='inlinecode'>tmux::tssh_from_file</span> helper</a></li> -<li>⇢ ⇢ <a href='#tssh-examples'><span class='inlinecode'>tssh</span> examples</a></li> -<li>⇢ ⇢ <a href='#common-tmux-commands-i-use-in-tssh'>Common Tmux commands I use in <span class='inlinecode'>tssh</span></a></li> -<li>⇢ <a href='#copy-and-paste-workflow'>Copy and paste workflow</a></li> -<li>⇢ <a href='#tmux-configurations'>Tmux configurations</a></li> -</ul><br /> -<h2 style='display: inline' id='before-continuing'>Before continuing...</h2><br /> -<br /> -<span>Before continuing to read this post, I encourage you to get familiar with Tmux first (unless you already know the basics). You can go through the official getting started guide:</span><br /> -<br /> -<a class='textlink' href='https://github.com/tmux/tmux/wiki/Getting-Started'>https://github.com/tmux/tmux/wiki/Getting-Started</a><br /> -<br /> -<span>I can also recommend this book (this is the book I got started with with Tmux):</span><br /> -<br /> -<a class='textlink' href='https://pragprog.com/titles/bhtmux2/tmux-2/'>https://pragprog.com/titles/bhtmux2/tmux-2/</a><br /> -<br /> -<span>Over the years, I have built a couple of shell helper functions to optimize my workflows. Tmux is extensively integrated into my daily workflows (personal and work). I had colleagues asking me about my Tmux config and helper scripts for Tmux several times. It would be neat to blog about it so that everyone interested in it can make a copy of my configuration and scripts.</span><br /> -<br /> -<span>The configuration and scripts in this blog post are only the non-work-specific parts. There are more helper scripts, which I only use for work (and aren't really useful outside of work due to the way servers and clusters are structured there).</span><br /> -<br /> -<span>Tmux is highly configurable, and I think I am only scratching the surface of what is possible with it. Nevertheless, it may still be useful for you. I also love that Tmux is part of the OpenBSD base system!</span><br /> -<br /> -<h2 style='display: inline' id='shell-aliases'>Shell aliases</h2><br /> -<br /> -<span>I am a user of the Z-Shell (<span class='inlinecode'>zsh</span>), but I believe all the snippets mentioned in this blog post also work with Bash. </span><br /> -<br /> -<a class='textlink' href='https://www.zsh.org'>https://www.zsh.org</a><br /> -<br /> -<span>For the most common Tmux commands I use, I have created the following shell aliases:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><b><u><font color="#000000">alias</font></u></b> tm=tmux -<b><u><font color="#000000">alias</font></u></b> tl=<font color="#808080">'tmux list-sessions'</font> -<b><u><font color="#000000">alias</font></u></b> tn=tmux::new -<b><u><font color="#000000">alias</font></u></b> ta=tmux::attach -<b><u><font color="#000000">alias</font></u></b> tx=tmux::remote -<b><u><font color="#000000">alias</font></u></b> ts=tmux::search -<b><u><font color="#000000">alias</font></u></b> tssh=tmux::cluster_ssh -</pre> -<br /> -<span>Note all <span class='inlinecode'>tmux::...</span>; those are custom shell functions doing certain things, and they aren't part of the Tmux distribution. But let's run through every alias one by one. </span><br /> -<br /> -<span>The first two are pretty straightforward. <span class='inlinecode'>tm</span> is simply a shorthand for <span class='inlinecode'>tmux</span>, so I have to type less, and <span class='inlinecode'>tl</span> lists all Tmux sessions that are currently open. No magic here.</span><br /> -<br /> -<h2 style='display: inline' id='the-tn-alias---creating-a-new-session'>The <span class='inlinecode'>tn</span> alias - Creating a new session</h2><br /> -<br /> -<span>The <span class='inlinecode'>tn</span> alias is referencing this function:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><i><font color="silver"># Create new session and if already exists attach to it</font></i> -tmux::new () { - <b><u><font color="#000000">readonly</font></u></b> session=$1 - <b><u><font color="#000000">local</font></u></b> date=date - <b><u><font color="#000000">if</font></u></b> where gdate &>/dev/null; <b><u><font color="#000000">then</font></u></b> - date=gdate - <b><u><font color="#000000">fi</font></u></b> - - tmux::cleanup_default - <b><u><font color="#000000">if</font></u></b> [ -z <font color="#808080">"$session"</font> ]; <b><u><font color="#000000">then</font></u></b> - tmux::new T$($date +%s) - <b><u><font color="#000000">else</font></u></b> - tmux new-session -d -s $session - tmux -<font color="#000000">2</font> attach-session -t $session || tmux -<font color="#000000">2</font> switch-client -t $session - <b><u><font color="#000000">fi</font></u></b> -} -<b><u><font color="#000000">alias</font></u></b> tn=tmux::new -</pre> -<br /> -<span>There is a lot going on here. Let's have a detailed look at what it is doing. As a note, the function relies on GNU Date, so MacOS is looking for the <span class='inlinecode'>gdate</span> commands to be available. Otherwise, it will fall back to <span class='inlinecode'>date</span>. You need to install GNU Date for Mac, as it isn't installed by default there. As I use Fedora Linux on my personal Laptop and a MacBook for work, I have to make it work for both.</span><br /> -<br /> -<span>First, a Tmux session name can be passed to the function as a first argument. That session name is only optional. Without it, Tmux will select a session named <span class='inlinecode'>T$($date +%s)</span> as a default. Which is T followed by the UNIX epoch, e.g. <span class='inlinecode'>T1717133796</span>.</span><br /> -<br /> -<h3 style='display: inline' id='cleaning-up-default-sessions-automatically'>Cleaning up default sessions automatically</h3><br /> -<br /> -<span>Note also the call to <span class='inlinecode'>tmux::cleanup_default</span>; it would clean up all already opened default sessions if they aren't attached. Those sessions were only temporary, and I had too many flying around after a while. So, I decided to auto-delete the sessions if they weren't attached. If I want to keep sessions around, I will rename them with the Tmux command <span class='inlinecode'>prefix-key $</span>. This is the cleanup function:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre>tmux::cleanup_default () { - <b><u><font color="#000000">local</font></u></b> s - tmux list-sessions | grep <font color="#808080">'^T.*: '</font> | grep -F -v attached | - cut -d: -f<font color="#000000">1</font> | <b><u><font color="#000000">while</font></u></b> <b><u><font color="#000000">read</font></u></b> -r s; <b><u><font color="#000000">do</font></u></b> - echo <font color="#808080">"Killing $s"</font> - tmux kill-session -t <font color="#808080">"$s"</font> - <b><u><font color="#000000">done</font></u></b> -} -</pre> -<br /> -<span>The cleanup function kills all open Tmux sessions that haven't been renamed properly yet—but only if they aren't attached (e.g., don't run in the foreground in any terminal). Cleaning them up automatically keeps my Tmux sessions as neat and tidy as possible. </span><br /> -<br /> -<h3 style='display: inline' id='renaming-sessions'>Renaming sessions</h3><br /> -<br /> -<span>Whenever I am in a temporary session (named <span class='inlinecode'>T....</span>), I may decide that I want to keep this session around. I have to rename the session to prevent the cleanup function from doing its thing. That's, as mentioned already, easily accomplished with the standard <span class='inlinecode'>prefix-key $</span> Tmux command.</span><br /> -<br /> -<h2 style='display: inline' id='the-ta-alias---attaching-to-a-session'>The <span class='inlinecode'>ta</span> alias - Attaching to a session</h2><br /> -<br /> -<span>This alias refers to the following function, which tries to attach to an already-running Tmux session.</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre>tmux::attach () { - <b><u><font color="#000000">readonly</font></u></b> session=$1 - - <b><u><font color="#000000">if</font></u></b> [ -z <font color="#808080">"$session"</font> ]; <b><u><font color="#000000">then</font></u></b> - tmux attach-session || tmux::new - <b><u><font color="#000000">else</font></u></b> - tmux attach-session -t $session || tmux::new $session - <b><u><font color="#000000">fi</font></u></b> -} -<b><u><font color="#000000">alias</font></u></b> ta=tmux::attach -</pre> -<br /> -<span>If no session is specified (as the argument of the function), it will try to attach to the first open session. If no Tmux server is running, it will create a new one with <span class='inlinecode'>tmux::new</span>. Otherwise, with a session name given as the argument, it will attach to it. If unsuccessful (e.g., the session doesn't exist), it will be created and attached to.</span><br /> -<br /> -<h2 style='display: inline' id='the-tr-alias---for-a-nested-remote-session'>The <span class='inlinecode'>tr</span> alias - For a nested remote session</h2><br /> -<br /> -<span>This SSHs into the remote server specified and then, remotely on the server itself, starts a nested Tmux session. So we have one Tmux session on the local computer and, inside of it, an SSH connection to a remote server with a Tmux session running again. The benefit of this is that, in case my network connection breaks down, the next time I connect, I can continue my work on the remote server exactly where I left off. The session name is the name of the server being SSHed into. If a session like this already exists, it simply attaches to it.</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre>tmux::remote () { - <b><u><font color="#000000">readonly</font></u></b> server=$1 - tmux new -s $server <font color="#808080">"ssh -t $server 'tmux attach-session || tmux'"</font> || \ - tmux attach-session -d -t $server -} -<b><u><font color="#000000">alias</font></u></b> tr=tmux::remote -</pre> -<br /> -<h3 style='display: inline' id='change-of-the-tmux-prefix-for-better-nesting'>Change of the Tmux prefix for better nesting</h3><br /> -<br /> -<span>To make nested Tmux sessions work smoothly, one must change the Tmux prefix key locally or remotely. By default, the Tmux prefix key is <span class='inlinecode'>Ctrl-b</span>, so <span class='inlinecode'>Ctrl-b $</span>, for example, renames the current session. To change the prefix key from the standard <span class='inlinecode'>Ctrl-b</span> to, for example, <span class='inlinecode'>Ctrl-g</span>, you must add this to the <span class='inlinecode'>tmux.conf</span>:</span><br /> -<br /> -<pre> -set-option -g prefix C-g -</pre> -<br /> -<span>This way, when I want to rename the remote Tmux session, I have to use <span class='inlinecode'>Ctrl-g $</span>, and when I want to rename the local Tmux session, I still have to use <span class='inlinecode'>Ctrl-b $</span>. In my case, I have this deployed to all remote servers through a configuration management system (out of scope for this blog post).</span><br /> -<br /> -<span>There might also be another way around this (without reconfiguring the prefix key), but that is cumbersome to use, as far as I remember. </span><br /> -<br /> -<h2 style='display: inline' id='the-ts-alias---searching-sessions-with-fuzzy-finder'>The <span class='inlinecode'>ts</span> alias - Searching sessions with fuzzy finder</h2><br /> -<br /> -<span>Despite the fact that with <span class='inlinecode'>tmux::cleanup_default</span>, I don't leave a huge mess with trillions of Tmux sessions flying around all the time, at times, it can become challenging to find exactly the session I am currently interested in. After a busy workday, I often end up with around twenty sessions on my laptop. This is where fuzzy searching for session names comes in handy, as I often don't remember the exact session names.</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre>tmux::search () { - <b><u><font color="#000000">local</font></u></b> -r session=$(tmux list-sessions | fzf | cut -d: -f<font color="#000000">1</font>) - <b><u><font color="#000000">if</font></u></b> [ -z <font color="#808080">"$TMUX"</font> ]; <b><u><font color="#000000">then</font></u></b> - tmux attach-session -t $session - <b><u><font color="#000000">else</font></u></b> - tmux switch -t $session - <b><u><font color="#000000">fi</font></u></b> -} -<b><u><font color="#000000">alias</font></u></b> ts=tmux::search -</pre> -<br /> -<span>All it does is list all currently open sessions in <span class='inlinecode'>fzf</span>, where one of them can be searched and selected through fuzzy find, and then either switch (if already inside a session) to the other session or attach to the other session (if not yet in Tmux).</span><br /> -<br /> -<span>You must install the <span class='inlinecode'>fzf</span> command on your computer for this to work. This is how it looks like:</span><br /> -<br /> -<a href='./terminal-multiplexing-with-tmux/tmux-session-fzf.png'><img alt='Tmux session fuzzy finder' title='Tmux session fuzzy finder' src='./terminal-multiplexing-with-tmux/tmux-session-fzf.png' /></a><br /> -<br /> -<h2 style='display: inline' id='the-tssh-alias---cluster-ssh-replacement'>The <span class='inlinecode'>tssh</span> alias - Cluster SSH replacement</h2><br /> -<br /> -<span>Before I used Tmux, I was a heavy user of ClusterSSH, which allowed me to log in to multiple servers at once in a single terminal window and type and run commands on all of them in parallel.</span><br /> -<br /> -<a class='textlink' href='https://github.com/duncs/clusterssh'>https://github.com/duncs/clusterssh</a><br /> -<br /> -<span>However, since I started using Tmux, I retired ClusterSSH, as it came with the benefit that Tmux only needs to be run in the terminal, whereas ClusterSSH spawned terminal windows, which aren't easily portable (e.g., from a Linux desktop to macOS). The <span class='inlinecode'>tmux::cluster_ssh</span> function can have N arguments, where:</span><br /> -<br /> -<ul> -<li>...the first argument will be the session name (see <span class='inlinecode'>tmux::tssh_from_argument</span> helper function), and all remaining arguments will be server hostnames/FQDNs to connect to simultaneously.</li> -<li>...or, the first argument is a file name, and the file contains a list of hostnames/FQDNs (see <span class='inlinecode'>tmux::ssh_from_file</span> helper function)</li> -</ul><br /> -<span>This is the function definition behind the <span class='inlinecode'>tssh</span> alias:</span><br /> -<span> </span><br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre>tmux::cluster_ssh () { - <b><u><font color="#000000">if</font></u></b> [ -f <font color="#808080">"$1"</font> ]; <b><u><font color="#000000">then</font></u></b> - tmux::tssh_from_file $1 - <b><u><font color="#000000">return</font></u></b> - <b><u><font color="#000000">fi</font></u></b> - - tmux::tssh_from_argument $@ -} -<b><u><font color="#000000">alias</font></u></b> tssh=tmux::cluster_ssh -</pre> -<br /> -<span>This function is just a wrapper around the more complex <span class='inlinecode'>tmux::tssh_from_file</span> and <span class='inlinecode'>tmux::tssh_from_argument</span> functions, as you have learned already. Most of the magic happens there.</span><br /> -<br /> -<h3 style='display: inline' id='the-tmuxtsshfromargument-helper'>The <span class='inlinecode'>tmux::tssh_from_argument</span> helper</h3><br /> -<br /> -<span>This is the most magic helper function we will cover in this post. It looks like this:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre>tmux::tssh_from_argument () { - <b><u><font color="#000000">local</font></u></b> -r session=$1; <b><u><font color="#000000">shift</font></u></b> - <b><u><font color="#000000">local</font></u></b> first_server=$1; <b><u><font color="#000000">shift</font></u></b> - - tmux new-session -d -s $session <font color="#808080">"ssh -t $first_server"</font> - <b><u><font color="#000000">if</font></u></b> ! tmux list-session | grep <font color="#808080">"^$session:"</font>; <b><u><font color="#000000">then</font></u></b> - echo <font color="#808080">"Could not create session $session"</font> - <b><u><font color="#000000">return</font></u></b> <font color="#000000">2</font> - <b><u><font color="#000000">fi</font></u></b> - - <b><u><font color="#000000">for</font></u></b> server <b><u><font color="#000000">in</font></u></b> <font color="#808080">"${@[@]}"</font>; <b><u><font color="#000000">do</font></u></b> - tmux split-window -t $session <font color="#808080">"tmux select-layout tiled; ssh -t $server"</font> - <b><u><font color="#000000">done</font></u></b> - - tmux setw -t $session synchronize-panes on - tmux -<font color="#000000">2</font> attach-session -t $session | tmux -<font color="#000000">2</font> switch-client -t $session -} -</pre> -<br /> -<span>It expects at least two arguments. The first argument is the session name to create for the clustered SSH session. All other arguments are server hostnames or FQDNs to which to connect. The first one is used to make the initial session. All remaining ones are added to that session with <span class='inlinecode'>tmux split-window -t $session...</span>. At the end, we enable synchronized panes by default, so whenever you type, the commands will be sent to every SSH connection, thus allowing the neat ClusterSSH feature to run commands on multiple servers simultaneously. Once done, we attach (or switch, if already in Tmux) to it.</span><br /> -<br /> -<span>Sometimes, I don't want the synchronized panes behavior and want to switch it off temporarily. I can do that with <span class='inlinecode'>prefix-key p</span> and <span class='inlinecode'>prefix-key P</span> after adding the following to my local <span class='inlinecode'>tmux.conf</span>:</span><br /> -<br /> -<pre> -bind-key p setw synchronize-panes off -bind-key P setw synchronize-panes on -</pre> -<br /> -<h3 style='display: inline' id='the-tmuxtsshfromfile-helper'>The <span class='inlinecode'>tmux::tssh_from_file</span> helper</h3><br /> -<br /> -<span>This one sets the session name to the file name and then reads a list of servers from that file, passing the list of servers to <span class='inlinecode'>tmux::tssh_from_argument</span> as the arguments. So, this is a neat little wrapper that also enables me to open clustered SSH sessions from an input file.</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre>tmux::tssh_from_file () { - <b><u><font color="#000000">local</font></u></b> -r serverlist=$1; <b><u><font color="#000000">shift</font></u></b> - <b><u><font color="#000000">local</font></u></b> -r session=$(basename $serverlist | cut -d. -f<font color="#000000">1</font>) - - tmux::tssh_from_argument $session $(awk <font color="#808080">'{ print $1} '</font> $serverlist | sed <font color="#808080">'s/.lan./.lan/g'</font>) -} -</pre> -<br /> -<h3 style='display: inline' id='tssh-examples'><span class='inlinecode'>tssh</span> examples</h3><br /> -<br /> -<span>To open a new session named <span class='inlinecode'>fish</span> and log in to 4 remote hosts, run this command (Note that it is also possible to specify the remote user):</span><br /> -<br /> -<pre> -$ tssh fish blowfish.buetow.org fishfinger.buetow.org \ - fishbone.buetow.org user@octopus.buetow.org -</pre> -<br /> -<span>To open a new session named <span class='inlinecode'>manyservers</span>, put many servers (one FQDN per line) into a file called <span class='inlinecode'>manyservers.txt</span> and simply run:</span><br /> -<br /> -<pre> -$ tssh manyservers.txt -</pre> -<br /> -<h3 style='display: inline' id='common-tmux-commands-i-use-in-tssh'>Common Tmux commands I use in <span class='inlinecode'>tssh</span></h3><br /> -<br /> -<span>These are default Tmux commands that I make heavy use of in a <span class='inlinecode'>tssh</span> session:</span><br /> -<br /> -<ul> -<li>Press <span class='inlinecode'>prefix-key DIRECTION</span> to switch panes. DIRECTION is by default any of the arrow keys, but I also configured Vi keybindings.</li> -<li>Press <span class='inlinecode'>prefix-key <space></span> to change the pane layout (can be pressed multiple times to cycle through them).</li> -<li>Press <span class='inlinecode'>prefix-key z</span> to zoom in and out of the current active pane.</li> -</ul><br /> -<h2 style='display: inline' id='copy-and-paste-workflow'>Copy and paste workflow</h2><br /> -<br /> -<span>As you will see later in this blog post, I have configured a history limit of 1 million items in Tmux so that I can scroll back quite far. One main workflow of mine is to search for text in the Tmux history, select and copy it, and then switch to another window or session and paste it there (e.g., into my text editor to do something with it).</span><br /> -<br /> -<span>This works by pressing <span class='inlinecode'>prefix-key [</span> to enter Tmux copy mode. From there, I can browse the Tmux history of the current window using either the arrow keys or vi-like navigation (see vi configuration later in this blog post) and the Pg-Dn and Pg-Up keys.</span><br /> -<br /> -<span>I often search the history backwards with <span class='inlinecode'>prefix-key [</span> followed by a <span class='inlinecode'>?</span>, which opens the Tmux history search prompt.</span><br /> -<br /> -<span>Once I have identified the terminal text to be copied, I enter visual select mode with <span class='inlinecode'>v</span>, highlight all the text to be copied (using arrow keys or Vi motions), and press <span class='inlinecode'>y</span> to yank it (sorry if this all sounds a bit complicated, but Vim/NeoVim users will know this, as it is pretty much how you do it there as well).</span><br /> -<br /> -<span>For <span class='inlinecode'>v</span> and <span class='inlinecode'>y</span> to work, the following has to be added to the Tmux configuration file: </span><br /> -<br /> -<pre> -bind-key -T copy-mode-vi 'v' send -X begin-selection -bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel -</pre> -<br /> -<span>Once the text is yanked, I switch to another Tmux window or session where, for example, a text editor is running and paste the yanked text from Tmux into the editor with <span class='inlinecode'>prefix-key ]</span>. Note that when pasting into a modal text editor like Vi or Helix, you would first need to enter insert mode before <span class='inlinecode'>prefix-key ]</span> would paste anything.</span><br /> -<br /> -<h2 style='display: inline' id='tmux-configurations'>Tmux configurations</h2><br /> -<br /> -<span>Some features I have configured directly in Tmux don't require an external shell alias to function correctly. Let's walk line by line through my local <span class='inlinecode'>~/.config/tmux/tmux.conf</span>:</span><br /> -<br /> -<pre> -source ~/.config/tmux/tmux.local.conf - -set-option -g allow-rename off -set-option -g history-limit 100000 -set-option -g status-bg '#444444' -set-option -g status-fg '#ffa500' -set-option -s escape-time 0 -</pre> -<br /> -<span>There's yet to be much magic happening here. I source a <span class='inlinecode'>tmux.local.conf</span>, which I sometimes use to override the default configuration that comes from the configuration management system. But it is mostly just an empty file, so it doesn't throw any errors on Tmux startup when I don't use it.</span><br /> -<br /> -<span>I work with many terminal outputs, which I also like to search within Tmux. So, I added a large enough <span class='inlinecode'>history-limit</span>, enabling me to search backwards in Tmux for any output up to a million lines of text.</span><br /> -<br /> -<span>Besides changing some colours (personal taste), I also set <span class='inlinecode'>escape-time</span> to <span class='inlinecode'>0</span>, which is just a workaround. Otherwise, my Helix text editor's <span class='inlinecode'>ESC</span> key would take ages to trigger within Tmux. I am trying to remember the gory details. You can leave it out; if everything works fine for you, leave it out.</span><br /> -<br /> -<span>The next lines in the configuration file are:</span><br /> -<br /> -<pre> -set-window-option -g mode-keys vi -bind-key -T copy-mode-vi 'v' send -X begin-selection -bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel -</pre> -<br /> -<span>I navigate within Tmux using Vi keybindings, so the <span class='inlinecode'>mode-keys</span> is set to <span class='inlinecode'>vi</span>. I use the Helix modal text editor, which is close enough to Vi bindings for simple navigation to feel "native" to me. (By the way, I have been a long-time Vim and NeoVim user, but I eventually switched to Helix. It's off-topic here, but it may be worth another blog post once.)</span><br /> -<br /> -<span>The two <span class='inlinecode'>bind-key</span> commands make it so that I can use <span class='inlinecode'>v</span> and <span class='inlinecode'>y</span> in copy mode, which feels more Vi-like (as already discussed earlier in this post).</span><br /> -<br /> -<span>The next set of lines in the configuration file are:</span><br /> -<br /> -<pre> -bind-key h select-pane -L -bind-key j select-pane -D -bind-key k select-pane -U -bind-key l select-pane -R - -bind-key H resize-pane -L 5 -bind-key J resize-pane -D 5 -bind-key K resize-pane -U 5 -bind-key L resize-pane -R 5 -</pre> -<br /> -<span>These allow me to use <span class='inlinecode'>prefix-key h</span>, <span class='inlinecode'>prefix-key j</span>, <span class='inlinecode'>prefix-key k</span>, and <span class='inlinecode'>prefix-key l</span> for switching panes and <span class='inlinecode'>prefix-key H</span>, <span class='inlinecode'>prefix-key J</span>, <span class='inlinecode'>prefix-key K</span>, and <span class='inlinecode'>prefix-key L</span> for resizing the panes. If you don't know Vi/Vim/NeoVim, the letters <span class='inlinecode'>hjkl</span> are commonly used there for left, down, up, and right, which is also the same for Helix, by the way.</span><br /> -<br /> -<span>The next set of lines in the configuration file are:</span><br /> -<br /> -<pre> -bind-key c new-window -c '#{pane_current_path}' -bind-key F new-window -n "session-switcher" "tmux list-sessions | fzf | cut -d: -f1 | xargs tmux switch-client -t" -bind-key T choose-tree -</pre> -<br /> -<span>The first one is that any new window starts in the current directory. The second one is more interesting. I list all open sessions in the fuzzy finder. I rely heavily on this during my daily workflow to switch between various sessions depending on the task. E.g. from a remote cluster SSH session to a local code editor. </span><br /> -<br /> -<span>The third one, <span class='inlinecode'>choose-tree</span>, opens a tree view in Tmux listing all sessions and windows. This one is handy to get a better overview of what is currently running in any local Tmux session. It looks like this (it also allows me to press a hotkey to switch to a particular Tmux window):</span><br /> -<br /> -<a href='./terminal-multiplexing-with-tmux/tmux-tree-view.png'><img alt='Tmux session tree view' title='Tmux session tree view' src='./terminal-multiplexing-with-tmux/tmux-tree-view.png' /></a><br /> -<br /> -<br /> -<span>The last remaining lines in my configuration file are:</span><br /> -<span> </span><br /> -<pre> -bind-key p setw synchronize-panes off -bind-key P setw synchronize-panes on -bind-key r source-file ~/.config/tmux/tmux.conf \; display-message "tmux.conf reloaded" -</pre> -<br /> -<span>We discussed <span class='inlinecode'>synchronized panes</span> earlier. I use it all the time in clustered SSH sessions. When enabled, all panes (remote SSH sessions) receive the same keystrokes. This is very useful when you want to run the same commands on many servers at once, such as navigating to a common directory, restarting a couple of services at once, or running tools like <span class='inlinecode'>htop</span> to quickly monitor system resources.</span><br /> -<br /> -<span>The last one reloads my Tmux configuration on the fly.</span><br /> -<br /> -<span>E-Mail your comments to <span class='inlinecode'>paul@nospam.buetow.org</span> :-)</span><br /> -<br /> -<span>Other related posts are:</span><br /> -<br /> -<a class='textlink' href='./2026-02-02-tmux-popup-editor-for-cursor-agent-prompts.html'>2026-02-02 A tmux popup editor for Cursor Agent CLI prompts</a><br /> -<a class='textlink' href='./2025-05-02-terminal-multiplexing-with-tmux-fish-edition.html'>2025-05-02 Terminal multiplexing with <span class='inlinecode'>tmux</span> - Fish edition</a><br /> -<a class='textlink' href='./2024-06-23-terminal-multiplexing-with-tmux.html'>2024-06-23 Terminal multiplexing with <span class='inlinecode'>tmux</span> - Z-Shell edition (You are currently reading this)</a><br /> -<br /> -<a class='textlink' href='../'>Back to the main site</a><br /> - </div> - </content> - </entry> - <entry> - <title>Projects I currently don't have time for</title> - <link href="gemini://foo.zone/gemfeed/2024-05-03-projects-i-currently-dont-have-time-for.gmi" /> - <id>gemini://foo.zone/gemfeed/2024-05-03-projects-i-currently-dont-have-time-for.gmi</id> - <updated>2024-05-03T16:23:03+03:00</updated> - <author> - <name>Paul Buetow aka snonux</name> - <email>paul@dev.buetow.org</email> - </author> - <summary>Over the years, I have collected many ideas for my personal projects and noted them down. I am currently in the process of cleaning up all my notes and reviewing those ideas. I don’t have time for the ones listed here and won’t have any soon due to other commitments and personal projects. So, in order to 'get rid of them' from my notes folder, I decided to simply put them in this blog post so that those ideas don't get lost. Maybe I will pick up one or another idea someday in the future, but for now, they are all put on ice in favor of other personal projects or family time.</summary> - <content type="xhtml"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h1 style='display: inline' id='projects-i-currently-don-t-have-time-for'>Projects I currently don't have time for</h1><br /> -<br /> -<span class='quote'>Published at 2024-05-03T16:23:03+03:00</span><br /> -<br /> -<span>Over the years, I have collected many ideas for my personal projects and noted them down. I am currently in the process of cleaning up all my notes and reviewing those ideas. I don’t have time for the ones listed here and won’t have any soon due to other commitments and personal projects. So, in order to "get rid of them" from my notes folder, I decided to simply put them in this blog post so that those ideas don't get lost. Maybe I will pick up one or another idea someday in the future, but for now, they are all put on ice in favor of other personal projects or family time.</span><br /> -<br /> -<pre> -Art by Laura Brown - -.'`~~~~~~~~~~~`'. -( .'11 12 1'. ) -| :10 \ 2: | -| :9 @-> 3: | -| :8 4; | -'. '..7 6 5..' .' - ~-------------~ ldb - -</pre> -<br /> -<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br /> -<br /> -<ul> -<li><a href='#projects-i-currently-don-t-have-time-for'>Projects I currently don't have time for</a></li> -<li>⇢ <a href='#hardware-projects-i-don-t-have-time-for'>Hardware projects I don't have time for</a></li> -<li>⇢ ⇢ <a href='#i-use-arch-btw'>I use Arch, btw!</a></li> -<li>⇢ ⇢ <a href='#openbsd-home-router'>OpenBSD home router</a></li> -<li>⇢ ⇢ <a href='#pi-hole-server'>Pi-Hole server</a></li> -<li>⇢ ⇢ <a href='#infodash'>Infodash</a></li> -<li>⇢ ⇢ <a href='#reading-station'>Reading station</a></li> -<li>⇢ ⇢ <a href='#retro-station'>Retro station</a></li> -<li>⇢ ⇢ <a href='#sound-server'>Sound server</a></li> -<li>⇢ ⇢ <a href='#project-freekat'>Project Freekat</a></li> -<li>⇢ <a href='#programming-projects-i-don-t-have-time-for'>Programming projects I don't have time for</a></li> -<li>⇢ ⇢ <a href='#cli-hive'>CLI-HIVE</a></li> -<li>⇢ ⇢ <a href='#enhanced-kiss-home-photo-albums'>Enhanced KISS home photo albums</a></li> -<li>⇢ ⇢ <a href='#kiss-file-sync-server-with-end-to-end-encryption'>KISS file sync server with end-to-end encryption</a></li> -<li>⇢ ⇢ <a href='#a-language-that-compiles-to-bash'>A language that compiles to <span class='inlinecode'>bash</span></a></li> -<li>⇢ ⇢ <a href='#a-language-that-compiles-to-sed'>A language that compiles to <span class='inlinecode'>sed</span></a></li> -<li>⇢ ⇢ <a href='#renovate-vs-sim'>Renovate VS-Sim</a></li> -<li>⇢ ⇢ <a href='#kiss-ticketing-system'>KISS ticketing system</a></li> -<li>⇢ ⇢ <a href='#a-domain-specific-language-dsl-for-work'>A domain-specific language (DSL) for work</a></li> -<li>⇢ <a href='#self-hosting-projects-i-don-t-have-time-for'>Self-hosting projects I don't have time for</a></li> -<li>⇢ ⇢ <a href='#my-own-matrix-server'>My own Matrix server</a></li> -<li>⇢ ⇢ <a href='#ampache-music-server'>Ampache music server</a></li> -<li>⇢ ⇢ <a href='#librum-ebook-reader'>Librum eBook reader</a></li> -<li>⇢ ⇢ <a href='#memos---note-taking-service'>Memos - Note-taking service</a></li> -<li>⇢ ⇢ <a href='#bepasty-server'>Bepasty server</a></li> -<li>⇢ <a href='#books-i-don-t-have-time-to-read'>Books I don't have time to read</a></li> -<li>⇢ ⇢ <a href='#fluent-python'>Fluent Python</a></li> -<li>⇢ ⇢ <a href='#programming-ruby'>Programming Ruby</a></li> -<li>⇢ ⇢ <a href='#peter-f-hamilton-science-fiction-books'>Peter F. Hamilton science fiction books</a></li> -<li>⇢ <a href='#new-websites-i-don-t-have-time-for'>New websites I don't have time for</a></li> -<li>⇢ ⇢ <a href='#create-a-why-raku-rox-site'>Create a "Why Raku Rox" site</a></li> -<li>⇢ <a href='#research-projects-i-don-t-have-time-for'>Research projects I don't have time for</a></li> -<li>⇢ ⇢ <a href='#project-secure'>Project secure</a></li> -<li>⇢ ⇢ <a href='#cpu-utilisation-is-all-wrong'>CPU utilisation is all wrong</a></li> -</ul><br /> -<h2 style='display: inline' id='hardware-projects-i-don-t-have-time-for'>Hardware projects I don't have time for</h2><br /> -<br /> -<h3 style='display: inline' id='i-use-arch-btw'>I use Arch, btw!</h3><br /> -<br /> -<span>The idea was to build the ultimate Arch Linux setup on an old ThinkPad X200 booting with the open-source LibreBoot firmware, complete with a tiling window manager, dmenu, and all the elite tools. This is mainly for fun, as I am pretty happy (and productive) with my Fedora Linux setup. I ran EndeavourOS (close enough to Arch) on an old ThinkPad for a while, but then I switched back to Fedora because the rolling releases were annoying (there were too many updates).</span><br /> -<br /> -<h3 style='display: inline' id='openbsd-home-router'>OpenBSD home router</h3><br /> -<br /> -<span>In my student days, I operated a 486DX PC with OpenBSD as my home DSL internet router. I bought the setup from my brother back then. The router's hostname was <span class='inlinecode'>fishbone</span>, and it performed very well until it became too slow for larger broadband bandwidth after a few years of use.</span><br /> -<br /> -<span>I had the idea to revive this concept, implement <span class='inlinecode'>fishbone2</span>, and place it in front of my proprietary ISP router to add an extra layer of security and control in my home LAN. It would serve as the default gateway for all of my devices, including a Wi-Fi access point, would run a DNS server, Pi-hole proxy, VPN client, and DynDNS client. I would also implement high availability using OpenBSD's CARP protocol.</span><br /> -<br /> -<a class='textlink' href='https://openbsdrouterguide.net'>https://openbsdrouterguide.net</a><br /> -<a class='textlink' href='https://pi-hole.net/'>https://pi-hole.net/</a><br /> -<a class='textlink' href='https://www.OpenBSD.org'>https://www.OpenBSD.org</a><br /> -<a class='textlink' href='https://www.OpenBSD.org/faq/pf/carp.html'>https://www.OpenBSD.org/faq/pf/carp.html</a><br /> -<br /> -<span>However, I am putting this on hold as I have opted for an OpenWRT-based solution, which was much quicker to set up and runs well enough.</span><br /> -<br /> -<a class='textlink' href='https://OpenWRT.org/'>https://OpenWRT.org/</a><br /> -<br /> -<h3 style='display: inline' id='pi-hole-server'>Pi-Hole server</h3><br /> -<br /> -<span>Install Pi-hole on one of my Pis or run it in a container on Freekat. For now, I am putting this on hold as the primary use for this would be ad-blocking, and I am avoiding surfing ad-heavy sites anyway. So there's no significant use for me personally at the moment.</span><br /> -<br /> -<a class='textlink' href='https://pi-hole.net/'>https://pi-hole.net/</a><br /> -<br /> -<h3 style='display: inline' id='infodash'>Infodash</h3><br /> -<br /> -<span>The idea was to implement my smart info screen using purely open-source software. It would display information such as the health status of my personal infrastructure, my current work tracker balance (I track how much I work to prevent overworking), and my sports balance (I track my workouts to stay within my quotas for general health). The information would be displayed on a small screen in my home office, on my Pine watch, or remotely from any terminal window.</span><br /> -<br /> -<span>I don't have this, and I haven't missed having it, so I guess it would have been nice to have it but not provide any value other than the "fun of tinkering."</span><br /> -<br /> -<h3 style='display: inline' id='reading-station'>Reading station</h3><br /> -<br /> -<span>I wanted to create the most comfortable setup possible for reading digital notes, articles, and books. This would include a comfy armchair, a silent barebone PC or Raspberry Pi computer running either Linux or *BSD, and an e-Ink display mounted on a flexible arm/stand. There would also be a small table for my paper journal for occasional note-taking. There are a bunch of open-source software available for PDF and ePub reading. It would have been neat, but I am currently using the most straightforward solution: a Kobo Elipsa 2E, which I can use on my sofa.</span><br /> -<br /> -<h3 style='display: inline' id='retro-station'>Retro station</h3><br /> -<br /> -<span>I had an idea to build a computer infused with retro elements. It wouldn't use actual retro hardware but would look and feel like a retro machine. I would call this machine HAL or Retron.</span><br /> -<br /> -<span>I would use an old ThinkPad laptop placed on a horizontal stand, running NetBSD, and attaching a keyboard from ModelFkeyboards. I use WindowMaker as a window manager and run terminal applications through Retro Term. For the monitor, I would use an older (black) EIZO model with large bezels.</span><br /> -<br /> -<a class='textlink' href='https://www.NetBSD.org'>https://www.NetBSD.org</a><br /> -<a class='textlink' href='https://www.modelfkeyboards.com'>https://www.modelfkeyboards.com</a><br /> -<a class='textlink' href='https://github.com/Swordfish90/cool-retro-term)'>https://github.com/Swordfish90/cool-retro-term)</a><br /> -<br /> -<span>The computer would occasionally be used to surf the Gemini space, take notes, blog, or do light coding. However, I have abandoned the project for now because there isn't enough space in my apartment, as my daughter will have a room for herself.</span><br /> -<br /> -<h3 style='display: inline' id='sound-server'>Sound server</h3><br /> -<br /> -<span>My idea involved using a barebone mini PC running FreeBSD with the Navidrome sound server software. I could remotely connect to it from my phone, workstation/laptop to listen to my music collection. The storage would be based on ZFS with at least two drives for redundancy. The app would run in a Linux Docker container under FreeBSD via Bhyve.</span><br /> -<br /> -<a class='textlink' href='https://github.com/navidrome/navidrome'>https://github.com/navidrome/navidrome</a><br /> -<a class='textlink' href='https://wiki.freebsd.org/bhyve'>https://wiki.freebsd.org/bhyve</a><br /> -<br /> -<h3 style='display: inline' id='project-freekat'>Project Freekat</h3><br /> -<br /> -<span>My idea involved purchasing the Meerkat mini PC from System76 and installing FreeBSD. Like the sound-server idea (see previous idea), it would run Linux Docker through Bhyve. I would self-host a bunch of applications on it:</span><br /> -<br /> -<ul> -<li>Wallabag</li> -<li>Ankidroid</li> -<li>Miniflux & Postgres</li> -<li>Audiobookshelf</li> -<li>...</li> -</ul><br /> -<span>All of this would be within my LAN, but the services would also be accessible from the internet through either Wireguard or SSH reverse tunnels to one of my OpenBSD VMs, for example:</span><br /> -<br /> -<ul> -<li><span class='inlinecode'>wallabag.awesome.buetow.org</span></li> -<li><span class='inlinecode'>ankidroid.awesome.buetow.org</span></li> -<li><span class='inlinecode'>miniflux.awesome.buetow.org</span></li> -<li><span class='inlinecode'>audiobookshelf.awesome.buetow.org</span></li> -<li>...</li> -</ul><br /> -<span>I am abandoning this project for now, as I am currently hosting my apps on AWS ECS Fargate under <span class='inlinecode'>*.cool.buetow.org</span>, which is "good enough" for the time being and also offers the benefit of learning to use AWS and Terraform, knowledge that can be applied at work.</span><br /> -<br /> -<a class='textlink' href='./2024-02-04-from-babylon5.buetow.org-to-.cloud.html'>My personal AWS setup</a><br /> -<br /> -<h2 style='display: inline' id='programming-projects-i-don-t-have-time-for'>Programming projects I don't have time for</h2><br /> -<br /> -<h3 style='display: inline' id='cli-hive'>CLI-HIVE</h3><br /> -<br /> -<span>This was a pet project idea that my brother and I had. The concept was to collect all shell history of all servers at work in a central place, apply ML/AI, and return suggestions for commands to type or allow a fuzzy search on all the commands in the history. The recommendations for the commands on a server could be context-based (e.g., past occurrences on the same server type). </span><br /> -<br /> -<span>You could decide whether to share your command history with others so they would receive better suggestions depending on which server they are on, or you could keep all the history private and secure. The plan was to add hooks into zsh and bash shells so that all commands typed would be pushed to the central location for data mining.</span><br /> -<br /> -<h3 style='display: inline' id='enhanced-kiss-home-photo-albums'>Enhanced KISS home photo albums</h3><br /> -<br /> -<span>I don't use third-party cloud providers such as Google Photos to store/archive my photos. Instead, they are all on a ZFS volume on my home NAS, with regular offsite backups taken. Thus, my project would involve implementing the features I miss most or finding a solution simple enough to host on my LAN:</span><br /> -<br /> -<ul> -<li>A feature I miss presents me with a random day from the past and some photos from that day. This project would randomly select a day and generate a photo album for me to view and reminisce about memories.</li> -<li>Another feature I miss is the ability to automatically deduplicate all the photos, as I am sure there are tons of duplicates on my NAS.</li> -<li>Auto-enhancing the photos (perhaps using ImageMagick?)</li> -<li>I already have a simple <span class='inlinecode'>photoalbum.sh</span> script that generates an album based on an input directory. However, it would be great also to have a timeline feature to enable browsing through different dates.</li> -</ul><br /> -<a class='textlink' href='./2023-10-29-kiss-static-web-photo-albums-with-photoalbum.sh.html'>KISS static web photo albums with <span class='inlinecode'>photoalbum.sh</span></a><br /> -<br /> -<h3 style='display: inline' id='kiss-file-sync-server-with-end-to-end-encryption'>KISS file sync server with end-to-end encryption</h3><br /> -<br /> -<span>I aimed to have a simple server to which I could sync notes and other documents, ensuring that the data is fully end-to-end encrypted. This way, only the clients could decrypt the data, while an encrypted copy of all the data would be stored on the server side. There are a few solutions (e.g., NextCloud), but they are bloated or complex to set up. </span><br /> -<br /> -<span>I currently use Syncthing for encrypted file sync across all my devices; however, the data is not end-to-end encrypted. It's a good-enough setup, though, as my Syncthing server is in my home LAN on an encrypted file system.</span><br /> -<br /> -<a class='textlink' href='https://syncthing.net'>https://syncthing.net</a><br /> -<br /> -<span>I also had the idea of using this as a pet project for work and naming it <span class='inlinecode'>Cryptolake</span>, utilizing post-quantum-safe encryption algorithms and a distributed data store.</span><br /> -<br /> -<h3 style='display: inline' id='a-language-that-compiles-to-bash'>A language that compiles to <span class='inlinecode'>bash</span></h3><br /> -<br /> -<span>I had an idea to implement a higher-level language with strong typing that could be compiled into native Bash code. This would make all resulting Bash scripts more robust and secure by default. The project would involve developing a parser, lexer, and a Bash code generator. I planned to implement this in Go.</span><br /> -<br /> -<span>I had previously implemented a tiny scripting language called Fype (For Your Program Execution), which could have served as inspiration.</span><br /> -<br /> -<a class='textlink' href='./2010-05-09-the-fype-programming-language.html'>The Fype Programming Language</a><br /> -<br /> -<h3 style='display: inline' id='a-language-that-compiles-to-sed'>A language that compiles to <span class='inlinecode'>sed</span></h3><br /> -<br /> -<span>This is similar to the previous idea, but the difference is that the language would compile into a sed script. Sed has many features, but the brief syntax makes scripts challenging to read. The higher-level language would mimic sed but in a form that is easier for humans to read.</span><br /> -<br /> -<h3 style='display: inline' id='renovate-vs-sim'>Renovate VS-Sim</h3><br /> -<br /> -<span>VS-Sim is an open-source simulator programmed in Java for distributed systems. VS-Sim stands for "Verteilte Systeme Simulator," the German translation for "Distributed Systems Simulator." The VS-Sim project was my diploma thesis at Aachen University of Applied Sciences.</span><br /> -<br /> -<a class='textlink' href='https://codeberg.org/snonux/vs-sim'>https://codeberg.org/snonux/vs-sim</a><br /> -<br /> -<span>The ideas I had was:</span><br /> -<br /> -<ul> -<li>Translate the project into English.</li> -<li>Modernise the Java codebase to be compatible with the latest JDK.</li> -<li>Make it compile to native binaries using GraalVM.</li> -<li>Distribute the project using AppImages.</li> -</ul><br /> -<span>I have put this project on hold for now, as I want to do more things in Go and fewer in Java in my personal time.</span><br /> -<br /> -<h3 style='display: inline' id='kiss-ticketing-system'>KISS ticketing system</h3><br /> -<br /> -<span>My idea was to program a KISS (Keep It Simple, Stupid) ticketing system for my personal use. However, I am abandoning this project because I now use the excellent Taskwarrior software. You can learn more about it at:</span><br /> -<br /> -<a class='textlink' href='https://taskwarrior.org/'>https://taskwarrior.org/</a><br /> -<br /> -<h3 style='display: inline' id='a-domain-specific-language-dsl-for-work'>A domain-specific language (DSL) for work</h3><br /> -<br /> -<span>At work, an internal service allocates storage space for our customers on our storage clusters. It automates many tasks, but many tweaks are accessible through APIs. I had the idea to implement a Ruby-based DSL that would make using all those APIs for ad-hoc changes effortless, e.g.:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre>Cluster :UK, :uk01 <b><u><font color="#000000">do</font></u></b> - Customer.C1A1.segments.volumes.each <b><u><font color="#000000">do</font></u></b> |volume| - puts volume.usage_stats - volume.move_off! <b><u><font color="#000000">if</font></u></b> volume.over_subscribed? - <b><u><font color="#000000">end</font></u></b> -<b><u><font color="#000000">end</font></u></b> -</pre> -<br /> -<span>I am abandoning this project because my workplace has stopped the annual pet project competition, and I have other more important projects to work on at the moment.</span><br /> -<br /> -<a class='textlink' href='./2022-04-10-creative-universe.html'>Creative universe (Work pet project contests)</a><br /> -<br /> -<h2 style='display: inline' id='self-hosting-projects-i-don-t-have-time-for'>Self-hosting projects I don't have time for</h2><br /> -<br /> -<h3 style='display: inline' id='my-own-matrix-server'>My own Matrix server</h3><br /> -<br /> -<span>I value privacy. It would be great to run my own Matrix server for communication within my family. I have yet to have time to look into this more closely.</span><br /> -<br /> -<a class='textlink' href='https://matrix.org'>https://matrix.org</a><br /> -<br /> -<h3 style='display: inline' id='ampache-music-server'>Ampache music server</h3><br /> -<br /> -<span>Ampache is an open-source music streaming server that allows you to host and manage your music collection online, accessible via a web interface. Setting it up involves configuring a web server, installing Ampache, and organising your music files, which can be time-consuming. </span><br /> -<br /> -<h3 style='display: inline' id='librum-ebook-reader'>Librum eBook reader</h3><br /> -<br /> -<span>Librum is a self-hostable e-book reader that allows users to manage and read their e-book collection from a web interface. Designed to be a self-contained platform where users can upload, organise, and access their e-books, Librum emphasises privacy and control over one's digital library.</span><br /> -<br /> -<a class='textlink' href='https://github.com/Librum-Reader/Librum'>https://github.com/Librum-Reader/Librum</a><br /> -<br /> -<span>I am using my Kobo devices or my laptop to read these kinds of things for now.</span><br /> -<br /> -<h3 style='display: inline' id='memos---note-taking-service'>Memos - Note-taking service</h3><br /> -<br /> -<span>Memos is a note-taking service that simplifies and streamlines information capture and organisation. It focuses on providing users with a minimalistic and intuitive interface, aiming to enhance productivity without the clutter commonly associated with more complex note-taking apps.</span><br /> -<br /> -<a class='textlink' href='https://www.usememos.com'>https://www.usememos.com</a><br /> -<br /> -<span>I am abandoning this idea for now, as I am currently using plain Markdown files for notes and syncing them with Syncthing across my devices.</span><br /> -<br /> -<h3 style='display: inline' id='bepasty-server'>Bepasty server</h3><br /> -<br /> -<span>Bepasty is like a Pastebin for all kinds of files (text, image, audio, video, documents, binary, etc.). It seems very neat, but I only share a little nowadays. When I do, I upload files via SCP to one of my OpenBSD VMs and serve them via vanilla httpd there, keeping it KISS.</span><br /> -<br /> -<a class='textlink' href='https://github.com/bepasty/bepasty-server'>https://github.com/bepasty/bepasty-server</a><br /> -<br /> -<h2 style='display: inline' id='books-i-don-t-have-time-to-read'>Books I don't have time to read</h2><br /> -<br /> -<h3 style='display: inline' id='fluent-python'>Fluent Python</h3><br /> -<br /> -<span>I consider myself an advanced programmer in Ruby, Bash, and Perl. However, Python seems to be ubiquitous nowadays, and most of my colleagues prefer Python over any other languages. Thus, it makes sense for me to also learn and use Python. After conducting some research, "Fluent Python" appears to be the best book for this purpose.</span><br /> -<br /> -<span>I don't have time to read this book at the moment, as I am focusing more on Go (Golang) and I know just enough Python to get by (e.g., for code reviews). Additionally, there are still enough colleagues around who can review my Ruby or Bash code.</span><br /> -<br /> -<h3 style='display: inline' id='programming-ruby'>Programming Ruby</h3><br /> -<br /> -<span>I've read a couple of Ruby books already, but "Programming Ruby," which covers up to Ruby 3.2, was just recently released. I would like to read this to deepen my Ruby knowledge further and to revisit some concepts that I may have forgotten.</span><br /> -<br /> -<span>As stated in this blog post, I am currently more eager to focus on Go, so I've put the Ruby book on hold. Additionally, there wouldn't be enough colleagues who could "understand" my advanced Ruby skills anyway, as most of them are either Java developers or SREs who don't code a lot.</span><br /> -<br /> -<h3 style='display: inline' id='peter-f-hamilton-science-fiction-books'>Peter F. Hamilton science fiction books</h3><br /> -<br /> -<span>I am a big fan of science fiction, but my reading list is currently too long anyway. So, I've put the Hamilton books on the back burner for now. You can see all the novels I've read here:</span><br /> -<br /> -<a class='textlink' href='https://paul.buetow.org/novels.html'>https://paul.buetow.org/novels.html</a><br /> -<a class='textlink' href='gemini://paul.buetow.org/novels.gmi'>gemini://paul.buetow.org/novels.gmi</a><br /> -<br /> -<br /> -<h2 style='display: inline' id='new-websites-i-don-t-have-time-for'>New websites I don't have time for</h2><br /> -<br /> -<h3 style='display: inline' id='create-a-why-raku-rox-site'>Create a "Why Raku Rox" site</h3><br /> -<br /> -<span>The website "Why Raku Rox" would showcase the unique features and benefits of the Raku programming language and highlight why it is an exceptional choice for developers. Raku, originally known as Perl 6, is a dynamic, expressive language designed for flexible and powerful software development.</span><br /> -<br /> -<span>This would be similar to the "Why OpenBSD rocks" site:</span><br /> -<br /> -<a class='textlink' href='https://why-openbsd.rocks'>https://why-openbsd.rocks</a><br /> -<a class='textlink' href='https://raku.org'>https://raku.org</a><br /> -<br /> -<span>I am not working on this for now, as I currently don’t even have time to program in Raku.</span><br /> -<br /> -<h2 style='display: inline' id='research-projects-i-don-t-have-time-for'>Research projects I don't have time for</h2><br /> -<br /> -<h3 style='display: inline' id='project-secure'>Project secure</h3><br /> -<br /> -<span>For work: Implement a PoC that dumps Java heaps to extract secrets from memory. Based on the findings, write a Java program that encrypts secrets in the kernel using the <span class='inlinecode'>memfd_secret()</span> syscall to make it even more secure.</span><br /> -<br /> -<a class='textlink' href='https://lwn.net/Articles/865256/'>https://lwn.net/Articles/865256/</a><br /> -<br /> -<span>Due to other priorities, I am putting this on hold for now. The software we have built is pretty damn secure already!</span><br /> -<br /> -<h3 style='display: inline' id='cpu-utilisation-is-all-wrong'>CPU utilisation is all wrong</h3><br /> -<br /> -<span>This research project, based on Brendan Gregg's blog post, could potentially significantly impact my work.</span><br /> -<br /> -<a class='textlink' href='https://brendangregg.com/blog/2017-05-09/cpu-utilization-is-wrong.html'>https://brendangregg.com/blog/2017-05-09/cpu-utilization-is-wrong.html</a><br /> -<br /> -<span>The research project would involve setting up dashboards that display actual CPU usage and the cycles versus waiting time for memory access.</span><br /> -<br /> -<span>E-Mail your comments to <span class='inlinecode'>paul@nospam.buetow.org</span> :-)</span><br /> -<br /> -<span>Related and maybe interesting:</span><br /> -<br /> -<a class='textlink' href='./2022-06-15-sweating-the-small-stuff.html'>Sweating the small stuff - Tiny projects of mine</a><br /> -<br /> -<a class='textlink' href='../'>Back to the main site</a><br /> - </div> - </content> - </entry> </feed> |
