# Computer Communications
## Introduction

Computer network is a collection of nodes, where the computing stations (resources) reside. The nodes communicate to each other via communication network. Transmission, and switching accomplishes the course of communications.

### Network Types

Networks can be classified by switching methods, topology, functions and representation.

#### Circuit Switching

is good for long continuous and time-constrained communications.
* Before the data transmission began, station to station (end-to-end) physical path must be established. All channels in the path are used simultaneously ruding the transmission. The entire path must be used for communication, until the release of the circuit.
* The best way to memorize operation, consists of three phases:
** Circuit Establishment (Resources are allocated)
** Data Transfering (Resource are used)
** Circuit Termination (Resources are deallocated)

#### Message Switching

A message is a logical unit of information that one station sends to another. It does not need a path to be established. Instead, the message travels over existing channels. It hops (travels) through the network in a node-to-node manner, in store-and-forward fashion, until it reaches its destination.

#### Packet Switching

Transmits data in a bursty nature. Small users get fast service in presence of large users. Messages are decomposed into packets. Packets are the smaller units of data.
* Many packets of the same message can be transmitted at the same time. In other words, the message is cut is small pieces which are transmitted simultaneously, yet by different channels.
* The message needs to be reassembled after arriving at the destination.

#### Datagram Packet Switching

* Data packets are treated independently of each other.
* Each packet can travel according to the route it found on the network.
* Sequential order is not required to take place.
* The connection operation consists only of data transfer phase.

#### Virtual Circuit packet switching

Virtual circuit is a logical connection, which is established prior to the start of communications. Logical connection is a route, over which all packets travel between the stations. Packets are delivered along the circuits in sequential order.
* Connection-Oriented Operation:
** Connection Established
** Data Transferred
** Connection Terminated

### Protocol Concepts

Consider a simple example of file transfer, which happens almost every day with us. How does it happen:
* Source either activates direct data communication path, or informs the network about desired destination.
* Source system must be sure that the destination system is ready to receive data.
* File transfer application of the source system must be sure that the file management program on the destination system is ready to receive files.
Conversion must be performed if two systems are incompatible.

#### Protocols

Protocol is a set of rules that governs the exchange of the information. It deals with
* Syntax, which is the format, coding, signals magnituded
* Semantics, which takes care of the implementation of control information and error handling.
* Timing the sequence in which everything occurs.
Anything, capable of transmitting and receiving information is called an entity. A system is a physically distinct collection of entities.
Protocols are responsible for:
* Delivering user data
* Fragmentation and reassambly
* Encapsulation
* Connection Control, which consists of
** Establishment of the connection
** Data transfer
** Connection Termination
* Controling the data flow between two protocol entities
* Error Control
* Sequencing, which is maintaining the proper order of Protocol data Unit Delivery
* Addressing, which is a proper manner of naming and referencing protocol entities.
* Multiplexing, allowing single connection to multiple users
* Expedited data delivery, security, which comes under a frame of Transmision Service.

#### Layered Approach

Entity implements the functions of a given layer, and the protocols for communicating with peer entities. An entity communicates with entities on
* Its layer
* on layers above, or below it, acting as an interface
The entity on the layers N communicated with the entities on lower layers, by invokations of N-1 primitives.
Primitives:
* 'Request': used to invoke requested service, passing parameters for full specification
* In order to show that a procedure has been invoked by a peer service, indication migh be useful.
* Response is issued to complete or acknowledge some procedure, invoked by an indication to user.
* Confirmation, used by a service provider to complete or acknowledge some procedure.

### OSI MOdel

Suggested reading: OSI model

### TCP/IP protocol architecture

Suggested Reading, from WIKIPedia:
* Internet protocol suite

## Data Link: Issues and Requirements

Data link control is respoinsible of data communications between tow transmitting-receving station, connected directly. The most important aspects of the Data Link COntrol are
* Frame synchronization
** character oriented, where the character is the basic unit (atom) of information.
** bit oriented, where the "atom" of information is a bit.
* Line Configuration, is a criteria that differs the way of data links.
** Topology (point to point, multipont)
** Duplexity
** Simplex, one connection at a time, in one directeion over a single line
** Half Duplex, One connection at time, during the talk.
** Full duplex 2 way connection during the talk.
* Line discipline
** contention
** polling
** selection

### Bit Oriented Data Link Protocols

