Network Protocols: Client-Server Communication

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What is the primary role of a protocol in network communication?

  • To define the hardware specifications of network devices.
  • To encrypt data transmitted over the network.
  • To manage the physical cables connecting network devices.
  • To establish an agreement on how programs will communicate. (correct)

In a typical network application, client and server applications communicate directly without underlying layers of protocols.

False (B)

What functions does TCP provide in ensuring reliable communication between applications?

connections, reliability, acknowledgment

In TCP, the process of initiating a connection involves a ______ handshake.

<p>three-way</p>
Signup and view all the answers

Match the following terms with their byte order:

<p>Host Byte Order = Byte ordering used by a specific system. Network Byte Order = Big-endian byte ordering</p>
Signup and view all the answers

What is the significance of the TIME_WAIT state in TCP?

<p>It ensures that previously transmitted packets have expired before a new connection is established. (B)</p>
Signup and view all the answers

UDP guarantees that datagrams will reach their final destination in the order they were sent.

<p>False (B)</p>
Signup and view all the answers

What are ephemeral ports, and how are they typically used in network communication?

<p>short-lived ports for client communication</p>
Signup and view all the answers

The maximum size of an IPv4 datagram, including the header, is ______ bytes.

<p>65535</p>
Signup and view all the answers

Match each component of an IPv4 socket address structure with its description:

<p>sin_family = Address family (e.g., AF_INET for IPv4). sin_port = Port number. sin_addr = IPv4 address.</p>
Signup and view all the answers

Which function converts a dotted-decimal IPv4 address into a network byte ordered 32-bit binary value, but is now deprecated?

<p>inet_addr (C)</p>
Signup and view all the answers

Byte ordering is not important in network programming because all systems use the same byte order.

<p>False (B)</p>
Signup and view all the answers

Why are byte manipulation functions like bzero or memset necessary when dealing with socket address structures?

<p>to handle non-character data</p>
Signup and view all the answers

The main difference between bcopy and memcpy is the order of the arguments and how they handle ______ fields.

<p>overlapping</p>
Signup and view all the answers

Match socket function with what it does:

<p>socket() = Specifies communication protocol. connect() = Establishes connection with stream socket. listen() = Accepts incoming client requests</p>
Signup and view all the answers

When a TCP server calls listen, what is the purpose of the backlog argument?

<p>It limits the number of uncompleted sockets. (C)</p>
Signup and view all the answers

If TCP client receives no response from server, ETIMEDOUT is set as a high intensity error.

<p>False (B)</p>
Signup and view all the answers

What action does calling function bind() perform?

<p>assigns protocol</p>
Signup and view all the answers

If TCP client does not specify which port to connect through by calling bind(), what port does it use? ______

<p>ephemeral</p>
Signup and view all the answers

Match each wildcard result with port and IP if a protocol specifies it.

<p>Kernel port and IP = 0 Port only = Local IP address with 0 IP Only = <code>INADDR_ANY</code></p>
Signup and view all the answers

Given an IPv4 connection, how may a wildcard IP address be specified?

<p>INADDR_ANY (C)</p>
Signup and view all the answers

It is normal for a server TCP server to let the kernel choose a random port, since this changes during each reset.

<p>False (B)</p>
Signup and view all the answers

What value does the listen() function do?

<p>accepts connections</p>
Signup and view all the answers

The listen() kernel should queue up to ______ values.

<p>backlog</p>
Signup and view all the answers

Match each statement about how to complete with listen() connection queues.

<p>clientSYN = Add entry to SYN state Full Handshake = Transfer entry Not enough space = Entry times out</p>
Signup and view all the answers

What is the purpose of SYN flooding?

<p>Launch attack by using SYNs. (B)</p>
Signup and view all the answers

The accept() argument is called by a TCP client.

<p>False (B)</p>
Signup and view all the answers

What is the purpose of fork() and exec()?

<p>concurrent servers</p>
Signup and view all the answers

Unix can be executed by a ______ process to call one of the 6 exec() functions.

<p>existing</p>
Signup and view all the answers

Match two uses of fork()

<p>For Copy = To handle operation while task copy does another. For Program = To make a new program and have copy replace main program.</p>
Signup and view all the answers

