Networking Flashcards
What are ports?
Communication endpoints between two devices; an integer in the range [0, 65535] (per device). Whenever an application tries to establish an Internet connection, it needs to claim a port number through which they can communicate with another device.
What are the different type of ports?
- well-known/system ports [0, 1023]
- dynamic/private ports [49152, 65535]
- registered ports [1024, 49151]
What are the protocols that implement a client-server model into an application?
Transmission Control Protocol(TCP) and User Datagram Protocol(UDP)
What is an IP address?
An address that identifies a device on the Internet; each device connected to the internet has a unique IP address; IP = inernet protocol
What version of IP is used right now?
IPv6, version 6: IP addresses consist of eight groups of four hexadecimal digits, separated by colons. In the day to day usage, however, IPv4 addresses are used.
What is TCP? (Transmission Control Protocol)
A protocol over the Internet Protocol that provides reliable and ordered delivery of network packets.
What does passive open refer to?
The server must first bind to a port and listen at it for incoming connections.
What does active open refer to?
The client connecting to a started server that is awaiting connections.
What does TCP use to establish a connection?
Three-way handshake:
1. SYN: client sends SYN to the server
2. SYN, ACK: the server sends back a SYN, together with ACK to acknowledge that it received the SYN from the client
3. ACK: the client sends back ACK
What is duplex communication?
When the connection is guaranteed (after finishing the three-way handshake), the communication can be made in both directions(client <=> server)
What does a socket(Socket/ServerSocket) do?
A server socket is used to bind to a port and listen for incoming messages; a socket requires the host/IP address and the port number)
How can reading from the socket be done?
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream());
String input = in.readLine();
How can writing to the socket be done?
PrintWriter out = new PrintWriter(s.getOutputStream(), true);
Scanner userInput;
out.println(userInput.nextLine())
What ports can we use?
Generally, it is recommended to use only registered ports.
What is UDP? (User Datagram Protocol)
A protocol that makes use of the Internet Protocol (IP) that does not provide reliable or ordered delivery of network packets. Instead, it provides faster delivery of network packets. Every packet is sent independently and there is no guarantee that the packets arrive in order, or at all even. This means that there is no concept of “state” in UDP.