Thursday, 19 March 2026

Digesting Networking Concepts From Beej's Guide Using Claude's Explaination - Lesson 2



LESSON 2 — IP Addresses, Ports, and Identity


Part 1 — The Problem of Identity on a Network

For data to travel from one machine to another, two questions must be answered with absolute precision:

  1. Which machine? — Out of billions of connected devices, which exact one?
  2. Which program on that machine? — Your machine runs dozens of programs simultaneously. Which one should receive this data?

IP addresses answer question 1. Port numbers answer question 2. Together they form a complete address for a network endpoint.


Part 2 — IP Addresses (IPv4)

What an IP Address Actually Is

An IPv4 address is a 32-bit number. That's it. 32 ones and zeroes.

But 32 ones and zeroes are hard for humans to read, so we represent it as four groups of 8 bits (called octets), each converted to decimal, separated by dots.

Binary:   11000000 . 10101000 . 00000001 . 00000101
Decimal:    192    .   168    .    1     .    5
Human:              192.168.1.5

Each octet can be 0–255 (because 8 bits can represent 2⁸ = 256 values, 0 to 255).

Total possible IPv4 addresses: 2³² = 4,294,967,296 (about 4.3 billion)

The Critical Architectural Insight About 4.3 Billion

In the 1970s and 80s when IPv4 was designed, 4.3 billion addresses seemed impossibly large. There were only a few thousand computers on the entire Internet.

The designers made a decision that seemed perfectly reasonable at the time: they allocated huge blocks of addresses generously to organizations. MIT got 16 million addresses. Apple got 16 million. The US Department of Defense got 16 million times 13. Ford, GE, IBM, HP — all got enormous blocks.

By the 2000s, it was clear we were running out. Today every phone, tablet, laptop, smart TV, IoT device needs an address. We've dealt with the shortage through NAT (which we'll cover), but the fundamental problem remained.

This is why IPv6 was invented.


Part 3 — IPv6 — The Solution to Address Exhaustion

What IPv6 Actually Is

IPv6 addresses are 128-bit numbers. Four times the bits of IPv4.

But 96 extra bits isn't just "a bit more space." Because addresses grow exponentially with bits:

IPv4:  2³²  = 4,294,967,296 addresses (4.3 billion)
IPv6:  2¹²⁸ = 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses

That's 340 undecillion addresses. 340 followed by 36 zeros. Every square millimeter of Earth's surface could have billions of addresses. Every grain of sand. Every atom.

We will never run out.

How IPv6 Addresses Are Written

Because 128 bits in decimal would be unreadable, IPv6 uses hexadecimal, grouped into 8 chunks of 16 bits (2 bytes each), separated by colons:

Full form:   2001:0db8:c9d2:aee5:73e3:934a:a5ae:9551

Two compression rules exist to shorten addresses:

Rule 1: Leading zeros in each group can be dropped:

2001:0db8:0012:0000  →  2001:db8:12:0

Rule 2: One consecutive run of all-zero groups can be replaced with :::

2001:0db8:0000:0000:0000:0000:0000:0051  →  2001:db8::51

