TCP Servers - andrewkyllo-401-advanced-javascript/seattle-javascript-401d34 GitHub Wiki
Event Queues
- All objects that emit events in NodeJS are instances of the EventEmitter constructor
- Functions can be registered as listeners for an event on instances of the EventEmitter class
OSI Model
- Open Systems Interconnection Reference Model
- A seven layer model developed to describe the different processes in computer networking
Internet Protocol Suite
- A conceptual model for the protocols used by the internet.
- Also known as TCP/IP. Described using 4 layers: Link, Internet, transport, and application.
TCP (Transmission Control Protocol)
- Widely used by application layer protocols in the internet protocol suite.
- Creates a two way communication between two hosts and procides reliable, ordered, and error checked byte streams between applications
- Data transfers manage network congestion and use flow control to limit the rate a sender transfers data to guarantee reliable delivery.
- Each IP packet between the hosts carries a single TCP segment
- A TCP segment is made up of header and data sections
TCP Header
Used at each end to control the type of interaction being sent.
Byte 0: Source port
Byte 3: Destination port
Byte 4: Sequence number
Byte 8: Acknowledgement number
Byte 12: Data Offset, NS flag, and 3 undefined bits
Byte 13: CWR, ECE, URG, ACK, PSH, RST, SYN, and FYN flags
Byte 14: Window size
Byte 16: Checksum
Byte 18: Urgent pointer
Byte 20: Options
Connection Establishment
- The client sends a SYN packet with a random initial sequence number.
- The server sends a SYNACK packet with the acknowledgment number set to one more than the initial sequence number
- The client responds with an ACK and an acknowledgment number increment by one
Connection Termination
- One end sends a FIN Segment and the other sends an ACK segment followed by a FIN segment.
- The termination initiation will then respond with an Ack segment