The main socket structure begins with sockaddr and ends with [blank]?

<p>suffix (C)</p>
Signup and view all the answers

A socket address can only be read. It is passed through other functions such as bind, sendto, or connect.

<p>False (B)</p>
Signup and view all the answers

What type do most socket values have to be in to execute properly?

<p>pointer</p>
Signup and view all the answers

Data length is passed as an ______ argument.

<p>integer</p>
Signup and view all the answers

With address value, match the input and result data.

<p>Value = Process to kernel Result = Kernel to process</p>
Signup and view all the answers

There are how many states?

<p>11 (A)</p>
Signup and view all the answers

The netstat function is a debugging tool.

<p>True (A)</p>
Signup and view all the answers

What does MSL stand for?

<p>maximum segment lifetime</p>
Signup and view all the answers

Every datagram contains an 8 bit ______ limit.

<p>hop</p>
Signup and view all the answers

Select what corresponds to TCP, UDP and SCTP

<p>TCP = connection oriented UDP = connectionless SCTP = “associations” between clients and servers and is SCTP is message-oriented</p>
Signup and view all the answers

Flashcards

Protocol

An agreement on how programs will communicate, including expected responses.

Client and server

Applications using a structure where one program (the client) requests services from another (the server).

UDP (User Datagram Protocol)

A transport-layer protocol that is simple and connectionless, often used for streaming.

TCP (Transmission Control Protocol)

A transport-layer protocol that provides reliable, connection-oriented service.

Signup and view all the flashcards

SCTP (Stream Control Transmission Protocol)

A transport protocol that supports multihoming between client and server

Signup and view all the flashcards

TCP Reliability

Ensures data reaches its destination.

Signup and view all the flashcards

TCP Three-Way Handshake

A sequence of steps to create a TCP connection: SYN, SYN-ACK, ACK.

Signup and view all the flashcards

TCP Connection Termination

A procedure where both sides agree to end a connection.

Signup and view all the flashcards

TIME_WAIT State

TCP's state after active close, waiting for potential duplicate packets.

Signup and view all the flashcards

Port Numbers

Numeric labels differentiating processes using UDP, TCP, and SCTP.

Signup and view all the flashcards

Well-known Ports

0-1023, controlled and assigned by the IANA.

Signup and view all the flashcards

Registered Ports

1024-49151, registered by the IANA as a service to the community.

Signup and view all the flashcards

Dynamic/Private Ports

49152-65535, not controlled or registered by the IANA.

Signup and view all the flashcards

Maximum IPv4 Datagram Size

The biggest datagram that IPv4 can use, headers included.

Signup and view all the flashcards

Maximum Transmission Unit (MTU)

The largest IP datagram that can pass across a network.

Signup and view all the flashcards

Path MTU

The path having the smallest MTU between two hosts.

Signup and view all the flashcards

Socket

An endpoint of a two-way communication link.

Signup and view all the flashcards

Socket functions

Requires a pointer to a socket address structure as an argument.

Signup and view all the flashcards

sockaddr

A generic structure used for socket addresses.

Signup and view all the flashcards

Big-Endian

Network order for multi-byte values.

Signup and view all the flashcards

htonl, htons, ntohl, ntohs

Functions for converting between host and network byte order.

Signup and view all the flashcards

inet_aton, inet_addr, and inet_ntoa

Functions to convert Internet addresses between ASCII strings in socket address structures.

Signup and view all the flashcards

inet_pton and inet_ntop

Functions that works with both IPv4 and IPv6 addresses.

Signup and view all the flashcards

Byte Manipulation Functions

operate on multibyte fields, without interpreting the data.

Signup and view all the flashcards

bzero

Sets bytes to 0. Used to initialize socket address structures.

Signup and view all the flashcards

bcopy

Moves bytes. Source to destination.

Signup and view all the flashcards

bcmp

Compares two arbitrary byte strings. Identical or not.

Signup and view all the flashcards

memset

Sets bytes to a value in destination.

Signup and view all the flashcards

memcpy

Similar to bcopy, but the order of the two pointer arguments is swapped.

Signup and view all the flashcards

socket()

Function to create a new socket.

Signup and view all the flashcards

connect()

Make a connection with a TCP server.

