1 ns-2 를 를를를 를를 를를를를 를를를를를 NS-2 를 802_11Ext 를를를를 를를를 를를 를를를를 를를를를를 강 강 강 ([email protected]) 강강강강 강강 강 강강 강강강 강강강강강 강강강강강강 2011 강 10 강 26 강
Oct 30, 2014
1
ns-2 를 이용한 최신 네트워크 시뮬레이션
NS-2 의 802_11Ext 클래스를 활용한 무선 네트워크 시뮬레이션
강 문 수 ([email protected])
네트워크 구조 및 분석 연구실조선대학교 컴퓨터공학부
2011 년 10 월 26 일
Contents
• 1. IEEE 802.11 개념 및 알고리즘 설명• 2. 기존 NS2 의 802.11 구현의 문제점 및 성능
오류• 3. 802_11Ext 클래스 소개 및 구조 분석• 4. 시뮬레이션 예제• 5. 802_11Ext 을 기반으로 directional antenna
구현 및 확장 예제
2
1. IEEE 802.11 MAC 동작 원리
- CARRIER SENSING- BINARY EXPONENTIAL BACKOFF 등
3
Why MAC (Media Access Protocol)?
• Single pair transmission
• Multiple pairs transmission
encoding modulation decodingdemodulation TX media
Coaxial cable, Ethernet, WiFi, Optical Fiber, VLC
A sender A receiver
1
3
4
2
5
What happens if there are a lot of simultaneous transmission over the same TX media ?
The characteristics of TX Media:Collision free or Collision ?
TDMA
• Time Division Multiple Access– Time synchronization and scheduling– Centralized coordination
1
3
4
2
5
1 2 3 4 5 1 2
A single TDMA round
RMA
• Random Multiple Access– No central coordination– Packet generation is a random process.– Assuming propagation and transmission delay are so
small.
1
3
4
2
5
Carrier Sensing
Node A
Node B
Node A
Node Bdelayed
Carrier sensing
Carrier SensingData
Ready
8
Carrier Sensing is not enough.
Node A
Node B
Node C
Node A
Node B
Node C
collision
Random Backoff
Node A
Node B
Node C
collision
Node A
Node B
Node C
Random backoff(Contention window[0:31])
Random Backoff
Hidden/Exposed node problem
• WiFi– Not single hop transmission
– Collision Avoidance
Hidden node problem
Exposed node problem
Collision Avoidance
• RTS/CTS exchange– For the hidden node
– For the exposed node
Reliability
• Wireless links are prone to errors.– High packet loss rate detrimental to transport layer
performance. – Mechanism needed to reduce packet rate experienced
by upper layers.
• A simple solution– Acknowledgment (ACK)– Retransmission
14
A B
data
ACK
A single frame transmission
15
Congestion Control
• If there are so many competitors, then?
• BEB (Binary Exponential Backoff)– Doubled contention window size (32 64 128)
16
Node A
Node B
Node C
Random backoff(Contention window[0:31])
13
4
2
5
Other MAC Protocols Issues:Fairness
19
2. NS-2 의 802_11Ext 클래스
기존 ns2 의 802.11 구현 문제점• Wrong collision handling
• No preamble and PLCP header modeling
• No cumulative SINR implementation
• Wrong backoff handling
• Misusage of the network allocation vector (e.g. EIFS)
• Incomplete support for capture
802.11a, b, g 설정 상의 문제
802.11a 의 성능 그래프(basic rate = 6Mbps, data rate = 54Mbps)
More accurate IEEE 802.11 implementation in NS2
MSWiM’07, October 22–26, 2007, Chania, Crete Island,
Greece.
802.11 transmission and reception (1/3)
• Modulation and coding rate
802.11 transmission and reception (1/3)
• PHY layer frame structure
802.11 transmission and reception (1/3)
• Frame reception process– Preamble– PLCP header– Frame
• In transmission– Not allowing to overhear
• In reception– Collision– Capture effect
Preamble Frame body
Revised Architecture
PHY modeling (1/2)
• Power monitor– All information on received signals is processed and
managed in this module.
• PHY state manager
PHY modeling (1/2)
• Frame drop reasons
MAC modeling (1/6)
• Transmission module– The interface to the PHY – RTS, DATA from transmission coordination– CTS, ACK from reception coordination– TX_IDLE and TXing states
MAC modeling (2/6)
• Reception module– Receiving frame– Address filtering– NAV update of channel state manager– RX_IDLE and Rxing states
MAC modeling (3/6)
• Channel state manager
MAC modeling (4/6)
• Backoff manager
MAC modeling (5/6)
• Transmission coordination module
MAC modeling (6/6)
• Reception coordination module
Bug fix for modulation
36
3. NS-2 의 IEEE 802.11 MAC 구현- MAC 프레임의 전송 및 수신 과정
37
IEEE 802.11 in ns-2
• IEEE 802.11 기반의 프레임 송수신 과정– CSMA/CA 기법 , 지수적 Backoff 기법 , RTS/CTS,
재전송 기법 등
• Mac802_11Ext – ns-2 에서 IEEE 802.11 의 MAC 을 추사화한 클래스– mac-802_11Ext.h, mac-802_11Ext.cc, mac-timers.h,
mac-timers.cc
38
802.11 프레임 전송과정• 기존의 구현
– 백오프 (Backoff) 과정 수행– 데이터를 전송하는 노드와 수신하는 노드간에 RTS/CTS
프레임을 교환– 데이터를 전송한 후에 일정 시간내에 ACK 프레임을
수신해야 함 . 만약 ACK 프레임을 수신하지 못하면 데이터를 재전송
• 기존의 구현과 유사하나 TXC 클래스를 통해 기존 백오프의 수행과정의 오류 수정
39
802.11 프레임 전송과정• 상위 계층 (TCP, UDP) 에서 프레임의 전송을
요구하면 , Mac802_11Ext 의 recv() 함수 호출• recv() 함수
40
802.11 프레임 전송과정• handleMsgFromUp() 함수
802.11 프레임 전송과정• handleMsgFromUp() 함수
802.11 프레임 전송과정• prepareMPDU() 함수
802.11 프레임 전송과정• generateRTSFrame() 함수
802.11 프레임 전송과정• generateRTSFrame() 함수
802.11 프레임 전송과정• transmit() 함수
PHY 계층으로 전달
802.11 프레임 전송과정• handleBKStart() 함수
802.11 프레임 전송과정• handleBackoffTimer() 함수
802.11 프레임 수신과정• 기존의 구현
– PHY 에서 구현되어야 할 기능들이 MAC 계층에 구현 전체 프레임 중 첫 비트가 목적지 단말에 도착했을 때 recv()
함수가 호출 전체 프레임이 도착하는 시간 동안 다른 프레임의 신호을
수신하는 경우• 이미 수신 중인 프레임과 충돌
프레임을 수신하는 시간 동안 프레임을 전송• 수신 프레임과 충돌하기 때문에 수신 프레임에 에러가 발생
• PHY 에서 프레임을 수신한 뒤 , MAC 의RXC::handleMsgFromBelow() 함수가 호출
802.11 프레임 수신과정• handleMsgFromBelow() 함수
802.11 프레임 수신과정• handleMsgFromBelow() 함수
802.11 프레임 수신과정• handleACKIndication() 함수
802.11 프레임 수신과정• handleCTSIndication() 함수
802.11 프레임 수신과정• recvDATA() 함수
4. IEEE 802.11 PHY 구현- Wireless PHY Ext 의 클래스 구조
55
IEEE 802.11 기반 PHY 계층• 기존의 구현
– WirelessPhy 클래스 Error Model, Energy Model, Propagation Model 수신한 프레임에 확률에 기반한 비트 에러를 생성 전파 모델에 기반하여 수신 프레임의 시그널 세기에 결정
프레임의 수신 가능 여부를 판단
– WirelessChannel 클래스 프레임의 브로드캐스트를 처리 프레임의 전송 세기 , 전파 모델에 기반하여 전파의 도달 범위를
계산 노드의 위치정보를 이용하여 전송한 프레임을 수신할 이웃 노드을
선택
• wirelss-phyExt.cc
• WirelessPhyExt 클래스 sendDown() 함수
• WirelessPhyExt 클래스 sendDown() 함수
• WirelessPhyExt 클래스 sendUp() 함수
• WirelessPhyExt 클래스 sendUp() 함수
• WirelessPhyExt 클래스 sendUp() 함수
• WirelessPhyExt 클래스 sendUp() 함수
• WirelessChannel 클래스의 sendUp() 함수void WirelessChannel::sendUp(Packet* p, Phy *tifp) { sendUp() 함수 Scheduler &s = Scheduler::instance(); Phy *rifp = ifhead_.lh_first; Node *tnode = tifp->node(); Node *rnode = 0; Packet *newp; double propdelay = 0.0; struct hdr_cmn *hdr = HDR_CMN(p);
프레임을 전송하는 노드프레임의 공통 헤더
… hdr->direction() = hdr_cmn::UP;
… 프레임의 진행 방향을 수신으로 설정
{ MobileNode *mtnode = (MobileNode *) tnode; MobileNode **affectedNodes; int numAffectedNodes = -1, i;
전송하는 노드이웃 노드 리스트를 저장할 배열이웃 노드 수
if(!sorted_) sortLists(); 모든 노드를 정렬 affectedNodes = getAffectedNodes(mtnode, distCST_+ 5, &numAffectedNodes); /* safety */
전송하는 노드와 전송 거리에 따른 이웃 노드 결정
for (i=0; i < numAffectedNodes; i++) { rnode = affectedNodes[i]; if(rnode == tnode) continue;
자신을 제외한 각 이웃노드 마다
newp = p->copy(); 전송할 프레임을 복사 propdelay = get_pdelay(tnode, rnode); 전송 지연 시간 계산 rifp = (rnode->ifhead()).lh_first; for(; rifp; rifp = rifp->nextnode()){ s.schedule(rifp, newp, propdelay); }
각 노드의 다수의 무선 인터페이스가 존재하면 , 각 인터페이스마다Propagation delay 시 뮬 레 이 션 한 후 프레임 전송
} delete [] affectedNodes; 메모리 해제 } Packet::free(p);}
Code analysis #1
Code analysis #2
4. 시뮬레이션 예제 데모
66
5. 802_11Ext 을 기반으로 directional antenna 구현 및 확장 예제
67
Code analysis #1
Code analysis #2
지향성안테나 구현 및 테스트• 구현코드
– antenna.{h, cc}– directable-antenna.{h, cc}– twoground.{h, cc}
antenna.{h, cc}
tworayground.{h, cc}
tworayground.{h, cc}
74
Test script
Simulation results (wd=15)
55 61 67 73 79 85 91 97 104
110
116
122
128
134
140
0.00E+00
1.00E+07
2.00E+07
3.00E+07
4.00E+07
5.00E+07
6.00E+07
7.00E+07
180
55 61 67 73 79 85 91 97 104
110
116
122
128
134
140
0.00E+005.00E+031.00E+041.50E+042.00E+042.50E+04
150
55 61 67 73 79 85 91 97 104
110
116
122
128
134
140
0.00E+00
5.00E-06
1.00E-05
1.50E-05
120
55 61 67 73 79 85 91 97 104
110
116
122
128
134
140
0.00E+00
5.00E-01
1.00E+00
90
Simulation results (wd=60)
55 61 67 73 79 85 91 97 104
110
116
122
128
134
140
0.00E+005.00E+051.00E+061.50E+062.00E+062.50E+063.00E+063.50E+064.00E+06
180
55 61 67 73 79 85 91 97 104
110
116
122
128
134
140
0.00E+00
5.00E+05
1.00E+06
1.50E+06
2.00E+06
2.50E+06
150
55 61 67 73 79 85 91 97 104
110
116
122
128
134
140
0.00E+001.00E+052.00E+053.00E+054.00E+055.00E+056.00E+05
130
55 61 67 73 79 85 91 97 104
110
116
122
128
134
140
0.00E+00
4.00E+04
8.00E+04
90
Q & A
78