Networking Flashcards

1
Q

What are ports?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the different type of ports?

A
  • well-known/system ports [0, 1023]
  • dynamic/private ports [49152, 65535]
  • registered ports [1024, 49151]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the protocols that implement a client-server model into an application?

A

Transmission Control Protocol(TCP) and User Datagram Protocol(UDP)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an IP address?

A

An address that identifies a device on the Internet; each device connected to the internet has a unique IP address; IP = inernet protocol

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What version of IP is used right now?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is TCP? (Transmission Control Protocol)

A

A protocol over the Internet Protocol that provides reliable and ordered delivery of network packets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does passive open refer to?

A

The server must first bind to a port and listen at it for incoming connections.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does active open refer to?

A

The client connecting to a started server that is awaiting connections.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does TCP use to establish a connection?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is duplex communication?

A

When the connection is guaranteed (after finishing the three-way handshake), the communication can be made in both directions(client <=> server)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does a socket(Socket/ServerSocket) do?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can reading from the socket be done?

A

BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream());
String input = in.readLine();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can writing to the socket be done?

A

PrintWriter out = new PrintWriter(s.getOutputStream(), true);
Scanner userInput;
out.println(userInput.nextLine())

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What ports can we use?

A

Generally, it is recommended to use only registered ports.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is UDP? (User Datagram Protocol)

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How does UDP initiate contact?

A

The client sends an initialisation packet to the server such that the server can register the client’s host name and port number. In a multi-threaded UDP server, the server will in turn send a packet back with information about the new port number that the client can connect to.

17
Q

What kind of socket does UDP use?

A

a DatagramSocket that can have either one parameter (the port number) or zero parameters (in which case it takes 0 and chooses a random available port number)

18
Q

How do you connect a socket?(TCP)

A

Using the method connect in the Socket class. Example:
s.connect(new InnetSocketAddress(“hostname”, 8189), 1000). 8189 is the port number and 1000 is the nr of milliseconds until it is considered timeout if the server hasn’t connected yet. On the server side, we do ServerSocket ss = new ServerSocket(8189); (passive open) Socket s = ss.accept() that accepts the connection and cause the active open.

19
Q

How can communication be enabled when using UDP?

A

Using DatagramPacket; Parameters: the data you want to transfer (as a byte array), the length of the array, the IP address of the recipient and the port number.