Signup and view all the flashcards

bind()

To assign an address to a socket,

Signup and view all the flashcards

listen()

The function to listen for incoming connections on TCP

Signup and view all the flashcards

accept()

A method to return the next completed connection from the completed connection queue.

Signup and view all the flashcards

close()

To close a system and terminate a TCP connection.

Signup and view all the flashcards

fork() and exec()

Copy and execute a program function

Signup and view all the flashcards

Study Notes

Introduction to all protocols

  • A protocol represents an agreement on how programs will communicate.
  • Decisions must be made regarding program initiation and expected responses, such as web server and client communication.
  • Network-aware applications commonly use a client and server model.

Client-Server Communication

  • A client typically communicates with a single server.
  • A single server can communicate with numerous clients concurrently.

Protocols and Layers

  • Client and server applications communicate using multiple protocol layers.
  • Clients and servers are often user processes.
  • TCP and IP protocols are often part of the kernel's protocol stack.
  • Ethernet communication involves a flow between client and server using underlying drivers and protocols.
  • When clients and servers are not on the same LAN, routers become involved.

Key Terms

  • Agreement: Highlights the importance of an agreed method.
  • Client and Server: Highlights the common software architecture.

Protocols: The Big Picture

  • IPv4: The fourth iteration of the Internet Protocol, responsible for providing network addresses.
  • IPv6: The sixth iteration of the Internet Protocol, responsible for providing network addresses.
  • TCP: Transmission Control Protocol, a connection-oriented protocol that provides reliable, ordered, and error-checked delivery of data.
  • SCTP: Stream Control Transmission Protocol, which is a reliable, message-oriented protocol.
  • UDP: User Datagram Protocol, a connectionless protocol used for applications that tolerate some data loss.
  • ICMP: Internet Control Message Protocol, used for network diagnostics and error reporting.
  • IGMP: Internet Group Management Protocol, used for managing multicast group memberships.
  • ARP: Address Resolution Protocol, allowing the conversion of IP addresses to MAC addresses.
  • RARP: Reverse Address Resolution Protocol, providing the reverse of ARP by converting MAC addresses to IP addresses.
  • BPF (BSD Packet Filter): A data link layer interface that provides raw network data access.
  • DLPI (Data Link Provider Interface): A standard interface for accessing data link layer services.

Features of User Datagram Protocol (UDP)

  • UDP is a simple transport-layer protocol as detailed in RFC 768.
  • Applications write messages to a UDP socket, which are encapsulated in UDP datagrams and further in IP datagrams for destination sending.
  • UDP does not guarantee datagram delivery, order, or arrival uniqueness.
  • UDP lacks reliability with no automatic retransmission in case of errors and is a connectionless service.
  • The datagram length is passed with the data to the application.
  • Voice over IP (VoIP), online games, and media streaming are examples of UDP use.

Features of Transmission Control Protocol (TCP)

  • TCP provides connections between clients and servers and is described in RFC 793.
  • TCP ensures reliability, requiring an acknowledgment (ACK) for data sent.
  • TCP offers automatic retransmission for error cases.
  • While TCP is reliable, it cannot be described as 100% reliable as failures can have notifications.
  • TCP contains algorithms to dynamically estimate the round-trip time (RTT) between a client and server allowing appropriate wait times for acknowledgments.
  • TCP sequences data.
  • This sequencing aids in reordering and duplicate detection.
  • TCP provides flow control, and connections are full-duplex.
  • Examples include WWW, FTP, and Email.

Features of Stream Control Transmission Protocol (SCTP)

  • SCTP offers services similar to those of UDP and TCP, and is described in RFC 2960.
  • SCTP provides associations between clients and servers and is message-oriented.
  • An association implies communication between two systems possibly using more than two addresses due to multihoming.

TCP vs UDP

  • TCP provides reliability, while UDP makes no guarantees for data delivery.
  • TCP ensures data delivery in order, unlike UDP.
  • TCP is connection-based between client and server.
  • TCP provides flow control.
  • TCP supports full-duplex connections, enabling simultaneous traffic in both directions.