You can only use :: once per address (otherwise you couldn't tell how many zero groups it represents).

Special IPv6 Addresses You Must Know

::1          →  Loopback address (equivalent to 127.0.0.1 in IPv4)
             →  Always means "this machine itself"

::           →  All zeros — used to mean "any address" (like 0.0.0.0 in IPv4)

::ffff:192.0.2.33  →  IPv4-mapped IPv6 address
                   →  Represents an IPv4 address in IPv6 notation

The Loopback Address — Why It Matters

The loopback address (127.0.0.1 in IPv4, ::1 in IPv6) is special. Data sent to this address never leaves your machine. It goes through the network stack but loops back to the same machine.

This is invaluable for development — you can run a server and client on the same machine and test them talking to each other without needing a real network.


Part 4 — Subnets — How Networks Are Organized

The Problem Subnets Solve

An IP address identifies a specific machine. But a network has structure — there are groups of machines (like all machines in one office, or one department, or one country). How do you express that structure?

Subnets divide the IP address into two parts:

  • The network portion — identifies which network (shared by all machines in that network)
  • The host portion — identifies which specific machine within that network

The Netmask

netmask (or subnet mask) tells you which bits of the IP address are the network portion and which are the host portion.

IP Address:  192.168.1.5
             11000000.10101000.00000001.00000101

Netmask:     255.255.255.0
             11111111.11111111.11111111.00000000

The netmask has 1s where the network bits are and 0s where the host bits are.

To find the network address, you AND the IP address with the netmask:

  11000000.10101000.00000001.00000101   (192.168.1.5)
& 11111111.11111111.11111111.00000000   (255.255.255.0)
= 11000000.10101000.00000001.00000000   (192.168.1.0)

So 192.168.1.5 is host 5 on network 192.168.1.0.

CIDR Notation — The Modern Way

Writing out the full netmask is verbose. CIDR (Classless Inter-Domain Routing) notation just counts the number of 1-bits in the netmask:

192.168.1.5/24   →  24 bits of network, 8 bits of host
                 →  256 possible host addresses on this network
                 →  Same as netmask 255.255.255.0

10.0.0.1/8       →  8 bits of network, 24 bits of host
                 →  16 million possible hosts on this network

2001:db8::/32    →  IPv6 subnet with 32-bit network prefix

Why You Need to Know This

As a Software Architect, you'll design systems where you need to understand whether two machines are on the same network (can communicate directly) or different networks (need to go through a router). Subnet knowledge is essential for understanding network topology, firewall rules, and cloud infrastructure (AWS VPCs, subnets, security groups all use this directly).


Part 5 — Port Numbers — The Second Half of Identity

The Problem Ports Solve

An IP address gets data to the right machine. But your machine is running many programs simultaneously — a web browser, a code editor, a Slack client, a database, your own server. How does the operating system know which program should receive incoming data?

Port numbers solve this. A port is a 16-bit number (0–65535) that identifies a specific process/service on a machine.

The complete address of a network endpoint is therefore:

IP Address + Port Number = Socket Address

Example:  192.168.1.5:80
          └───────────┘ └┘
          Which machine  Which program

This combination (IP + Port) is called a socket address or endpoint.

Well-Known Ports

The Internet Assigned Numbers Authority (IANA) maintains a list of standard port assignments:

Port 20, 21  →  FTP (file transfer)
Port 22      →  SSH (secure shell)
Port 23      →  Telnet
Port 25      →  SMTP (email sending)
Port 53      →  DNS (domain name lookup)
Port 80      →  HTTP (web)
Port 443     →  HTTPS (secure web)
Port 3306    →  MySQL database
Port 5432    →  PostgreSQL database
Port 6379    →  Redis
Port 27017   →  MongoDB

Ports 0–1023 are reserved — only privileged processes (root/admin) can bind to them. This is why you can't run a web server on port 80 without root access.

Ports 1024–49151 are registered ports — can be used by user applications, many are assigned to known services.

Ports 49152–65535 are ephemeral (dynamic) ports — the OS automatically assigns these to client-side connections. When your browser connects to a server on port 80, your browser itself gets a random high port (like 54832) for the other side of the conversation.

The Full Picture of a Connection

A TCP connection is uniquely identified by four values:

Source IP     + Source Port     (your machine, ephemeral port)
Destination IP + Destination Port (server, well-known port)

Example:
  192.168.1.5:54832  →  93.184.216.34:80

This 4-tuple uniquely identifies this connection in the entire network.

This is why a server can handle thousands of connections all to port 80 simultaneously — each connection has a different source IP + port combination, making each 4-tuple unique.


Part 6 — NAT — The Hidden Architecture of the Modern Internet

The Problem NAT Solves

With only 4.3 billion IPv4 addresses and billions of devices, we ran out. But we couldn't just replace IPv4 overnight — too much infrastructure depended on it. NAT (Network Address Translation) was invented as a stopgap measure that ended up defining how most of the world's Internet works.

How NAT Works

Your home router has one public IP address (assigned by your ISP). Behind it, all your home devices have private IP addresses from a reserved range that is not routable on the public Internet.

Private IP ranges (RFC 1918):
  10.0.0.0    –  10.255.255.255    (10.x.x.x)
  172.16.0.0  –  172.31.255.255   (172.16-31.x.x)
  192.168.0.0 –  192.168.255.255  (192.168.x.x)

These addresses are never routed on the public Internet. Every home network in the world can use 192.168.1.x — no conflict, because they're all private.

When your laptop (192.168.1.5) makes a request to google.com:

Your laptop:
  Sends packet: FROM 192.168.1.5:54832  TO 142.250.80.46:443

Your router (NAT):
  Records the mapping: 192.168.1.5:54832 ↔ public_ip:random_port
  Rewrites packet:     FROM 203.0.113.1:61234  TO 142.250.80.46:443
  Sends it out

Google responds:
  Sends packet: FROM 142.250.80.46:443  TO 203.0.113.1:61234

Your router (NAT):
  Looks up its table: 203.0.113.1:61234 → 192.168.1.5:54832
  Rewrites packet:    FROM 142.250.80.46:443  TO 192.168.1.5:54832
  Delivers to your laptop

Google only ever sees your router's public IP. Your laptop's private IP is completely hidden.

The Architectural Implications of NAT

NAT has profound implications you'll encounter as an architect:

Servers cannot initiate connections to NAT'd devices — the router has no mapping for unsolicited incoming connections. This is why you can't just connect to a computer on someone's home network from the Internet. This is what "being behind a NAT" means.

Peer-to-peer is hard — when both parties are behind NAT, neither can initiate to the other directly. Techniques like STUN, TURN, and ICE exist to work around this (used in WebRTC, video calling).

IPv6 eliminates the need for NAT — every device gets a globally routable address. This is one of IPv6's major benefits beyond just more addresses.


Part 7 — Byte Order — The Hidden War Inside Your CPU

The Problem

When you store a multi-byte number in memory, which byte do you store first?

Consider the number 0xb34f (hexadecimal). It's two bytes: 0xb3 and 0x4f. When storing these two bytes in memory at addresses 1000 and 1001, which goes where?

Different CPU architectures made different choices:

Big-Endian (Network Byte Order):
  Address 1000: 0xb3  (most significant byte first)
  Address 1001: 0x4f

Little-Endian (Intel x86, x64, ARM in most modes):
  Address 1000: 0x4f  (least significant byte first)
  Address 1001: 0xb3

Big-Endian stores the most significant byte at the lowest address — the "big end" first. Like writing numbers left to right in decimal — the most significant digit comes first.

Little-Endian stores the least significant byte first. Intel processors do this. Most consumer computers today are little-endian.

Why This Matters for Networking

The Internet standardized on Big-Endian as the Network Byte Order. This decision was made so that all machines on the Internet agree on how to interpret multi-byte numbers in packet headers.

If you're on an Intel machine (little-endian) and you put the number 3490 directly into a packet header without conversion, the bytes will be in the wrong order. The receiving machine will read a completely different number.

The Conversion Functions

The C sockets API provides four functions to convert between host byte order and network byte order:

htons()  →  Host TO Network Short  (16-bit)
htonl()  →  Host TO Network Long   (32-bit)
ntohs()  →  Network TO Host Short  (16-bit)
ntohl()  →  Network TO Host Long   (32-bit)

The rule is simple and absolute:

  • Any multi-byte number going into a packet → convert with hton*()
  • Any multi-byte number coming out of a packet → convert with ntoh*()

On a big-endian machine these functions do nothing (it's already in the right order). On a little-endian machine they swap the bytes. You always call them regardless of your machine — that's what makes your code portable.

Port 3490 in host byte order (little-endian Intel):
  Memory: 0xa2 0x0d  (3490 = 0x0DA2, stored as 0xA2 0x0D)

After htons(3490) — Network Byte Order:
  Memory: 0x0d 0xa2  (big-endian: most significant first)

Lessons 1 & 2 — Master Summary

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
LESSON 1 — WHAT IS A NETWORK?

Problem solved:    Moving data between machines reliably
Solution:          Agreed protocols organized in layers

Four layers:
  Application    →  your code
  Transport      →  TCP (reliable) | UDP (fast)
  Internet       →  IP (routing)
  Network Access →  physical bits

Data encapsulation:
  Each layer adds its header going DOWN the stack
  Each layer strips its header coming UP the stack
  Layers are opaque to each other

TCP:  connection + handshake + ordered + reliable + slower
UDP:  connectionless + fire-and-forget + fast + unreliable

Sockets: the API boundary between your app and the network

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
LESSON 2 — IDENTITY ON A NETWORK

IP Address:   32-bit (IPv4) or 128-bit (IPv6) number
              Identifies which MACHINE

IPv4:         4.3 billion addresses, running out
IPv6:         340 undecillion addresses, never running out
              Written in hex groups: 2001:db8::1
              ::1 = loopback | :: = any address

Subnet:       Network portion + Host portion of IP address
              Netmask tells you where the split is
              CIDR: /24 means 24 bits are network portion
              AND (IP, netmask) = network address

Port:         16-bit number
              Identifies which PROGRAM on the machine
              0–1023: reserved (need root)
              1024–49151: registered
              49152–65535: ephemeral (auto-assigned to clients)

Full address: IP + Port = Socket Address (endpoint)
Connection:   identified by 4-tuple:
              (src_ip, src_port, dst_ip, dst_port)

NAT:          Router translates private IPs to one public IP
              Private ranges: 10.x.x.x, 172.16-31.x.x,
                              192.168.x.x
              Implication: servers can't initiate to NAT'd devices

Byte Order:
  Big-Endian    = Network Byte Order (Internet standard)
  Little-Endian = Intel/most consumer CPUs
  htons/htonl   = Host → Network (use before sending)
  ntohs/ntohl   = Network → Host (use after receiving)
  Always call these. No exceptions.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━


Digesting Networking Concepts From Beej's Guide Using Claude's Explaination - Lesson 1



LESSON 1 — What is a Network, Really?


Part 1 — The Fundamental Problem

Let's go to absolute first principles.

A computer is, at its core, a machine that processes data. But data trapped on one machine is limited in value. The moment you connect machines together, the value multiplies enormously. You can share files, send messages, stream video, run distributed systems.

But connecting machines creates an immediate problem: how does data find its way from one machine to another, across potentially thousands of miles, through thousands of intermediate devices, reliably and correctly?

This is not a simple problem. Think about what needs to be solved:

  • How does data know where to go?
  • How does data get physically moved from machine to machine?
  • What if the path between two machines has multiple routes?
  • What if data gets lost or corrupted along the way?
  • How does the destination machine know which application the data belongs to?
  • How do two machines that have never met before agree on how to communicate?

The entire field of networking is the answer to these questions. And every concept in Beej's guide — every struct, every system call, every function — is a direct solution to one of them.

Keep this principle always: Every networking concept exists because there was a real, specific problem that needed solving. Nothing in networking is arbitrary.


Part 2 — The Postal System Analogy (High Level)

Before diving into technical depth, lock in the intuition.

Imagine a global postal system. To send a letter:

You need your friend's address — specific enough that the letter reaches exactly the right building, exactly the right apartment. You need a postal network — trucks, planes, sorting facilities, delivery workers — all operating by agreed rules. You need a common format — everyone writes addresses the same way, uses the same envelope format, follows the same rules.

Now map this to networks:

Postal World Network World
Street address IP Address
Apartment number Port number
Postal rules & format Protocol (TCP/UDP)
Postal network infrastructure The Internet
The letter itself Data packet
Postal worker who delivers Router
Your mailbox Socket

A network is a postal system for data. This analogy will keep serving you as concepts get more complex.


Part 3 — Layers. The Architecture That Changed Everything.

This is the single most important architectural concept in all of networking. Understand this deeply and everything else becomes obvious.

The Problem Layers Solve

Imagine building a network without layers. You'd have to rebuild everything from scratch for every application. Your web browser would have to know how to handle Ethernet cables. Your email client would need to know about WiFi protocols. Every application would need to understand every possible physical medium data might travel on.

That's insane. It would mean millions of redundant implementations, every application rewriting the same low-level code, and any change to physical hardware breaking every application simultaneously.

Layers solve this by dividing responsibilities cleanly. Each layer does one job, exposes a clean interface upward, and doesn't care about the internal workings of other layers.

The Unix/Internet Layer Model

┌──────────────────────────────────────────────────────┐
│               APPLICATION LAYER                      │
│                                                      │
│  What lives here: Your program, HTTP, FTP, SSH,      │
│  DNS, SMTP, your custom chat protocol                │
│                                                      │
│  Its job: Define what data means and how             │
│  applications communicate with each other            │
│                                                      │
│  What it knows: Nothing about routing, nothing       │
│  about physical wires. Just: "I want to send         │
│  this data to that address"                          │
├──────────────────────────────────────────────────────┤
│          HOST-TO-HOST TRANSPORT LAYER                │
│                                                      │
│  What lives here: TCP, UDP                           │
│                                                      │
│  Its job: Get data from one program to another       │
│  program across a network                            │
│                                                      │
│  TCP guarantees: ordered delivery, error checking,   │
│  re-transmission of lost data                        │
│                                                      │
│  UDP guarantees: nothing. Fast, fire and forget      │
│                                                      │
│  What it knows: Source and destination PORT          │
│  numbers. Breaks data into segments.                 │
├──────────────────────────────────────────────────────┤
│               INTERNET LAYER                         │
│                                                      │
│  What lives here: IP (Internet Protocol)             │
│                                                      │
│  Its job: Route data from one machine to another     │
│  machine anywhere on the planet                      │
│                                                      │
│  What it knows: Source and destination IP            │
│  ADDRESSES. Breaks data into packets.                │
│                                                      │
│  Critical insight: IP is UNRELIABLE by design.       │
│  It makes best-effort delivery. TCP sits on top      │
│  of IP and adds reliability.                         │
├──────────────────────────────────────────────────────┤
│            NETWORK ACCESS LAYER                      │
│                                                      │
│  What lives here: Ethernet, WiFi, fiber optic,       │
│  cellular, Bluetooth                                 │
│                                                      │
│  Its job: Move raw bits across a physical medium     │
│  from one device to the next (hop by hop)            │
│                                                      │
│  What it knows: MAC addresses (hardware addresses    │
│  of physical network interfaces)                     │
└──────────────────────────────────────────────────────┘

The Critical Insight About Layers

You, as an application programmer, live entirely in the top layer.

The operating system handles the Transport and Internet layers. The hardware and device drivers handle the Network Access layer. You never write code to route packets. You never write code to manage Ethernet frames.

Sockets are the exact boundary between your application layer and everything below it. They are the interface the operating system provides so your application can use the network without knowing anything about how the network physically works.

This is profound architecturally. It means:

  • Your application works on WiFi, Ethernet, fiber, cellular — without changing a single line of code
  • Your application works on IPv4 or IPv6 — with minimal changes
  • The OS can change its internal networking implementation — your application doesn't notice

This is the power of layered abstraction.


Part 4 — Data Encapsulation

This is how layers actually communicate. It's one of the most elegant designs in all of computer science.

The Wrapping Process (Sending)

When your application sends data, it travels downward through the layers. Each layer adds its own header — a small block of metadata that tells that layer's counterpart on the receiving machine what to do.

STEP 1 — Your application has data:

  [ "Hello Bob" ]

STEP 2 — Transport layer (TCP) adds its header:
  Contains: source port, destination port, sequence number,
            checksum, flags (SYN, ACK, FIN etc.)

  [ TCP HEADER | "Hello Bob" ]

STEP 3 — Internet layer (IP) adds its header:
  Contains: source IP address, destination IP address,
            protocol type, TTL (time to live), checksum

  [ IP HEADER | TCP HEADER | "Hello Bob" ]

STEP 4 — Network Access layer (Ethernet) adds its header AND footer:
  Contains: source MAC address, destination MAC address,
            frame type. Footer contains CRC error check.

  [ ETH HEADER | IP HEADER | TCP HEADER | "Hello Bob" | ETH FOOTER ]

This complete bundle is called a frame at the Ethernet level, a packet at the IP level, a segment at the TCP level, and a message at the application level. These are precise technical terms.

The Unwrapping Process (Receiving)

On the destination machine, the data travels upward through layers. Each layer reads and strips only its own header.

Ethernet layer receives frame:
  Checks ETH HEADER — is this for me? (checks MAC address)
  Checks ETH FOOTER — is data corrupted? (CRC check)
  Strips ETH HEADER and FOOTER
  Passes [ IP HEADER | TCP HEADER | "Hello Bob" ] up to IP layer

IP layer receives packet:
  Checks IP HEADER — is this IP address mine?
  Strips IP HEADER
  Passes [ TCP HEADER | "Hello Bob" ] up to TCP layer

TCP layer receives segment:
  Checks TCP HEADER — which port? sequence number correct?
  Strips TCP HEADER
  Passes [ "Hello Bob" ] up to your application

Your application receives:
  "Hello Bob"  ✓

Why This Is Architecturally Beautiful

Notice that no layer looks inside another layer's data. IP doesn't know what TCP is doing. TCP doesn't know what your application is saying. Each layer is completely opaque to its neighbors.

This means:

  • You can run any application protocol over TCP without modifying TCP
  • You can run TCP over any physical medium without modifying TCP
  • You can replace any layer independently without breaking the others

This is the principle of separation of concerns applied to an entire global infrastructure. It's one of the best architectural decisions ever made.


Part 5 — TCP vs UDP 

Both TCP and UDP live in the Transport layer. Both use IP underneath. But they make fundamentally different design tradeoffs.

TCP — Transmission Control Protocol

TCP solves the problem: "IP is unreliable. How do I build reliable communication on top of it?"

TCP establishes a connection before any data flows. This connection setup is called the three-way handshake:

Client                          Server
  |                               |
  |  ——— SYN ——————————————————>  |   "I want to connect"
  |                               |
  |  <—— SYN-ACK ———————————————  |   "OK, I acknowledge, I'm ready"
  |                               |
  |  ——— ACK ——————————————————>  |   "Great, starting now"
  |                               |
  |  === DATA FLOWS BOTH WAYS ==  |

After the handshake, TCP guarantees:

Ordered delivery — TCP numbers every byte sent (sequence numbers). If packets arrive out of order, TCP reorders them before giving data to your application.

Reliable delivery — The receiver sends acknowledgments (ACKs) back. If the sender doesn't get an ACK within a timeout, it re-sends that data.

Error detection — Every segment has a checksum. Corrupted data is detected and discarded (then re-sent).

Flow control — TCP prevents a fast sender from overwhelming a slow receiver. The receiver advertises how much buffer space it has (window size).

Congestion control — TCP detects network congestion and slows down to avoid making it worse.

All of this comes at a cost: overhead and latency. There are acknowledgments flying back and forth. There's the handshake before data can flow. There's waiting for re-transmission if something is lost.

Use TCP when: you cannot afford to lose a single byte. Web pages (HTTP/HTTPS), file transfers (FTP), email (SMTP), login sessions (SSH), databases, banking.

UDP — User Datagram Protocol

UDP solves a different problem: "Sometimes reliability overhead is unacceptable. How do I send data as fast as possible?"

UDP has no connection, no handshake, no acknowledgments, no re-transmission, no ordering guarantee.

You put data in a packet and fire it. That's all UDP does. It adds a minimal header (source port, destination port, length, checksum) and hands it to IP.

Sender                           Receiver
  |                               |
  |  ——— PACKET 1 ————————————>  |   arrives ✓
  |  ——— PACKET 2 ————————————>  |   lost ✗  (nobody knows, nobody cares)
  |  ——— PACKET 3 ————————————>  |   arrives ✓
  |  ——— PACKET 4 ————————————>  |   arrives before packet 3 ✓ (out of order)

The receiver has no idea packet 2 was lost. No re-transmission happens. The application has to deal with gaps if it cares.

Use UDP when: latency matters more than completeness. Video calls (a dropped frame is better than a frozen screen waiting for re-transmission), online games (position updates — a missed one is fine, the next one is coming in 16ms anyway), DNS lookups (small, fast, re-send if no reply), live audio streaming, IoT sensors.

The Architectural Decision Framework

Does your application need every byte, in order, guaranteed?
  YES → TCP
  NO  → Can your application handle missing or out-of-order data?
          YES → UDP (and write your own reliability if needed)
          NO  → TCP

Note: Some applications build their own reliability on top of UDP when they need both speed and some degree of reliability but with custom behavior. QUIC (used in HTTP/3) does exactly this.


Lesson 1 — Complete Summary

WHAT IS A NETWORK?
  A system that moves data between machines by agreed rules

WHY LAYERS?
  Clean separation of concerns
  Each layer has one job
  Layers are independently replaceable
  Application programmers only live in the top layer

THE FOUR LAYERS (Unix/Internet model)
  Application    → your code, what data means
  Transport      → TCP (reliable) or UDP (fast)
  Internet       → IP, routing across machines
  Network Access → physical transmission of bits

DATA ENCAPSULATION
  Each layer wraps data with its own header going DOWN
  Each layer unwraps its own header coming UP
  No layer reads another layer's data

TCP vs UDP
  TCP  → connection, handshake, ordered, reliable, slower
  UDP  → connectionless, fire-and-forget, fast, unreliable

SOCKETS
  The API boundary between your app and the network layers
  The OS provides sockets so your app can use the network
  without knowing anything about physical infrastructure


Sunday, 10 March 2024

Who Am I?

 Yes, you read it right I have been asking the same question all my life. To myself my dear ones and to what do you call it? "acquaintance" I meet in my life. However, I feel someday I would get time to write all the things I have known or heard back. Till then let me procrastinate.

Saturday, 1 January 2022

Amazon Web Services

To understand AWS, it's very important that you know what exactly is cloud environment. 

This environment is something which you can think of as an operating system or say your Personal Computer.

Just like your PC which have it's own memory and CPU for computing and running a program or an application similarly the program needs the same kind of environment (think instances) to run the application. Depending upon your need you can configure and install the same over cloud. So basically, We are going to buy a computer which is going to run our application and then the same can be used by multiple users & process their requests. The capacity can be increased or reduced depending on the need. 

Now coming back to AWS, as you already know it's Amazon Web Services and is mainly used for availing cloud computing services.

The basic terminologies which you will often come across are:

EC2 - Elastic Compute Cloud -> Just think of it as instance which can be configured as per the size requirement of CPU and processing power needed for the Operating System.

RDS - Relational Database Service -> Just think of it as memory which will be used to store your program, files, images etc.

S3 - This also can be used to store large files.

Cloudwatch - To monitor your instance and it's activity.


Saturday, 28 August 2021

Git Tutorial

First up, for you to push and pull the code you'll need a github account and also git installed on your system. If that's done continue reading -

• Go to the project top most folder and on right click you will see 'open gitbash here'.

• Type git init

• Now, in your github account, At the top right of any of the page, you should see a '+' icon. Click on that and Select 'New Repository'. After giving it a name click on 'Create Repository'.

• You will see a page titled 'Quick Setup'

• Copy the link in input right beneath the title, which looks like https://github.com/yourepo/repo.git

• Go back to command line on your system and type - git remote add origin [copied link]

Ex: git remote add origin https://github.com/yourepo/repo.git

• Push your branch by typing - git push origin master

• That's it you're done.

 

Thursday, 8 April 2021

Easiest Git Tutorial

First up, most probably you will want to contribute to the already existing repository. And I'm assuming you might have done all the id creation and git installation steps.

Basically you wil be using these set of commands:

• Go to the repository and copy it's link from "Add Code" section.

• Go to the folder where you want to create the local copy and open git bash by right clicking.

• Write command ->  git clone <url you copied>

• Now you'll be having your repo in your folder get inside the same.

• Now you can either create a branch to separately add your code or you can commit your code their itself.

• Most probably you'll be creating branch. 

• For creating branch get inside the repository which got cloned and then open git bash.

• Write command ->  git checkout -b "Branch Name"

• Now you write your changes and commit it their in your branch 

• For commiting the changes you must make sure that you are on the branch where you want the changes to be committed by you.

° If not on branch, type -> git checkout <branch name>

• Now at first send your changes to the staging area so as to be committed by typing -> git add .

• Now commit using -> git commit -m "Some message"

• Now before pushing your changes make sure you are having the latest pull from the base/master branch. For doing the same go to branch base/master by typing -> git checkout <master>

• Get all latest changes -> git pull

• Now again switch back to your branch by typing git checkout <your branch >

• Now merge your code with the master branch so as to take the latest changes on your branch by typing  -> git merge master 

• If there exists any merge conflict rectify it by opening your editor and making the necessary changes and then again add and commit it by following the above commiting steps.

•  Finally push the changes you did by typing ->
git push origin <branch where you want to merge>

• That's it done. 

• Hope you liked it :) 

Tuesday, 10 July 2018

Storage Classes In C

Variables in C has a storage class and a scope. The storage class identifies the part of memory where storage is allocated for an object/variable which is declared & defined.It defines how long the storage allocation continues to exist. It also determines the scope which specifies the part of the program over which a variable name is visible, i.e. the variable is accessible by name. There are four storage classes in C:

* automatic: Used with auto keyword in local scope.Initializes with garbage values if not defined.

* register: Used for frequently used variables.Initializes with zero if not defined.

* external: Used for global scope.Initialized with zero If not defined.

* static: Used for retaining the value during function calls.Initializes with garbage values if not defined.

Thursday, 30 March 2017

Need is to develop an intellect crowd instead of searching

With sudden urge inside the society, it seems people are interested in the click to know more section since they have no work to do neither they have the ability to control their guts. Well, people have some set of gut feelings which all of a sudden can change their perception about any of the things present around them.

We can use this urge as a resource for one kind and development(if experimented repeatedly) For example let's take some set of students who are looking to understand and express their opinion about things and their thought.One can be developed as an asset for the future as he/she tends to help the surrounding around and explore the beauty of nature filled with magic.

At least give a try at things to a child who is showing some interest it really can be beneficial in the long run.Help people know their secret to learn more about.It really would help them know about their ability to realize their potential.

Make sprints about the working culture so that knowledge sharing groups can be found in much ease.

Today i came across an internship fair to learn about internship schemes and requirements and i assume companies will try to understand that the internship leads to brain development in a guided path and they can guide people in  best possible manner.

Saturday, 12 November 2016

First of mine.

So now when I have started writing it i gotta be telling you how it came to writing.
There was a time back in school when I used to write each and everyday though with poor or no sense( though i am continuing it now because i have no clue what the reaction would be ).
My life has been exhalirating and there is not even a single evidence in my life where i could prove I'm better( though i still feel it ) than else.
Infact I'm writing now to re read it. Because i don't know whether I'm going to post it or not.Anyways back to the point of me introducing myself. I am Ravi Raj. I hail from one of the most diverse place in the world. I study computer science. I read a lot and all you will know in this blog is how I plan everything in my mind while i read anything.

The first thing which i want to tell you about is i am a big tech enthusiast though i don't own an iPhone or Alienware kinda gadgets because of you know? student issues. I have learnt so many things but i don't know how i am going to tell you what i am thinking inside  *Pease don't forgive me if i do  something wrong* because i really want to express the best of mine.Having assured this let me end it. So that you can wait and i can exaggerate.I would be telling you atleast one story everyday till i die. You may like it or may kill me so that i stop writing. Thanks.