To study
* High Level Data Link COntrol (HDLC) - ISO
* LAPB - ITU-T (for x.25)
* Point-to-Point Protocol used on the internet to connect home users to ISPs, as well as router to router. While working, it relies on:
** Line Control protocol for establishing connection
** In order to check the validity of a password, PPP uses either PAP or CHAP. It comes between Establish, and Authenticate states.
** Network Control Protocol for negotiating network layer option. Comes between Network and Open states.
** And for providing IP service over the established connection, IPCP is in use. It comes between the states of Authenticate and Network.
Just for reference
* Advanced Communications Control Procedures (ADCCP)
* Synchronous data Link COntrol
* Link Access Procedures, D channelLAPD - ITU-T (for ISDN)
* Link Access Procedure for Frame-mode Bearer Sercies (LAPF)
* Logic Link COntrol(LLC) - IEEE 802.2

## Network Layer

This layer and its protocols are responsible for the terminal to terminal data packet delivery. One of its main design issues are:

### Subnet to host interface

| Connection Type | Methode Description |
| Virtual Circuit service | Network layer excercises flow and error control over the established circuit. Network tries its best to deliver packets in sequence. |
| Datagram Service | Network layer accepts packets from users, and tries to deliver them as isolated units. Packets may arrive not in sequence, and not in full order. |
| Internal Operation. Internal virtual circuit operation. Virtual Circuit Switching. | A virtual circuit determines a route between two terminals in a network. Then all the packets follow the same way. |
| Datagram Switching (Internal datagram Operation) | Each packet is treated independently, and finds its own route through the network. |

### External vs. Internal operation

In case of external.internal virtual circuit, whenever the user requests VC, a dedicated route is set through the network. All packets will follow it.
* External Virtual Circuit with internal datagrams.
** Different packets of the same message may follow different routes through the network.
** The original sequence and the integrity of message is achieved by resassemlby of packets at the destication node.
* External/Internal datagram, features independent treatment of each packet.
General COmparison
| Ext/Int | Virtual circuits | Datagrams |
| Internal Operations | MInimizes per-packet overhead *routing decisions are made only on at-call set ups *Sequenced Delivery | Robust with respect to the outages of links and nodes. |
| External Operation | End-to-End sequencing with flow control. | No call set-up.No need to hold packets in case of an error packet. |

### X.25 Standard

The protocol specifies three level interface between Data Terminal Equipment and Data Control Equipment
* From TOP to BOTTOM, the levels of the interface are:

### Packet Levels

enables subscribers of the network to set up logical connections to the subscribers. These logical connections, form a pre-planed routes and are called, Virtutal circuits THis level relies on Packet Layer Protocol
* Virtual Circuit Service of X.25
* Dynamically established Virtual Call.
* Network Assigned, permanet virtual circuit.
* Packet types
| Packet Type | DCE -> DTE | DTE -> DCE | VC | PVC |
| Call setup and Cleaning | Incoming Call | Call Request | X | |
| | Call Connected | Call Accepted | X | |
| | Clear Indication | Clear Request | X | |
| | Clear Confirmation | Clear Confirmation | X | |
| Data and Interrupt | Data | Data | X | X |
| | Interrupt | Interrupt | X | X |
| | Interrupt Confirmation | Interrupt Confirmation | X | X |
| Flow COntrol and Reset | RR | RR | X | X |
| | RNR | RNR | X | X |
| | | REJ | X | X |
| | Reset Indication | Reset Request | X | X |
| | Reset Confirmation | Reset Confirmation | X | X |
| Restart | Restart Indication | Restart Request | X | X |
| Restart | Restart Confirmation | Restart Confirmation | X | X |
| Diagnostic | Diagnostic | | X | X |
| Registration | Registration Confirmation | Registration Request | X | X |

#### Multilink Procedure

* Multilink procedure allows multiline DTE-DCE connections.
* Each link is governed by SLP LAPB
* MLP frame format
** Multilink Control Field (MLC) (2 octets)
*** 12 bit sequence number accross al links is needed, to reorder frames sent, which may arrive in different order.
*** Restination reorders the packets according to MLP sequence numbers
*** The X.25 packet.

### Physical Level

deals with the physical interface between the link that attaches computer to the network, and the computer.
* X.21
* X.21 bis, similar to EIA-232-D

### X25 details
#### Error control and recovery

* Reset packet: This operation requires to reinitialize a virtual circuit.
* Restart packet: This operation requires to reset all active virtual circuits.