TCP Connection Establishment

  • The server must be prepared by passively opening with calls to socket, bind and listen.
  • The client actively opens, using connect, to send a synchronize, SYN, segment. The sequence number for client data is included in the SYN. An IP and TCP header are included in the data.
  • In the server's acknowledgement (ACK) of the SYN, the server's own SYN is sent with its initial sequence number. The ACK of the client's SYN happens in a single segment.
  • The client must acknowledge the server's SYN.

TCP Connection Termination

  • The application issues a close first, beginning the active close.
  • This end's TCP sends a FIN segment.
  • The other end to RECEIVE the FIN performs the passive close. Receives FIN acknowledged by TCP. Passes into the application as an end-of-file following any queued data for receiving.
  • The receiver to the end-of-file closes the connection, and this causes the TCP to send a FIN.
  • The remote end to receive the final FIN ACKs.

TCP State

  • A TCP connection has 11 states, with state transitions determined by current states and received information.
  • An active open in the CLOSED state prompts TCP to send SYN; the new state is SYN_SENT.
  • If TCP receives SYN with ACK next, an ACK is sent, and the new state is ESTABLISHED, in which data transfer occurs.
  • Netstat is a useful tool for debugging client and server applications.

TIME_WAIT State

  • TIME_WAIT is a misunderstood aspect regarding network programming.
  • The end doing an active close transitions through this state, for a duration of twice the maximum segment lifetime (MSL). This is sometimes called the 2MSL.
  • MSL refers to the maximum time for an IP datagram in any given network.
  • Datagrams contain an 8-bit hop limit with a value of 255, with this bound to 255 seconds.
  • A packet that has a max hop limit cannot exist longer than MSL seconds.

TIME_WAIT Reasons

  • The two reasons for TIME_WAIT state are to guarantee reliable TCP's full-duplex connection termination and expire old duplicate segments.

Scenario Explaining TIME_WAIT

  • A scenario where a TCP connection from 12.106.32.254:1500 to 206.168.112.219:21 is closed. Sometime later, a new connection between the same IP addresses and ports: 12.106.32.254 port 1500 and 206.168.112.219 port 21.
  • The latter connection is an incarnation of the previous connection because the IP addresses and ports are the same.
  • To prevent misinterpretation as belonging to a new incarnation of the same connection, TCP will not initiate a new connection currently in TIME_WAIT.

Port Numbers

  • All three transport layers use 16-bit integer port numbers to differentiate between UDP, TCP, and SCTP processes.
  • When a client contacts a server, the client must identify the server.
  • TCP, UDP and SCTP define well-known service ports
    • Every TCP/IP implementation for FTP assigns the port 21 to the FTP server.
    • Trivial file transfer protocol (TFTP) gets the UDP port of 69
  • Client ports are ephemeral ports.
  • Port numbers are assigned automatically by the transport protocol to the client.

Port Number Ranges

  • Well-known ports are in the range of 0 through 1023. These are controlled and assigned by the IANA. Port 80 is for a Web server for TCP and UDP.
  • Registered ports are in the range of 1024 through 4951, these are not controlled by the IANA, the IANA registers their uses as a convenience to the community. An X Window server for both protocols is assigned ports in the range 6000 through 6063.
  • Dynamic or private ports are in the range 49152 through 65535. The IANA has no comment on these ports. These are ephemeral ports.

TCP Port Numbers and Concurrent Servers

  • It is important to understand port numbers and concurrent servers.
  • A server starts on the host freebsd, through IP addresses. The server makes a passive open with its well-known port number. The server is waiting for a client request.
  • Let us examine a sequence: The server is started on the host freebsd, with IP addresses. The server does a passive open using its well-known port number.
  • A concurrent server will accept a client to handle the client. The concurrent server has child handle client when the client has a connection

Buffer Sizes and Limitations

  • The maximum size of an IPv4 datagram including the header is 65,535 bytes due to its 16-bit total length field, for an IPv6 datagram the size is 65,575 bytes including the 40-byte IPv6 header.
  • Many networks have a maximum transmission unit (MTU) dictated by hardware, such as Ethernet with a 1,500 byte MTU.
  • The minimum link MTU for IPv4 is 68 bytes.
  • The path MTU is the smallest MTU between two hosts.
  • If an IP datagram's size exceeds the interface's link MTU, it will be fragmented. Fragmentation is performed by IPv4 and IPv6 and reassembled at the destination to prevent data loss.
  • If the “don't fragment”" (DF) bit is set in the IPv4 header, fragmentation will not occur.
  • IPv4 and IPv6 define minimum reassembly buffer sizes so implementations must support the minimum datagram size.
  • TCP has a maximum segment sizes (MSS) announcing to the peer TCP the maximum amount of TCP data that the peer can send per segment.
  • SCTP keeps a fragmentation point based on the smallest path MTU found to all peer addresses.

