2014年12月11日 星期四

Android Studio 1.0 + GitHub

Android Studio跟github再一起 整個就是爽

VCS verson control選擇 GIT

過幾秒再選一次VCS 會發現多很多東西都跟GIT有關
但這些只是local的GIT
必須在選擇
"VCS"->"Import into version control"->"Share Project on GitHub"
打入帳號密碼   你就跟GitHub綁再一起拉XDD

2014年10月7日 星期二

arduino IDE

官方的IDE太難用了

改用Stino  好用一百倍

https://github.com/Robot-Will/Stino

交大資工--新世代無線網路--筆記

mid1

LAW VS WAN -->相對的大小網路
Circuit switching:  傳輸前需先建立連線及所需資源,連線建立後封包皆依循
此連線路徑傳輸,其他人無法使用該連線。 no delay
Packet switching:  傳輸時將資料分成多個資料區塊,封包傳輸路徑由路由器決定。
low teir--> CT2 PACS DECT PHS

1G->AMPS(USA)
2G->GSM(EU) D-AMPS (USA RAN: IS-136(TDMA) and IS-95(CDMA), CN: IS-41)
(data 還是用circuit船)

2.5G->GPRS(circuit and packet)  EDGE(circuit and packet)

3G-> 3GPP(EU  WCDMA 只管 2G GSM轉換到3G)  3GPP2(USA CDMA2000)
(CN 內部支援IP 傳資料-->有packet switch)
3.5G-> HSPA(3GPP)  EV-DO(3GPP2)

3.9G-> LTE(3GPP)   WiMax
(download 100M, up 50M)

4G->LTE-A  WiMax-a
100 Mbit/s for high mobility
1 Gbit/s for low mobility

3GPP SAE and EPS->release 8
EPS-->LTE+SAE
SAE-->only have packet switch, everything is IP, Roaming between 3GPP, non-3GPP
LTE-A-->LTE-advance 加強 新增MIMO

service
first wave->SMS
second wave->low speed data(i-Mode)
current wave-->high speed(MMS game video)

IP-Based Wireless network-->better for growing data and service, 可以直接連上網路


physic layer->transmiss the bit
link layer->error correction
network layer->header , routing, ICMP, flow control
transport layer->TCP UDP

MCHO-->MS detect and initiate the handoff
NCHO-->BS detect and initiate the handoff
MAHO-->MS detect, BS initiate

Inter BS handoff-->same BSC
Inter system handoff-->different BSC

hard handoff-->break then connect
soft handoff-->connect then break

softer handoff-->handoff in same cell
soft handoff-->handoff in different cell
soft-softer handoff-->combine of soft and softer

SDU-->在 soft handoff 的情況下,行動裝置會同時連上多個基地台,此時便需要 SDU
負責同步的問題:
(1) Reverse link  
當行動裝置上傳資料時,資料會傳給所有連線中的基地台,基地台收到後會
往後端網路送,此時 SUD 會從數個基地台接收到資料,並在這些資料中挑
選一個正確率較高的資料來做傳輸。
(2) Forward link  
當行動裝置下載資料時,資料會由所有連線的基地台送達,而 SDU 負責的
便是將由後端網路送來的資料複製並分配到所有與裝置連線的基地台。 

Handoff:  在同一間營運商下切換基地台。
Roaming:  從一家營運商的基地台切換到另一家營運商的基地台。 

CIDR-->原本的預設的方法不夠用  更有彈性一點就是用CIDR 想要多少host就給你多少

ARP-->廣播  尋找MAC

Gratuitous ARP-->檢查重複IP or 告知其他人要更新table了

Proxy ARP-->就是router做的事,source以為他送給了destionation,但事實上是送給router

limited broadcast-->只有目前所在的區域網路 (LAN) 上作廣播255.255.255.255
Directed broadcast-->對某個網域廣播140.113.255.255

unicast-->只傳給1個人
multicast-->傳給一些人
broadcast-->傳給所有人

What is the major difference between Transmission Control Protocol (TCP)
and User Datagram Protocol (UDP)?
TCP:(1)可靠資料傳輸,遺失資料會重傳
            (2)具有 flow control(避免接收端 overflow)
            (3)具有 congestion control(避免網路塞車)
