Networking Flashcards
What’s the difference between a domain and a host?
Domain is the “entity/site” and host is where it runs.
for example: www.google.com is domain which runs on multiple hosts(servers).
Can a domain be associated with multiple hosts?
yes
Can a host be associated with more then one IP?
Yes. e.g. wireless and wired connection.
Can an IP correspond to more then one host?
No. every IP is corresponding to a single host.
How many bits are in each octet of the IP?
8 bits.
What are sockets?
Special FDs created via the socket() syscall instead of open(), which allows parties to communicate through the network.
read()-ing and write()-ing through socket fds
– Translate to receiving & sending data
What are ports and why are they needed?
• Simultaneously, on the same host, there can be
– Multiple communicating processes, each utilizing multiple sockfds
– So IP addresses aren’t a sufficient identifier for transmitted data chunks
• To avoid ambiguity, each sockfd is associated with a
– Port, unsigned 16-bit integer that uniquely identifies the sockfd
– Every transmitted chunk is associated with IP address + port
What types of ports exist?
• Ports can be either
– Ephemeral = dynamically allocated by the kernel, or
– Well-known = standard, predetermined, known values
• Ports ≤ 1023 are “reserved” (for privileged processes)
• For example, http & https traffic flows via ports 80 & 443
How are the TCP socket fds created?
• Different for
– Client and server
• But for starters, both need to
– Properly initialize a struct addrinfo via the getaddrinfo() syscall
– Invoke socket() using values from addrinfo
• Which returns the sockfd
What are the params for getaddrinfo function?
int getaddrinfo( const char* node, const char* service /the port in our case/, const struct addrinfo* hint, struct addrinfo** res);
node is the host (if server then null (this host), if client then servers name)
service is the port (same for both server and client).
res is the result struct containing all the info (ai_family + ai_addr (encapsulates IP+port) + ai_addrlen specifically).
hint contains:
hint.ai_family
hint.ai_protocol
hint.ai_socktype
hint.ai_flags
In hint Why do we need both ai_protocol and ai_socktype?
- Other protocols may implement a stream abstraction too
* Notably, non-default TCP versions specialized for data centers
What’s ethernet?
• Ethernet is both a link-layer (L2) protocol
– Allows nodes (not processes) to communicate within the LAN
– By sending “frames” (how byte-chunks are called in the link-layer)
• And a physical-layer (L1) protocol
– Lowest protocol layer (EE realm)
– Defines how raw bits (rather than frames) are transmitted
What’s MAC (media access control) address?
• A unique 48-bits number
– Identifying each Ethernet component
– Burned in ROM of NIC / Switch / AP
– Used to switch Ethernet frames to their destination within the LAN
What’s the ethernet header is used for? and how the frame is divided?
• Using frame’s header
– Switches know where to
send the frame, and
– Receiver can identify sender
The entire frame is called the physical-layer Ethernet packet.
without the preamble and sdf its called link-layer Ethernet frame.
What are routers?
A routers is hardware components that physically stands at the edge of
(at least) two networks, LAN1 and LAN2,
• And can communicate with both
LAN1 and LAN2 might be using two different protocols and therefore can’t communicate.