Category Archives: 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.

Continue reading Illustrating Binary Countdown Protocol with C++ Program

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.

Continue reading Git Add

Git Status

git status shows you the current state of your working directory and staging area — which files are tracked, which have been modified, which are staged for the next commit, and which Git doesn’t know about at all. It’s the command I run more than any other Git command, usually right before deciding what to do next. This is the sixth post in this site’s Git command guide, following Git Commit.

Continue reading Git Status

Git Log

git log displays the commit history of a repository — author, date, commit hash, and message, in reverse chronological order with the most recent commit first. It’s the command I reach for whenever I need to answer “who changed this and when,” and it has far more useful flags than the bare command suggests. This is the eleventh post in this site’s Git command guide, following Git Pull.

Continue reading Git Log