When writing the networking related code or implementing protocols yourself, please make sure there is a particular order for ip addresses, ports etc when sending bytes out to the network and recieving bytes from the network. Otherwise you can misinterpret the things pretty easily.
There are utilities function like ntohl ( network to host ) or htonl ( host to network ).
Okay so how does DORA look like:
dhcp discover
Client -------------------> Server
dhcp offer
Client <------------------ Server
dhcp request
Client --------------------> Server
dhcp ack/nack
Client <--------------------- Server
What's the need for dhcp request after server sends dhcp offer?
Because multiple DHCP servers might have replied with different offers, this single message serves two purposes at once: it confirms the lease with the chosen server and politely declines any other servers.
Micro is one of the most unorganised platform I have ever worked with. Best are turing and mercor.
While working with micro, you will feel lost because no one is monitoring anything, no program manager, not aware what to do etc...
micro1 is aggressively hiring; if your AI Interview is left, complete it today!
Company name: micro1
Batch Eligible: All college students + Working Professionals
Salary: $60 - $120 per hour
Location: Remote (Work From Home)
Apply now : https://t.co/D0zKzegy0u
Do share with your Friends and Juniors too!
GDB is a very powerful tool, you must have it under your belt if you code in c.
Today while debugging dhcp offer in c, I did a small mistake and could not parse that properly in dhcp client.
Attached the dhcp client with gdb and checked the values individually and pointed out the bug was pointer arithmetic.
You're a FOOL if you're learning NETWORKING and still can't troubleshoot these 19 problems: ๐
1. No Internet
Check IP, default gateway, and DNS.
2. Website Not Loading
Check DNS, connectivity, and HTTP response.
3. DNS Not Resolving
Test with nslookup or dig.
4. High Latency
Inspect RTT and network congestion.
5. Packet Loss
Check interfaces, links, and congestion.
6. Port Not Reachable
Check firewall rules and listening services.
7. IP Address Conflict
Look for duplicate IP assignments.
8. DHCP Failure
Check leases, scopes, and DHCP availability.
9. Wrong Subnet Mask
Verify the local network range.
10. Gateway Unreachable
Check routing and local connectivity.
11. TCP Connection Timeout
Inspect routes, firewalls, and server availability.
12. Connection Refused
Check whether the target service is listening.
13. HTTPS Certificate Error
Check certificate validity, hostname, and trust.
14. Slow Website
Inspect DNS, TLS, network, and backend response times.
15. VLAN Communication Failure
Check VLAN membership and inter-VLAN routing.
16. MTU Mismatch
Investigate fragmentation and Path MTU Discovery.
17. SSH Connection Failure
Check port 22, sshd, firewall, and authentication.
18. VPN Not Connecting
Check credentials, tunnel configuration, and network reachability.
19. Intermittent Disconnects
Inspect interface errors, wireless signal, and logs.
Memorizing the OSI Model is EASY.
Knowing WHERE the packet fails is the real skill.
Don't just learn networking.
Learn how to DEBUG it.
@WilliamInCyber Yes, right now currently implementing DHCP in C, I must say there is much much more info hidden when one implements the protocol.
When things do not work, you search and then come up with 5 more things. You come to know how linux has build several security measures.
Why do mobile brands not prefer making a handy, lightweight smart phone?? Why do they make them big screen that require two hands, one to hold and other to scroll.
The prefect size is Google pixel 4a. I have run this phone most in my life without any issue. The size, the weight all are prefect. I wish more brands could build phones like this.
One of the best phones that google discontinued.
When implementing the protocols, it is very important to calculate the length of different protocols header correctly.
Where protocol header length is fixed, it is easy but becomes tricky when involving dynamic length options as in DHCP.
Was stuck in correctly identifying the DHCP options in server side code due to the size of bytes I was writing in client side socket.
After sometime, correctly calculated the length of DHCP header along with options and was able to identify the options in server side correctly.
Building the protocols in low level language like C is whole another level of fun. You get to know much more information, how data is laid out, what fields are important, why certain things do not work, how to overcome those restrictions etc etc.
Currently building DHCP client and server and implementing the DORA. Implemented the D part for now. Next is O.
Hey guys, I have pixel 4a and been using this for the last 6 years, but now screen is cracked and does not show up anything.
USB debugging is not enabled. Phone has screen lock. Meanwhile I get another phone, are there any ways I can connect it to my mac and run the apps from the mac like Authenticator and other banking apps??
Wrapping the macro in do { ... } while(0) solves both:
- It shields the inner if from stealing your else.
- It swallows the trailing semicolon cleanly.
- The compiler optimizes the while(0) away completely zero runtime cost.
Classic C idiom, zero overhead. #CLang#Programming
It looks weird at first glance, until you realize it prevents one of the sneakiest syntax and logic bugs in C.
Here is why you need it (and how plain if blocks break your code): ๐งต๐
After the preprocessor expands it, two things go wrong:
- Your semicolon after LOG("Failed"); becomes }; else, causing a syntax error.
- Because the caller didn't use { } around LOG, the else attaches to the INNER if (debug) instead of if (err) - silently breaking your logic.