Socket Address

  • A socket is one endpoint of a two-way communication link between two programs running on the network.

Client Side

  • The client knows the hostname of the machine on the server and the server's port number
  • To make a connection request, the client tries to rendezvous with the server on the server's machine and port using the connection request.
  • The client also identifies itself to the server, binding to a local port number for its connection, usually assigned by the system.

Server Side

  • The server has the name and port number.
  • It listens to the incoming requests.
  • On acceptance, the server creates a clients socket.
  • The server needs a new socket so it can continue to listen to the original socket for connection requests while tending to the needs of the connected client.

Socket Address Structure

  • Socket functions require a pointer to a socket address structure as an argument.
  • Each supported protocol suite defines its own socket address structure.
  • The names structure starts with sockaddr_ and ends with its unique suffix of its protocol suite.

IPv4 Socket Address Structure

  • The structure commonly known as the "Internet socket address structure," is named sockaddr_in and the socket is defined by including the header.

Generic Socket Address Structure

  • Socket address structures are passed by reference as an argument in any socket function.
  • Socket functions that take it as an argument deal with socket address structures from any of the supported protocol families.

C function prototype for the bind function

  • The socket functions then defined as taking a pointer to the generic socket address structure require that any calls cast a pointer to protocol-specific socket address structure to the pointer.

Value Result Arguments

  • Socket structures are passed with socket functions. Because a pointer is passed, this means that they are passed by reference.
  • The length of the structure is passed as an argument, and the way the length depends on which direction the structure is being passed process to kernel, or vice versa.

Integer Socket Parameters

  • Functions for bind, connect, and sendto, pass a socket address structure from the process to the kernel. Where an argument is a pointer and another is an integer that gives the size.

Socket Address Structure

  • Conversely the functions accept, recvfrom, getsockname, and getpeername, pass a socket address structure the other was, from the kernel to the process. Here, one pointer contains the argument and the size is an integer containing the size.

Byte Ordering

  • A 16-bit integer, can be made of 2 bytes
  • Storing the 2 bytes in the memory is through these methods:
    • With the low-order byte comes at the start.
    • Little End byte-order
    • High-order byte is the first byte at the start.
      • Big-endian byteorder

Functions for Byte Order

  • Multibyte values have the "little-endian" and "big-endian" are the placement of big and little at the start.
  • Host byte is the byte order of a given system.
  • Networking protocols must specify network byte order.
  • Sending and receiving must agree to the order that can be transmitted.
  • The Internet protocols use big-endian byte ordering for for all of the protocol's integers.

Converting between bytes

  • The unp_htons.h has code for converting between these 2 bytes. This is for short and long. H means host, n for network, s for short (16 bit port number ie TCP/UDP), L for long (IPV4 address ie 32-bit)

Converting internet addresses

  • Inet_aton, inet_addr, and inet_ntoa convert Internet addresses between ASCII strings (readable) and binary values (socket structures).
  • Inet_addr returns the 32-bit conversion, as the return value, not in socket address, (0.0.0.0 to 255. 255. 255. 255). Constant Inaddr_None shows all errors.
  • Inet_addr is now deprecated and replaced by inet_aton.
  • Inet_pton/ntop functions are new to IPV6, function with both IPV4/6.

Internet pton

  • Converts string and binary, storing the binary through the pointer named addrptr. Success here results in 1. Input string is not a valid presentation gives a 0 upon returning with an error.

Internet ntop

  • Does the reverse conversion, from numeric to presentation. The Len argument is the size of the destination

Byte Manipulation Functions

  • There are two groups of functions that operate on multibyte fields, without interpreting the data, and without assuming that the data is a null-terminated C string.
  • Addressing issues when taking into consideration the strings, are a null terminated C string
  • 4.2 BSD is related by the byte group
  • Standard ANSI C use mem (for memory.)