UDP:(1)不保證資料一定會送達,遺失資料不會重傳
            (2)沒有 flow control
            (3)沒有 congestion control 

 For real-time traffic, why the network usually does not need to retransmit the
lost packets?
因為即時傳輸的資料都具有時效性,時間一過就不需要那些資料,故不需重
傳。例如現場直播的影片資料,若在中途發生遺失,後來又被重傳,則會造
成過去的影像被播出來的結果,故不需重傳。 

paging in cellular network:
MS可能會idle,此時MS 只會監聽paging channel,BS如果要喚醒某台MS就會送pagin message,來喚醒該機器

TMSI
由VLR給的隨機號碼,有區域性,所以換一個VLR 就拿一個新的, network可以隨時更改TMSI的值

IMSI
是獨一無二 的號碼來上GSM and UMTS 網路 或是當TMSI更新失敗時使用.
IMSI儲存在SIM卡中
IMSI很少被傳送->避免被竊取盜用.
----------------------------------------------------------------------

mid2

ipv6

V6 VS V4 -->IP長度 header彈性
router 只看hop by hop extension header
fragmentation-->fragmentable part only at destination, unfragmentable is each intermediate node
source routing-->依造我的路徑走,且IPV6的destination IP 會是next router 的IP  會一直改
global-->全球對外IP
site-->區域(private
link-->更private  use during auto-configuration and when no routers are present
interface ID-->對低的64bit  跟MAC依樣
neighbor discovery-->V6 沒有ARP而是是用address resolution,利用ICMP的adv and sol (用SOL問  有人用adv直接回
router discovery-->用ICMP的adv sol (router用adv告訴大家我是router   有host用sol問誰是router)
redirection-->建議host要怎麼走路徑比較好
autoconfiguration-->stateless(由router 的prefix跟interface id自動生成IP)   stateful(DHCP)
DAD-->檢查有沒有重複IP(用在stateless)

3GPP release 5

PLMN-->一個機器提供服務(一個電信業者
RAN
  • GERAN-->GSM/EDGE RAN(2G  (BSS(BSC+BTS ))
  • UTRANS-->UMTS RAN(3G  (RNS(RNC+nodeB) )
CN
  • CS (GMSC + MSC/VLR)
  • PS(GGSN+SGSN)
  • IMS
  • Information Server(HSS(HLR改版 使用者訊息跟位置)+  EIR(紀錄IMEI)+ Auc(認證使用者,加密訊息))
MS->in GSM
UE->3G
  • ME-->除了SIM卡以為的手機部分(TE軟體+MT硬體+TA天線)
  • USIM-->sim卡
IMEI-->手機序號2G
TMSI -->由MSC/VLR給的隨機號碼, network可以隨時更改TMSI的值,可以更IMSI做轉換,避免IMSI被盜用
TMSI和P-TMSI分別是CS-domain和PS-domain的臨時IMSI
IMSI-->是獨一無二 的號碼來上GSM/UMTS 網路 或是當TMSI更新失敗時使用.IMSI很少被傳送->避免被竊取盜用.

MSC-->可以分成MSC server(處理呼叫控制和行動管理) + CS-MGW(處理 switch,媒體轉換,夾帶訊息處理和夾帶訊息傳輸) 好管理 有彈性
SGSN-->位置紀錄(like VLR),route(UE跟GGSN的中間人),paging(喚醒sleep UE)
GGSN-->負責封包在PLMN的進出,並轉送給SGSN(接著再轉給UE

SGSN number and GGSN number-->跟一些沒有IP的協定溝通時使用

MAP-->HLR+VLP衍生版,多了移動 SS7之一
SS7-based-->VLR+HLR跟緊急電話處理,119 110 會通就這個

IMS-->Support real-time voice and multimedia IP services ,有一個SIP協定在處理

RAN Internal Interface
  • GERAN-->Abis + Um
  • UTRAN-->Iub + Iur + Uu

RAN to CN Interface
  • GERAN-->A or Iu-CS (CS) + Gb or Iu-PS (PS)---->要就A/Gb 一起 不然就是Iu系列
  • UTRAN-->Iu-CS (CS) + Iu-PS(PS)

PDP-->在PS內部傳輸,想成IP協定  
PDP context會建立在GGSN跟SGSN  用來記錄一些UE的資訊(包含PDP address( 可能是IP 或是 X.25) +IMSI +APN + tunnel ID + QOS )
PDP 分兩個state
  • active-->GGSN可以找到UE,RAB在需要傳資料的時候可能才建立
  • inactive-->GGSN找不到UE,GGSN需要轉成active( PDP Context Activation),UE在換手之後不會更新PDP context,但是會更新HLR所以GGSN還是可以利用Network-Requested PDP Context Activation 找到UE
PDU-->想成packet

traffic bearer-->傳送不同entities(3GPP中存在的區塊like SGSN GGSN)的連線 
把bearers分割-->可以省電  有獨立性  好管理 有彈性  允許不同協定應用

在RAB中還有分RRC  RANAP連線
  • RRC-->Radio Bearer 的部分(有signaling Radio Bearer + traffic Radio Bearer )控制跟傳輸
  • RANAP-->Iu bearer(Iu signaling+Iu traffic)

UE連上3GPP 的PS步驟
  1. GPRS attach-->認證且建立連線(SMS是夾帶在這邊傳出去的
  2. PDP context activation -->去要求一個PDP 位置
  3. RAB Establishment-->可以開始接收資料
  4. IMS註冊(option)-->如果UE需要用到即時語音服務或是 mulitmedia

GTP-->用來在RNC跟SGSN  還有SGSN跟GGSN中間 或是兩個SGSN之間 的routing,是使用tunnel方式

    

有GPRS attach跟IMSI attach-->一個PS一個CS  可以同時進行

PDP address-->可以由GGSN指派,或是由外部網路指派

PDP context activation  -->可能會有PDP address allocation,會建立CN bearer ,RAB bearer
  • 由UE發起PDP 建立-->發起Mobile-Initiated PDP Context Activation(PDP Address, NSAPI(想成PDP context的ID), APN , PDP type, qos)
  • 由網路發起PDP 建立-->可能是外面有封包進來要傳給UE,但是GGSN發現PDP不存在,所以要建立,做的事跟上面依樣,但是GGSN必須知道UE的資訊(IMSI 之類的 讓他可以利用HLR找到UE)Network-Requested PDP Context Activation
APN-->要連上哪種網路,在3GPP通常是GGSN,APN可透過SGSN中DNS翻譯得到 GGSN的IP address,讓SGSN知道去找哪個GGSN
Select a service (or a GGSN) in the PS domain or a contact point in an external packet network  

Tunnel Endpoint Identifier (TEID):TUNNEL的編號

PDP context modification-->PDP address 只有GGSN可以說他要更動,  QOS誰都可以說他要改

RAB 建立-->只能有SGSN啟動,會把剩下動作交給RNC來處理,RNC會用RRC來跟UE溝通

SGSN跟GGSN的ingerface
  • Gn->SGSN跟GGSN在同PLMN
  • Gp-->SGSN跟GGSN不同PLMN
GTP有兩個種協定
一個GTP-C可以控制多個GTP-U,每個UE會有一個GTP-U
  • GTP-C-->控制GTP-U tunnels,  PDP contexts, location management, and mobility management 
  • GTP-U--> 負責傳user資料  establish and manage GTP tunnels used to tunnel user packets
GTP 訊息
  • tunnel management--> activate, modify and remove PDP Contexts and their associated GTP tunnels
  • location management-->由GGSN 從HLR找地點訊息
  • mobility management-->used between SGSNs to transfer mobility related information
  • path management--> used by a node to determine if a peer node is alive and to inform the peer node of what GTP header extensions it can support 
Iu-PS interface
user傳資料是用GTP-U
控制"不是"用GTP-C
  • Tunnel Management: establishing, maintaining and releasing the GTP tunnels between a RNC and a SGSN 
  • RABr Management: establishing, maintaining and releasing RAB
  • Radio Resource Management: Radio Resource Admission Control by RNC 
  • Mobility Management: handoff between RNC; paging; positioning services 

Gi->GGSN跟外部網路的連線
Gr-->SGSN跟HLR
Gc-->GGSN跟HLR
Gs-->SGSN跟MSC/VLR



----------------------------------------------------------------------

 mid3

 
2G

PDCP
  1. Header compression for higher-layer data streams(IPHC  ROHC)
  2. 把上層資訊轉成RLC看得懂
  3.  Maintaining data transmission orders for upper layer protocols that have such requirement 
RLC
  1. 控制radio interface
  2. MN 可以有多個RLC 連線
  3. 支援 broadcast info RAB and CN to MN , RRC and RB 的建立與維護 , pagin , power control ,radio 測量與回報 ,MN跟RAN的加密
GMM SM SMS
  1. GMM:維護GPRS attach and detach ,加密 
  2. SM: 維護PDP contrxt activation and modification and deactivation
  3. SMS: 簡訊
連到外部網路
  1. 跟外部網路註冊
  2. 外部網路動態給IP
trandparent access--> GGSN只有負責轉傳
non transparent-->GGSN有參與成為傳輸的一部分(GGSN 是MIP的FA )

MIP

Mobility
  1. terminal mobility:裝置移動 連線要不斷
  2. user mobility:人換地方還可以繼續使用
  3. service mobility:某個服務 換裝置 還是保持
Basic functional component
  1. location management
  2. packet delivery
  3. handof and roaming
  4. network access control(3A 認證 授權 收錢)
Location update

location area-->紀錄MN現在大概在哪個地區,不需要知道明確位置(沒資料傳輸時)  RAN跟CN可以記錄不同的location area
movement base-->看移動多少Cell更新一次
distance base-->看距離多少更新一次
implicit base-->跟著BS的signaling 溝通時更新

location discovery(paging)
paging area-->paging的範圍 不需要跟location area依樣
MN收到要找他的paging 就要回報他目前確切位置
blanket paging-->地毯式搜索  全部都發出去-->簡單且快  但是浪費
sequential paging-->把paging area在分割成小單元  一個一個單元找-->比較慢  但是不浪費

direct delivery-->直接對傳(需要知道MN在哪  CN需要多增加協定 好知道MN繪製)
relayed delivery-->有中間人先代收 再轉交(中間人會成為bottleneck)

handoff需要多layer溝通才能達到  需要80.21來穿透layer


MIPV4

Network Access Identifier--> a standard way of identifying users who request access to a network

agent adv->ICMP+Mobility Agent Advertisement Extension+Prefix-Lengths Extension

movement detection-->lifetime 過期 , 新舊network prefix改變 代表換網域
gratuitous ARP-->告知他人要改cache
Proxy ARP-->幫別人回答ARP request

RRQ
  1. discover home agent addr-->directied broadcast到home domain ,HA收到會回復RRP(達帶addr)
  2. discover home addr-->home addr填0   ,HA 會回傳RRP夾帶addr
  3. renew registration
  4. deregister-->time=0

RRP
  1. SPI-->used to select the authentication algorithm, mode, and secret used in computing the authenticator
  2. authenticator-->經過計算出來的數字  如果封包被更動  這數字會對不上

CVSE-->如果收到看不懂的cendor extension  就直接全部丟棄
NVSE-->如果收到看不懂的vendor extension  不管該extension 繼續傳


List the pros and cons of Mobile IPv4.
優點:
(1) 網路架構簡單。 
(2) 大多採用原本網際網路的協定與格式,只新增了 Registration
Request(RRQ)與 Registration Reply(RRP)。
(3) Correspondent Host(CH)不用知道對方是固定位址還是會移動的。
(4) CH 只要記錄對方的 HoA 即可,不需要因為對方更換 IP address 而更新。
(5) 確保移動時(更換 IP address)連線不中斷。
缺點:
(1)  存在 Triangular Routing Problem。(傳輸路徑因為要經過 Home Agent 而
拉長)
(2)  Mobile IPv4 的訊息需經過 Home Agent(HA),因此 HA 的處理速度及
Home Agent 的網路頻寬會影響傳輸速率,導致 HA 可能會變成整個網路
傳輸路徑的一個瓶頸,影響整體效能。
(3)  存在 Handoff 延遲問題。
(4)  存在與 Foreign Agent 取消註冊的問題。
(5)  支援其他行動管理的能力有限,例如 paging。
(6)  可能存在端點對端點之間傳輸的長時間延遲。 


MIPV6

只有CO-COA
用nighbor discovery去檢查有沒有移動(router adv 中的 prefix
bind update->RRQ
bind ack->RRP


packet delivery
  1. bi-directional-->VN沒有mipV6 (就是reverse tunnel
  2. route opt

用routing header讓CN送給MN的 destination可以改變
用destination options header讓MN送給CN的時候 可以改source


mobility header
包含BU跟BA訊息



----------------------------------------------------------------------

 final

 

 
PMM-> a set of information used by the network to track the mobile’s location 
處存於MS and SGSN
PMM-DETACHED State
-->SGSN找不到UE(連GPRS Attach都沒有

PMM-CONNECTED State
-->SGSN知道UE在哪個RNC的cell

PMM-IDLE State
-->SGSN知道UE在哪個RA

PDP context 在connected and idle 都是active->
  1. Reduce the time for a mobile to change from PMM-IDLE state back to PMM-CONNECTED state 
  2. Make it easier for the PS CN domain to support paging(GGSN 會認為MS一直活著  不知道paging的發生)
同步問題->MS and SGSN 沒有同步,可以在RAU跟paging的時候同步


location area->CS,LAI
routing area->PS,RAI
LA會包含一堆RA

PMM-IDLE:
  1. RRC-IDLE->SGSN知道MN在RA
  2. RRC-connected-->SGSN知道MN在RA (因為RRC 是 CS跟PS共用 ,這邊是PS 沒用  CS有用
PMM-connected:
  1. RRC-connected-->SGSN知道MN在哪個RNC


RAU的執行
  1. MS到一個新的RA
  2. MS發現RAU timer過期
  3. 網路要求從新建立
  4. MS更改netwrok capability (info 認證 加密  跟radio無關的

Intra-SGSN RAU
  1. MS 要在PMM-connected
  2. MS送一個RAU request給SGSN(包含P-TMSI. old RAI. P-TMSI signature. type. netwrok capability
其中的Old RAI 是用來區分到底是intra 還是inter交換
P-TMSI 是PS的TMSI 
P-TMSI signature-->
 3-octet number assigned to the mobile by the SGSN that assigned the P-TMSI
 used by the SGSNs to authenticate a P-TMSI
 can also be used by the mobile to authenticate the network node that is assigning the P-TMSI

inter-SGSN
  1. target SGSN會送一個SGSN context request給source SGSN,來驗證MS的P-TMSI是不是合法的
  2. 如果source SGSN確定是合法的 會回傳PMM context and PDP context給target
  3. 如果source SGSN認為是不合法的,target 就去跟MS做認證,去查是不是合法使用者(因為如果source 可以認證 就可以跳過這一步  比較快


Serving RNS relocation

在UE換RA的時候
src RNC會先把signal and traffic 轉給dst RNC
之後再建立新連線path
這樣可以加速handoff

source RNC 會送 Relocation Required 給source SGSN 包含
  1. type: UE involved or not
  2. source RNC ID
  3. target RNC ID
  4. Source RNC to target RNC transparent container:info security information, RRC context

Hard Handoff

Inter-RNC hard handoff without Iur

Relocation Request Acknowledge:包含Target RNC to Source RNC Transparent Container,會有target RNC 的頻率


paging

  1. PMM-IDLE
  2. SGSN 送RANAP paging message 給RA底下的RNC
type 1 paging:use paging channel
type 2 paging:use dedicated RRC channel


service request procedure

  1. MS在PMM-IDLE-->建立signal 變成PMM-connected
  2. MS在PMM-connected-->更改PDP context
service type:
DATA->建立控制訊號 跟RAB
signaling-->建立控制訊號

Service Request is acknowledged
 Mobile in PMM-CONNECTED state and Service Type is DATA: SGSN will return a Service Accept
 Mobile in PMM-IDLE state and Service Type is SIGNALING: SGSN does not send any explicit signaling message 



安全的要點
  1. Authentication: validate authentic identity
  2. Authorization: access control
  3. Integrity: protection from unauthorized change
  4. Confidentiality or Privacy: keep information private such that only authorized users can understand it
  5. Availability: outsider cannot block legitimate access
  6. Non-repudiation: supply undeniable evidence to prove the message transmission and network access

網路攻擊:
Passive attacks:監聽
active attacks:
  1. DOS
  2. 中間人攻擊
  3. replay
  4. Masquerade
主要兩種演算法

secret-key-->加密 解密 同一把 (DES

public-key-->加密 解密 不同把 (RSA

Transposition Ciphering-->把明文 換位置  打亂順序
Substitution Ciphering-->把明文 依造規定替換掉

 Message Authentication

來確保明文的完整性 跟 來源可信
利用Message Authentication Code (MAC)

hash function:
unkey:MD5  SHA-1
keyed:HMAC


數位簽章
證明來源是對的

Digital Signature Standard (DSS)-->Specify algorithms for computing digital signatures 

PKI-->把public key給一個CA來保管
CA會把public加密,當CA傳給使用者的時候 在解密得到真正的public key,避免key被偽造
加密過的public key-->PKC

public key 加密
是把明文用public key加密,解密用private key
public key 認證
是把明文用private key加密  解密用public key

IPsec

是一個在network layer的加密
  1. AH->integrity and data origin authentication of the IP
  2. ESP->confidentiality and authentication(integrity and data origin authentication)(optional)
SA-->用來溝通要用哪個加密演算法之類的
A set of information maintained by the two nodes that defines:
 Which security services will be supported
 How these security services will be provided
可以建立一大堆SA,之後說要用哪一個SA就好

SAD-->因為SA資料量太大,無法夾帶在IP,所以要存在雙方電腦上

SPI-->一個SA的編號


AH

Authentication Data
  1. ICV=MAC (用來檢查integrity 
  2. 有用secret key -->authentication 
  3. 會把整個封包 包進來算(除了會隨著傳送改變的值
ESP
  1. AH 的保護都有
  2. 但是不保護IP header  ,只保護 護蓋的範圍
  3. padding-->有些 加密演算法 會要求固定的byte長度
  4. next header-->  indicating what upper-layer protocol was protected
 如果雙方電腦 沒有可用的SA  那在傳封包之前 要先建立IKE SA來溝通建立新的SA


 Authentication, Authorization, and Accounting (AAA)

RADIUS-->量大效率會變低 scalability 

Diameter-->
  1. Provide a base protocol to support AAA
  2. Typically not used alone unless used only for accounting
  3. Peer-to-peer protocol
     A peer could be a client, agent, or server
  4. A agent could be a relay, proxy, redirect, or translation agent

GSM IS-41

GSM-->secret key  Ki 存在SIM卡
IS-41-->A-Key 是寄信給user 自己輸入手機

Authentication and Key Agreement (AKA)
  1. GSM-->網路收到手機的request,就challenge (主動連上網路
  2. IS-41-->網路會定期廣播challenge(被動連上網路

GSM的安全

Three algorithms
 A3: authentication -->challenge 用
 A5: stream cipher algorithm-->加密用
 A8: cipher key generation

弱點:
  1. 沒有認證網路
  2. 會把ki 給visted network(漫遊的時候 給其他電信商 資料
  3. CN 內部沒加密
  4. Kc 不夠長
  5. 不是end to end 加密
  6. A5 有安全疑慮

GPRS
在A5那邊做更動-->變成GEA
再GSM DATA會當成input拿去加密-->會算比較久  如果演算法複雜的話

GPRS 會把DATA 拿去做XOR-->加密速度比較快 因為XOR的電路很簡單

3GPP

跟GPRS 差不多 只是演算法不一樣
多了integrity 跟雙互認證
在RAN跟CN都會加密

AKA->
Mutual authentication 
 Establish a new pair of cipher and integrity keys
HLR會傳一大組AV給visted network, 自己選一組AV來使用


Authentication Vector (AV)
  1. Ordered based on sequence number
  2. Consists of the following components
     a random number RAND
     an expected response XRES
     a cipher key CK
     an integrity key IK
     an authentication token AUTN 
Anonymity Key (AK)-->用來把SQN藏起來,不要直接被看到


優點:
  1. 有雙向認證
  2. visted network只會拿到算好的值
  3. RAN CN都有加密


 UMTS Encryption Algorithm (UEA)-->加密資料用
  1. Access Link Data Confidentiality 
  2. For data and some signaling traffic
  3. Applied on dedicated channels between ME and RNC
 UMTS Integrity Algorithm (UIA)-->確認資料完整
  1. Access Link Data Integrity 
  2. Shall be implemented in the ME and in the RNC
  3. Most control signaling messages between ME and RNC are integrity protected 
  4. Integrity protection should be applied at the RRC layer


----------------------------------------------------------------------