ICS 2305-Networking Systems Programming Lecture Final
ICS 2305-Networking Systems Programming Lecture Final
NETWORKING
Karanja Mwangi
Lesson objective
7 Application Application
6 Presentation Presentation
5 Session Session
4 Transport Transport
3 Network Network Network
2 Data link Data link Data link
1 Physical Physical Physical
Client Server Communication TCP and UDP
8
Transmission Control Protocol (TCP): An
Analogy
9
PORTS (IPv4 vs. IPv6)
Port - A 16-bit number that identifies the application
process that receives an incoming message.
Local hosts for IPv4 address is 127.0.0.1
Local hosts for IPv6 address is IPv6
is 0:0:0:0:0:0:0:1 shortened form is ::1
Both are stored in an IP address struct of appropriate
type(library functions in C usually hide them)
in_addr for IPv4
in6_addr for IPv6
Port numbers divided into three categories
• Well Known Ports 0-1023
• Registered Ports 1024-49151 by the IANA (Internet
Assigned Numbers Authority), and represent second tier common
ports (socks (1080), WINS (1512), kermit (1649), https (443))
• Dynamic/Private Ports 49152-65535 ephemeral ports, available
for temporary client usage
Well Known Ports- Reserved ports
0000001000000000
How do two machines with different byte-orders communicate?
Using network byte-order
Network byte-order = big-endian order
network byte-order conversion
#include <sys/types.h>
#include <sys/socket.h>
int socket(int domain, int type, int protocol);
#include <sys/socket.h>
#include <sys/socket.h>
int bind(int sockfd, const struct sockaddr *servaddr, socklen_t addrl
en);
#define _OE_SOCKETS
#include <sys/socket.h>
int listen(int socket, int backlog);
Where
Backlog Defines the maximum length for the queue of
pending connections.
#include <sys/socket.h>
ssize_t recv(int sockfd, void *buf, size_t nbytes, int flags);
#include <unistd.h>
https://beej.us/guide/bgnet/html//index.html
https://academy.nordicsemi.com/courses/cellular-iot-
fundamentals/lessons/lesson-3-cellular-
fundamentals/topic/lesson-3-exercise-1/
https://www.youtube.com/watch?v=WdE3PCHSBy8
https://people.cs.rutgers.edu/~pxk/rutgers/notes/sockets/