Networks 2 Flashcards
What is true of checksums when it comes to UDP?
It isn’t compulsory in IPv4 but must be used in IPv6
What is UDP?
User Datagram Protocol. Fire + forget. Defined in RFC 768 to be minimal message oriented transport layer. Provides procedure for app programs to send messages to other programs with min of protocol mechanism, transaction oriented. Delivery + duplicate protection not guaranteed. Stateless, suitable for large nums of clients, good for unidirectional comms (stock market, streaming apps)
What should applications requiring ordered reliable delivery of data streams use?
Use TCP (transmission control protocol)
What does stateless mean?
Retains no state of UDP messages once sent.
Describe how UDP transmission works?
Data sent across network layer in finite packets. No error detection or correction, no connection oriented links, no verification of delivery links, basic datagram delivery. Easy to implement, minimal overhead + minimal header structure. Low intensity tasks performed in background (routine network monitoring)
Describe what’s in a datagram?
Contains header + payload. Header contains dest. (address + port), origin (address + port) + other info used for transmission. Payload contains data. Each one contains single message which may be request or reply.
Describe the source + dest port + message length field in UDP.
Source port field 16 bits long, assigned by originating host. Dest port field 16 bits long, usually well known port associated with app (DNS uses port 53). Message length field 16 bits, includes length in bytes of entire datagram.
What is port binding?
Ports generally well known, e.g. for services. When DNS server program executes on comp, tells comp it’s using port 53, known as binding a port. Port num is unsigned int + passed to function bind() which transfers to code for layer 4 of data comms stack. Client code doesn’t ask for port num. Well known port assignments are 0-1023, reserved so only programs run by root/admin user can use. Services also run as root/admin user but only 1024 of them.
How are ports assigned in UDP?
Client code sends data packet to server, layer 4 software chooses free port from ephemeral port range + puts value into source port of packet. Table links source port to client program. When server replies, takes received source port + makes dest. port for reply packets. Eph. ports allow each client session to run on unique port. Server always binds same port, client port changes. After client shut down, any port in use locked for short time before released back to free pool. OS can use any policy to allocate from eph. ports pool. Protocol + port together unique.
What do datagramSocket + datagramPacket do?
DS required to send/receive DP, all datagram sockets bound to local port. Listen for incoming data + place in datagram header of outgoing data. Single class D IP addresses + port define 1 multicast channel. To mitigate UDP unreliability, data may be sent over 2 diff channels. Must be routed differently through network (geographically diverse routing) (A + B channels in industry)
What is the consequence of sending data over 2 diff channels in UDP?
Client may same message 2x (or not at all) Every message has unique num so client can detect if message same, gaps in message sequences + not receiving messages. Line arbitrage is algorithm to receive 1 instance of message (arbitrate between line A + B) Fall back TCP connection to get missed messages. Continuous rebroadcasting on sep set of UDP MC channels. Creating reliable comms responsibility is on app programmer (linehandler).
Why is UDP good even with its cons?
Faster than using TCP FSMs in ultra low latency environment. Full market data feed is multiple pairs of MC channels. Too many stocks to send in near real-time over 1 channel. 1 channel could have bit rate as low as 2 Mb/s.
What is a server?
Program that provides service + can be reached over network. Receives message from client, appr. processing carried out + response sent back to client. Docs stored as array of strings indexed 0 - 3. Client requests doc by sending index to it. It responds by sending it copy of doc.
What is a client?
Program that sends request to server for certain service + receives response from it. When it makes conn. to server, it must be running + waiting for its connection. Prompted to enter message to send to server + enter int 0 - 4. It waits for server to respond + contacts server until it quits.
What is TCP + describe in terms of client/server connection?
Connection-oriented service so conn. between source + dest established before transmission + ended when complete. To facilitate comm, hosts creates sockets + data transms. flow in streams between these. Server contains socket that listens at certain port for conn. requests. When request received, negotiates conn. + allocates socket to handle all comms between server + client which contains 1 socket where it initiates conn. to server + if conn. successful, uses to send data to from server.