Skip to main content

Snippets

Illustrating Binary Countdown Protocol with C++ Program

The Binary Countdown Protocol is a contention-resolution MAC (Medium Access Control) protocol used on shared broadcast channels. When multiple stations want to transmit simultaneously, each station broadcasts its address as a binary number, bit by bit from the most significant bit (MSB) downward. Stations with a 0 bit at a position where another station has a 1 bit drop out of the contention. The station whose complete binary address survives the entire comparison wins the channel and transmits its frame. This guarantees that the station with the highest binary address always wins each contention round. This C++ program simulates the Binary Countdown Protocol. Each frame is treated as an 8-bit binary number. The program converts each frame to its decimal equivalent (which represents the station’s binary address), then announces the frames in descending priority order — highest decimal value first — as they would be granted channel access.

Git Add . (All)

git add . stages all changes in the current directory and everything below it — modified files, new files, and deleted files — in a single command. It's the fastest way to prepare everything for a commit when you want the full working-directory state captured. This is the fourth post in this site's Git command guide, following Git Add.

Git Commit

git commit saves your staged changes to the local repository as a permanent snapshot. It creates a new commit object with a unique identifier based on the changes made, along with a message that describes them. This is the fifth post in this site's Git command guide, following Git Add . (All).

Git Add

git add is the command that stages changes from your working directory into Git's index, marking them to be included in the next commit. Staging is an intermediate step that gives you precise control — you can add one file at a time, leaving other modified files unstaged until a later commit. This is the third post in this site's Git command guide, following Git Clone.

Git Clone

git clone copies an entire remote repository locally. This guide covers shallow clones with --depth, cloning specific branches, submodules, SSH vs HTTPS, and fixing a Permission denied (publickey) error.

Git Status

git status shows modified, staged, and untracked files in your repository. This guide covers the short format (-s), how .gitignore interacts with status output, and a full status-code reference table.

Git Log

git log displays commit history. This guide covers --oneline --graph --all for compact history, git log -p for diffs, filtering by author and date, and a flag reference table.

Git Branch

git branch lists, creates, renames, and deletes branches. This guide covers renaming master to main with -m, the difference between -d and -D, and a reference table of common flags.

Git Checkout

git checkout switches branches and restores files. This guide covers detached HEAD state and the checkout vs switch vs restore split introduced in Git 2.23, with a side-by-side comparison table.

Git Pull

git pull fetches and merges remote changes. This guide covers the divergent branches reconciliation warning, setting pull.rebase and pull.ff, and a merge-vs-rebase comparison table.