Berkeley-derived Functions

  • Bzero function has specific byte use, as initializing socket is structure to 0, moves bytes from source the destination; otherwise.
  • Bcmp sees 2 arbitrary byte strings. Has a value of 0 if matched, if unequal is the non zero.

ANSI C

  • Memsel does 1 byte value; memcpy is like bcopy but pointer switches, or fields. Correct ANSI MEMMOVE MUST take when fields, overlapping or string are there.

Sockets

  • Sockets functions can write complete TCP client and server and along with it concurrent servers.
  • The client can make the server fork with a new processes only with servers.
  • There it is possible one may make these events between socket and clients.
  • There first, it comes the server is to be started sometimes earlier.

Socket Details:

  • When the client sends a response
  • End files have been notifications for the responses
  • There the other connection can be with clients.

Socket creation

  • Perform network I/O by calling the socket, specifying which type of protocol is best (Unix domain/stream)
    • Family = Address protocol family
    • Type = Socket types (stream, datagram) socket).
    • Protocol = Used as the protocol use to create the socket-if not passed sets family protocol (0).

Connect Socket

  • Connect is TCP to make TCP with the server:
  • Socketfd = socket
  • Servaddr = a pointer to an address
  • Before it needs client, it's the kernel. The kernel chooses both an source if.

Connect

  • Has 3 way handshakes
  • TCP = 3-way.
  • SYN, RST, are errors to note with connect ( ). Soft.

Bind

  • The protocol address is the combination of either a 32-bit IPv4 address or a 128-bit IPv6 address, along with a 16-bit TCP or UDP port number. myaddr = a pointer to the address,
  • And if the code calls binds; it can choose port #, IP address, etc. (local)

Bind

  • Servers start with it
  • If not used by client, does not work
  • TCP has both unless it requires it to not work.
  • Server are known if used.

Listens

  • Call function, only if TCP is active and has 2 actions.
  • The listening is converted to passive - where it takes any requests in queue
    • Needs Bind before and socket.

Queue and Listens. -

  • It has 2 kinds:
    • It comes from SYNS and its 3 way. Syn_RCD is that state. The sockets:
      • Has TCP with completion of data - Complete queue/states

Listens Details:

-When TCP is found to add, this happens with 3 way-the second Syn.

  • Its remained to complete; when its complete the queue can occur with accept.

Listen Details:

  • When SYN arrive;
  • There a entry gets is given
  • It times out with it.

Connection Detail Summary:

  • The backlog takes in 1.5, a multiplier
  • If backlog is 0, all are restricted until closed. If you have all to stop, closes all.
  • There should always be a configure high value.

Attack (SYN FLOODING) :

  • Tries to send to fill, to take control for more to 1 port.
  • To try to not show, and make sure they not get shown.
  • Can prevent data to legitimate clients this way.

Accept

  • TCP Servers often give back from complete queue from complete connection.
  • IF completion is not queued; the process stops running until it resumes because its empty. -Addlen and Addir needs to see the correct Peer in code. Value is returned/by with the kernels byte.

Returns

  • The new code and returns, is used to be made.
  • 2 Sockets: - TCP sockets that are used bind , and listening. - Accept
    • One can be found across all servers. The new socket, helps with what new data comes from it. To know which client has a connection,
    • Must finish before to make all correct connection.

Shutdown

  • Is for ending connection
  • Standard.
  • End the transmissions in sockets are marked as 1.

System Calls

  • Is where forking, and to get the servers work - this happens This occurs to runs to 2.

System Detail:

  • Must run by calling processes often - or ID stops.
  • Needs open files first.

Exec = Executed

  • Disk must call 1 per exec 6, - Replaces program
  • Process ID won't transfer. To make it transfer it must be called.

Execution

To make a code:

  • To specific to where data.
  • To make it as pointers:
    • Must call as Null.
  • Needs to follow the code:
    • File name follows standard for executable.
      • Is the function is being used.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Computer Networking Basics Quiz
24 questions
Unit 3: Application Layer
40 questions
Use Quizgecko on...
Browser
Browser