← Back to list

BASICS OF NETWORKING & SOCKET CONNECTION

1.Networking

Athul Anand · 2026-04-07 07:43 · 0 claps · 3.0 min read
#networking #sockets #tcp #udp #tcpdump
Open on Medium ↗
Wiki topics: 🔒 · Cybersecurity

BASICS OF NETWORKING & SOCKET CONNECTION

1.Networking

  • Networking is the process of connecting devices to exchange data.
  • Networking = connecting devices + sharing data + accessing resources
  • Basic Terms:
  • Node : Any device connected to a network
  • Packet : A packet is a small unit of data send over a network.
  • Bandwidth : Maximum data transfer capacity of a network.
  • Latency : Time delay in data transfer.

2.OSI MODEL

  • Open System Interconnection Model
  • 7 Layer Framework

7. Application → HTTP, FTP, Browser

6. Presentation → Encryption (SSL/TLS)

5. Session → Session handling

4. Transport → TCP / UDP

3. Network → IP Routing

2. Data Link → MAC Address

1. Physical → Cable / Signals

Layers

Physical :Deals Physical transmission of data.

Data Link : Handles node to node delivery.

Network : Handles routing & addressing.

Transport : Ensures realiable data delivery.

Session : Manages Sessions(start,maintain,end).

Presentation : Encrypts/Decrypts data.

Application : Network services to application.

3.Data Flow

  • Sending Side:
  • Application → Presentation → Session → Transport → Network →Data Link → Physical.
  • Receiving Side:
  • Physical → Data Link → Network → Transport →Session → →Presentation → Application.
  • This process is called Encapsulation & Decapsulation.

4.Protocols

  • A set of rules that define how data is transmitted between devices.
  • Ensures proper communication, format, and error handling.
  • Key Functions :
  • Data formatting
  • Error detection
  • Flow control
  • Addressing
  • Protocol Stack Example :
  • Application → HTTP
  • Transport → TCP
  • Network → IP
  • Data Link → Ethernet

5.TCP vs UDP

Transmission Control Protocol(TCP)

  • Establishes a connection before sending data
  • Ensures data reaches correctly
  • Maintains order of packets
  • Retransmits lost data

How TCP works ?

  • Connection setup (3-way handshake)
  • Data transfer (with ACK)
  • Retransmit if packet lost
  • Connection close

3-way handshake

It is the process used by TCP to establish a connection between client and server before sending data.

  1. SYN (Client → Server) : Client sends a request to start communication.
  2. SYN-ACK (Server → Client) : Server acknowledges and agrees.
  3. ACK (Client → Server) : Client confirms connection.

User Datagram Protocol(UDP)

  • Sends data without connection
  • No guarantee of delivery
  • No order checking
  • No retransmission

How UDP works ?

  • Send data → No checking → Done

6.SOCKET

  • Endpoint of communication between two machines over a network.
  • Identification of socket
  • 192.168.1.10:8080
  • Connects application to network.

Server Flow

  • socket() → bind() → listen() → accept()

Client Flow

  • socket() → connect()

Communication

  • send() and recv()

Full duplex communication.

Used in:

  • Web servers
  • APIs
  • IoT devices
  • Embedded systems (your domain)\

Types of Sockets :

  • TCP Socket (SOCK_STREAM)
  • UDP Socket (SOCK_DGRAM)

Server

  • socket()
  • bind()
  • listen()
  • accept()

Client

  • socket()
  • connect()

TCP Server

  • socket() : Creates communication endpoint
  • bind() : Attaches socket to -> IP addressPort number
  • listen() : Server waits for connections
  • accept() : Accepts client connection and creates new socket for communication

TCP client

  • socket() : Creates communication endpoint
  • connect() : Client connects to server
  • send() / recv() : Data exchange happens here=
  • close() :Releases socket

6.Debugging Tools

  • tcpdump & Wireshark

tcpdump

  • CLI packet capture tool.
  • Used in embedded/Linux systems.
  • Example : tcpdump -i br-lan

Wireshark

  • GUI packet analyzer.
  • Deep packet inspection.

UseCases :

  • Check packet flow.
  • Debug connectivity issues.
  • Analyze protocol behavior.

7.OpenWRT

  • OpenWRT = an open-source Linux-based operating system for networking devices.

why openwrt?

  • we can modify :Network configs, Firewall rules, WiFi behavior
  • Package System : Uses opkg
  • Install features like: tcpdump, luci (web UI)
  • Embedded Friendly
  • Runs on: Routers, IoT devices, Industrial devices.

Device Boot

  • Boot → Kernel → Network Init → Interfaces up.

Interfaces created:

  • br-lan
  • eth0
  • wlan0

Key Components

  • dnsmasq → DHCP + DNS
  • firewall → traffic control
  • hostapd → WiFi
  • br-lan is LAN bridge.
  • NAT used for internet access.(convert private IP addresses into a public IP address)
  • Firewall rules control traffic.

Conclusion

Networking is the backbone of modern communication systems, enabling devices to exchange data efficiently using well-defined protocols. The OSI model helps us understand how data flows across different layers, from physical transmission to application-level interaction.

Protocols like TCP and UDP play a crucial role in ensuring reliable or fast communication depending on the use case. TCP provides secure and ordered communication, while UDP enables fast, lightweight data transfer.

Sockets act as the bridge between applications and the network, allowing client-server communication. Through system calls like socket(), bind(), connect(), send(), and recv(), we can build real-world communication systems such as web servers, APIs, and embedded device communication.

In embedded environments like OpenWRT, networking concepts become even more practical. Components like br-lan, firewall, dnsmasq, and hostapd work together to manage connectivity, routing, and security.

Debugging tools such as tcpdump and Wireshark are essential for analyzing packet flow, troubleshooting issues, and understanding protocol behavior in real time.

Overall, a strong understanding of networking fundamentals and socket programming is critical for designing, debugging, and optimizing communication systems, especially in embedded and IoT domains.


메타데이터
post_id
fa337aa3d964
slug
basics-of-networking-socket-connection-fa337aa3d964
url
https://medium.com/@athul.anand/basics-of-networking-socket-connection-fa337aa3d964
canonical_url
https://medium.com/@athul.anand/basics-of-networking-socket-connection-fa337aa3d964
author_url
https://medium.com/@athul.anand
status
ok
fetched_at
2026-06-14 11:28:49