Tuesday, November 24, 2009

Network Programming in C - Beej's guide summary(Part 1)

So to brush up my C skills, I thought of doing some C programming and Network programming was something I was always curious about so what better way then do network programming in C.I haven't gotten to the programming part yet.So far I have just completed about half of Beej's guide to Network Programming
And since I have fallen into this good (or bad? who knows) habit of taking notes, here is what I have covered so far from the tutorial
  • What is a socket?
  • Difference between Stream Sockets and Datagram Sockets (SOCK_STREAM and SOCK_DGRAM)
  • Stream sockets use Transmission Control Protocol and Datagram Sockets use User Datagram protocol
  • Streams sockets have a connection open during transmissioin and have all the good stuff of ensuring the packets reach other end in same order etc whereas datagram sockets don't ensure any of that, the reason to use UDP over TCP is speed and speed
  • Layers of Network stack and why it is layered (very brief)
  • why ipv6? Because we were running out of address in ipv4 - ipv4 is 32 bits for each address, ipv6 is 128 bits
  • Representation of ipv4 address e.g. 192.0.2.111 and ipv6 address e.g. 2001:0db8:c9d2:0012:0000:0000:0000:0051 , you can actually ignore zeros and represent it as 2001:db8:c9d2:12::51
  • Loopback ipv6 address is ::1 and ipv4 is 127.0.0.1
  • What is a subnet and how it is represented?
  • What are port numbers?
  • byte orders - big endian and little endian and the need to convert from network byte order to host byte order and vice versa during receiving and sending packets
  • Explains Structs - addrinfo, sockaddr,sockaddr_in, in_addr, sockaddr_in6, in6_addr,sockaddr_storage
  • Explains - inet_pton() function which converts String representation of ip address (e.g. 172.78.89.1) to in_addr struct and inet_ntop() for vice versa conversion
  • Private networks and Network Address Translation(NAT) - for example when you are connected via a router to the internet from home , your ip addres via ipconfig is different than what your ip address is on this site http://www.whatismyip.com/.Also in theory there can be so many addresses with ipv6 that NAT won't be needed

No comments: