### 基於 Sheng-Tzong Cheng 教授授課內容筆記 以及 Introdunction to Wireless & Mobile Systems (Dharma Prakash Agrawal, Qing-An Zeng)
# Ch01 Introduction
## Fundamentals of Cellular Systems
* Cell: 指基地台(BS = Base Station)可以覆蓋的範圍(TextBook p.11)
1. Global/Macrocell/Microcell/Picocell 表示 relative size of the area can be covered
2. MS = Mobile System
3. 六邊形的優點(詳細 in Ch05): 可以對區域進行不重疊的分割

* 因為有限的頻寬被分配給無線服務,故應用 multiplexing 技術:
1. Freqency Division Multiple Access = **FDMA**
Frequency band 被分成數個 Subband = Channel,每個Channel 由 BS 分配給 User,多用於 1G cellular systems.

3. Time Divisiob Multiple Acces = **TDMA**
一個 Channel 會被複數個 User 使用,將時間切成 Time Slot (時槽) 後分配給不同的 User,多用於 2G cellular system。分配方式為 round-robin (RR),可以參見 [OS Note](https://hackmd.io/0iIZHCoQQRu3aT0M-N0frw?view#Scheduling-Algorithm)

5. Code Division Multiple Access = **CDMA**
也稱為 Spread Spectrum,利用 Code 的**正交性**使我們能同時傳輸多個 User 的資料。BS 會對每個 User 分配一個唯一的 code,每個 User 的 Data 被統一傳出,再用該 cdoe 解碼 Data。(Textbook p.19)

7. Orthodonal Frequency Division Multiplexing = [**OFDM**](https://ir.nctu.edu.tw/bitstream/11536/45879/7/350507.pdf)
**Intersymbol Interference (ISI)** 由時間延遲的多路徑信號引起的。ISI也對通道的突發錯誤率產生影響。在降低ISI的過程,我們運用 OFDM 以提供高品質的訊號,OFDM選擇頻率時選擇 **symbol time** 的倒數作為頻率,所以在 Frequency domain 上有重疊,與 FDMA 不同。

5. Delay Spread: In many cases, 當訊號從發送到接收端, 信號會遭受一個或多個反射,使無線信號沿著不同的路徑傳播。由於每條路徑的長度不同,因此每條路徑的到達時間也不同。信號的這種模糊或擴散效應被稱為 “delay spread.”
註: Delay Spread 影響 ISI。
9. Space Division Multiple Access = SDMA
不在 midterm 考試範圍,不多贅述
11. Frequency Hopping
為了防禦存在特定頻率的強大敵方訊號 ([jamming effect](https://scholarworks.montana.edu/xmlui/bitstream/handle/1/9021/jamming.pdf?sequence=1)) 而設計的機制,一個使用者在預定時間段使用一個頻道,然後改變到另一個頻道進行傳輸,可以視為 FDMA 和 TDMA 的結合。

## Cellular System Infrastruction
* 過去的無線系統由高功率 transmitter (發射器)覆蓋服務區域,而 Cellular System 用幾個較小的六邊形覆蓋,演化如圖。

* 也就是說,MS 會和其所在 cell 的 BS 進行通訊。BSs 經過 BSC (= BS controller) 連接,而 BSCs 連接至 MSC (= Mobile Switching Center),MSCs 連接至 PSTN (= Public Switched Telephone Network) 和 ATM (= Asynchronous Transfer Mode)。可以說:**A BS consists of a Base Transceiver System (BTS) and a BSC.**

* 在任何 Cellular 系統中,都需要四個 simplex channels 用於 BS 與 MS 之間的交換與同步:
1. **Control channel** 用於交換控制資訊如認證、訂戶資訊、call parameter negotiation 等 hand shake 資訊;**Traffic channel** 用於傳輸實際資訊。
2. 由 BS 往 MS 的 channel 是 **forward channel = downlink**;由 MS 往 BS 的 channel 是 **reverse channel = uplink**。


# Ch02 Probability, Statistics, and Traffic Theories
## Basic Probability and Statistics Theories
* Discrete / Continuous Random Variables
* Discrete
* probability mass function (pmf): $p(k) = P(X = k)$
* cumulative distribution function (CDF): $P(k) = P(X \leq k), for\ all\ k$
* Expected Value & Variance
* Continuous:
* probability density function (pdf): $P(X \subset S) = \int_S f_x(x){d}x$
* cumulative distribution function (CDF): $F_x(s) = P(X \leq x), for -\infty < x < \infty$
* Expected Value & Variance
* Poisson distribution:描述單位時間內隨機事件發生的次數的機率分布,$\lambda$是隨機事件發生次數的數學期望值。
* $P(X = k) = \frac{\lambda^{k}e^{-\lambda}}{k!}$
* $E[X] = \lambda$, $Var(X) = \lambda$
* Geometric distribution
* $P(X = k) = p(1-p)^{k-1}$
* $E[X] = \frac{1}{1-p}$, $Var(X) = \frac{p}{(1-p)^{2}}$
* Binomial distribution
* $P(X = k) = \begin{pmatrix}
n \\
k
\end{pmatrix} p^k(1-p)^{n-k}$
* $E[X] = np$, $Var(X) = np(1-p)$
* Normal distribution
* Uniform distribution
* Exponential distribution
* $f_x(x) = 0,\ x<0;\ \lambda e^{-\lambda x},\ for\ 0\leq x<\infty$
* $E[x] = 1/\lambda, Var(X) = 1/\lambda^2$
### Multiple Random Variables
* Conditional Probability
* Bayes’s Theorem
* Independence
## Traffic Theory
### Poisson Arrival Model
* 在無線網路中,不同的用戶在不同的時間發起 Call,並且 cell 中發起的 call 的順序通常被識別為 Poisson Process。 Poisson Porcess 的rate $\lambda$ 是每單位時間(在很長一段時間內)的 average numner of events。對於時間區間 $[0, t)$ ,發生 n 次 arrival 的機率:
$P_n(t) = \frac{(\lambda t)^n}{n!}e^{-\lambda t}$
* 取時間上任一點 t ,令 $T_1$ 為到下一次 arrival 抵達前的時間差,則:
$P(T_1 > t) = P_0(t) = e^{-\lambda t}$
$\ \Rightarrow$ distribution function of $T_1$: $\ F_{T_1}(t) = P(T_1 \leq t) = 1 - e^{-\lambda t}$
$\ \Rightarrow$ pdf of $T_1$: $\ f_{T_1}(t) = \lambda e^{-\lambda t}$
* 針對一個Queueing的系統,其中有許多的參數和特性,有個簡單且明確的表示方法:**Kendall's Notation**
1. A Distribution of interarrival times of customers
2. B Distribution of service times
3. C Number of servers
4. D Maximum number of customers in system
5. E Calling population size
* For A, B:
* M Exponential distribution (Markovian)
* D Degenerate (or Deterministic) distribution
* Ek Erlang distribution (k 5 shape parameter)
* G General distribution (arbitrary distribution)
* Hk Hyperexponential with parameter k
* Markov process 是一種其中過程的下一個狀態僅依賴於當前狀態的過程。這表示,只要我們知道當前狀態以及從該狀態轉換的機率,我們就能夠預測可能的下一個狀態,而不受過去任何狀態的影響。A Markov chain 是一種離散狀態的馬可夫過程。

對於 State n,我們可以描述:$\lambda_{n-1}P(n-1) + \mu_{n+1}P(n+1) = (\lambda_n + \mu_n)P(n)$
* P(i) 是 state i 的 s.s. 機率
* $\lambda_i$ 是平均 arrival rate
* $\mu_i$ 是平均 service rate
可以推知:
* $\lambda_0P(0) = \mu_1P(1)$
* $P(n) = \frac{\lambda_0...\lambda_{n-1}}{\mu_1...\mu_n}P(0)$
### M/M/1/$\infty$ or M/M/1
* customer 按照 Poisson Distribution(第一個 M)到達,並以先到先服務(FIFO)或先到先得(FCFS)的方式競爭服務(第二個 M),而且只有一個服務器。

* 若平均 arrival rate = $\lambda$,平均 service rate = $\mu$,$P(i)$ 代表有 i customs 的機率,則平衡式為:
* $\lambda P(0) = \mu P(1), when\ i = 0$
* $(\lambda + \mu)P(i) = \lambda P(i-1) + \mu P(i+1)$
* $P(i) = (\frac{\lambda}{\mu})^i P(0), i \geq 1$
* Traffic Intensity: 已知 $P(0)$ 代表 server free。因為 $P(0) > 0$,可以推知 $\rho = \frac{\lambda}{\mu} < 1 = 1 - P(0)$,由此可以推知:
* $P(i) = \rho^i(1-\rho)$
* Practice:
>Consider a cellular system in which each cell has only one channel (single server) and an infinite buffer for storing the calls.
In this cellular system, call arrival rates are discouraged – that is, the call rate is only 𝜆/(𝑛 + 1) when there are 𝑛 calls in the system.
The interarrival times of calls are exponentially distributed.
The call-holding times are exponentially distributed with mean rate 𝜇 .
Develop expressions for the following:
>a. Steady-state probability 𝑝𝑛 of 𝑛 calls in the system.
> 先求 $\rho = \frac{arrival\ rate}{service\ rate}$,且$\mu = \lambda/(n+1)$$\Rightarrow$$\rho = \frac{\lambda}{(n+1)\mu}$
> "The interarrical time of calls are exp. distributed."
>b. Steady-state probability 𝑝0 of no calls in the system.
>c. Average number of calls in the system, 𝐿𝑠
### M/M/S/$\infty$
### M/G/1/$\infty$
# Ch03 Mobile Radio Propagation
## Free Space Propagation and Loss
* 對於一個 Free Space 環境,有 $P_t$ 發射點,球體表面積為 $4\pi d^2$,令 $A_e$ 為發射機有效面積、$G_t$ 為天線增益:
$P_r = \displaystyle\frac{A_e G_t P_t}{4\pi d^2}$
接收端天線增益 $G_r$ 與發射器有效面積 $A_e$ 關係:$G_r = \displaystyle\frac{4\pi A_e}{\lambda^2}$
故 $P_r(Recieve\ Power) = \displaystyle\frac{G_r G_t P_t}{(4\pi d/\lambda)^2}$
可以推得 **$Free\ Space\ loss(L_f) = \displaystyle\frac{P_r}{P_t} = \displaystyle\frac{1}{G_r G_t}(\displaystyle\frac{4\pi d}{\lambda})^2$**
理想情況可以約化成 $L_f(dB) = 32.45 + 20 log_{10}f_c(MHz) + 20 log_{10}d(km)$
註:dBm=10log(mW)
## Propagation Loss in Channel
* $L = L_P L_S L_F$
* $L_P$: 路徑損耗,取決於發射機和接收機之間的距離、載波頻率和地形輪廓。
* $L_S$: slow fading (shadowing),由於相對較小區域內的建築物、道路和其他障礙物引起的傳播條件變化。
* $L_F$: fast fading,由於 MS 的運動而引起的,包括許多繞射波,代表通道的微觀方面。
## Doppler Effect
* $f_r(received/ signal) = f_c(source\ carrier) - f_d(Doppler\ frequency/shift)$
* $f_d = \displaystyle\frac{v}{\lambda} cos(\theta)$ v= moving speed

# Ch05 Cellular Concept
## Capacity of a Cell
* cell 負載主要取決於:
1. Average call arrival rate $\lambda$
2. Average holding time $T$
$\Rightarrow$ 將 traffic load 定義為 $a = \lambda T$
其中,$\lambda = requests / time$
* 保持繁忙 **1hr** 的 servicing channel 在數量上被定義為 **1 Erlang**,是 load 的計量單位。
* Eg. $a = \frac{30\ calls}{3600\ sec}*360\ sec = 3\ Erlang$
* 即 load = arrival rate * hold time
* 引入M/M/S/S系統
* $B(S, a) = blocking\ probability = \displaystyle\frac{\displaystyle\frac{a^S}{S!}}{\displaystyle\sum_{i=0}^{S}\frac{a^i}{i!}}$
* $Efficiency = \displaystyle\frac{Traffic\ nonblocked}{Capacity} = \displaystyle\frac{Erlang*portion\ of\ used\ channel}{number\ of\ channels}$
* 而 Erlang C 值代表 arriving call delay 的機率
## Frequency Reuse
* **$D(reuse\ distance) = \sqrt{3N(number\ of\ cells\ in\ a\ cluster)} R(radius\ of\ each\ cell)$**
$\Rightarrow q(reuse\ fractor) = \frac{D}{R} = \sqrt{3N}$
* Cochannel interference ratio(CCIR): 在 Frequency Reuse 的系統中,在間隔 Reuse Distance 的位置出現重複頻率,會造成些許 interference,此干擾的強度可以寫作 Cochannel interference ratio:
$\displaystyle\frac{C}{I} = \displaystyle\frac{Carrier}{Interference} = \displaystyle\frac{C}{\sum_{k=1}^{M}I_k}$
* Cell Splitting: 在每個新添加的 cell 的中心建立額外的 BS,以便有效處理較高密度的通話。由於新分割 cell 的覆蓋區域較小,傳輸功率水平較低,這有助於減少CCIR。

* Cell Sectoring: 一個全向的天線非常難設計。改為一個天線覆蓋60度或120度的區域;這些被稱為定向天線(directional antennas),它們服務的小區被稱為sectored cells。

# Ch06 Multiple Radio Access
## Intro
* Multiple Acccess Protocols: 為了解決多個 MS Access 單個 BS 時不知道誰該先走的問題:
* 碰撞後解決:1. Random access: ALOHA, CSMA
* 避免碰撞(Conflict-free): TDMA, FDMA, CDMA...
## Contention-based Protocols
### ALOHA


# Final
#### Test Note
1. 111
2. 222
3. Baseband link type
* Polling-based (TDD) packet transimissions
* 必定是 Master-Slave pair, 不會 S-S or M-M
* 一定是 Master 先發;再換 Slave 發
* Master 主動啟動 (可以是詢問是否有資料),M-S 必有資料,S 可以有很多個
* Slave 可以不回傳資料,Slave 回傳時只有 Master 會收到
* Switching 技術:導入藍芽產生的技術
1. Circuit Switching (SCO = Synchronous connection-oriented link):同步、對稱
* 先傳先到、後傳後到:E.g., 藍芽耳機(打電話、聽音樂)
* 一收到馬上丟出去,無 buffer 概念
* Full-duplex:M-S : S-M
2. Packet Switching (ACL = Asynchronous Connection-less link):非同步、非對稱/週期
* 傳送和輸出間有 buffer:E.g., 傳真機
* 非對稱:M-S 和 S-M 的資料量可以不同(我給你 1 個 slot,可能還 3 個 slot)
* 一個 Master 可以有 5 個 Slave;也可以是 5 個 Slave 搭一個 Master (一定是 odd + odd)
* 一定是 6 個 slot 去做配置,一定是 1 + k or k + 1,一定是 odd + odd