#### Multiplexing

* DTE is allowed to establish up to 4095 Virtual Circuits simultaneously.
* each packet contains a 12bit Virtual Circuit number. (0 is reserved for "restart" and diagnostic packets.

#### Flow Control

* Sliding Window protocol with default size of 2 (max is 7 or 127)

#### Acknowledgements

They may have either local or end to end significance.
* when D=0, the acknowledgement is made between DTE and the network.
* when D=1, the acknowledgement is made from Remote DTE

## Frame Relay Networks

* This technology is designed to provide lower delays, and higher throughput, in comparison with traditional switching networks.
* F.R. originated as a part of ISDN standardization, yet can be provided for bothISDN and non-ISDN networks.
* In x.25 the control packets are carried on the same channel, and the same virtual circuit as the data packet. In fact in-band signaling takes place there. Simply speaking control and data packets travel in series, not in parallel. Multiplexing and switching takes place at level 3, whicle both layers 2 and 3 include flow control.
* Frame Relay provides separate channels/virtual circuits for data and control packets. In other words, data and control packets travel in parallel ways.

### FrameRelay protocol architecture

Consider two separate planes of operations, COntrol (C) plane and user (U) plane.
* C plane is responsible for establishment and termination of logical connections.
* U plane is responsible to the transfer of user data between the subscribers.
* Multiplexing, and logical connection switching takes place at level 2 (instead of 3) leaving level 3 for processing.
* Flow control is not end to end. No the hop to hop.

### Call Control

Call controls signalling is carried on a separate logical connection. Thus the state table maintenance is not required for intermediate nodes.
* It used LAPD (Q.921) protocol, for relizable data link control
* Q.931/Q.933 control signalling mesages are exchanged atop of Q.921 protocol.

#### Frame relay call control functions

* Exchange of a Q.931/Q.933 message over a logical connection dedicated call - establishes and release a frame relay connection.
* Sending the SETUP message, either side can request the establishment. The side which sends setup message may chose DLCI option by choosing the unused value. Otherwise the accepting side will assign DLCI with the conenct message.
Other side can answer with
* CONNECT message to confirm the connection, or the
* RELEASE COMPLETE message to refus the connection.
After the connection is established, data transfer can proceed. Clearing a connection is accomplished by the exchange of DISCONNECT, RELEASE, and RELEASE COMPLETE messages.

#### Q.931/Q.933 repertoire

| Call establishment messages | Call clearing messages | Miscalleneous messages |
| Alerting call proceeding connect connect acknowledgement progress setup | Disconnect Release Release complete | Status Status enquiry |

### User data Transer

User plane provides LAP-F protocol for data transfer (Link Access Procedure for Frame Mode bearer Services) It is defined in Q.922. Only the code function which are used in frame relay are defined here:
* delimiting, alignment, and transparancy
* multiplexing/demultiplexing, using the address field
* inspecting the frame for integral number of oxtets
** prior to zero bit insertion
** after zero bit extraction
Core functions of theLAPF constitue a subwayler in a data link layer. They provide bare data transfer service without any flow and error control. Besides this, the user can chose end-to-end function. Network can relay the frames with the following properties
* Small probability of frame loss.
* Preservation of the order of frame.

### Q.921/Q.922
## Routing protocols

Computer communication protocols can be divided on
* nonroutable
* routed
* routing protocols
Routing protocls in turn can be divided on by methode on
* distance vector routing
* link state routing

### Network address translation

(NAT) is a very important issue of routing. NAT can use either one-to one mapping or one to many mapping. NAT has several advantages.
* It conserves public IP addresses
* NAT hides internal IP scheme from the outside world
* allows easy renumbering of IP address translation.
For example: when a user decides to change a provider, along with external IP Addresses, NAT will presedve all the internal IP addresses with the internal to external translation.
However NAT has following disadvantages
* Delay comes froma NAT router to perform address translation.
* End to end IP traceablity is lost due to IP translation
* It is hard to find the originator of the message.

#### Static NAT

This kind of translation is ONE TO ONE. The configuration is simple, because NAT Routes will be a default gateway for all clients

#### Dynamic NAT

* Group-to-Group mapping, where a group of valid outside IP addresses are mapped to a group of private IP addresses.
* Network administrator doesnt care of specific one-to one mapping.
* Any private IP address will be automatically translated to any IP address.