1. Trang chủ
  2. » Luận Văn - Báo Cáo

Phát triển bộ tiện ích APE Testbed hỗ trợ kiểm thử mạng di dộng Ad-hoc tt

65 2 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

HỌC VIỆN CƠNG NGHỆ BƯU CHÍNH VIỄN THƠNG - TRẦN DANH HƯNG PHÁT TRIỂN BỘ TIỆN ÍCH APE TESTBED H TR IỂ TH NG DI ỘNG AD-HOC LUẬN VĂN TH C SĨ Ỹ THUẬT TP HỒ CHÍ MINH – NĂM 2016 HỌC VIỆN CƠNG NGHỆ BƯU CHÍNH VIỄN THƠNG - TRẦN DANH HƯNG PHÁT TRIỂN BỘ TIỆN ÍCH APE TESTBED H TR IỂ TH NG DI ỘNG AD-HOC Chuyên ngành: Hệ thống thông tin ã số: 60.48.01.04 LUẬN VĂN TH C SĨ Ỹ THUẬT NGƢỜI HƢỚNG DẪN KHOA HỌC : TS LÊ TRUNG QUÂN TP HỒ CHÍ MINH – Năm 2016 i LỜI CA OAN Tơi cam đoan cơng trình nghiên cứu riêng Các số liệu, kết nêu luận văn trung thực chƣa đƣợc cơng bố cơng trình khác Tp HCM, ngày 01 tháng 09 năm 2016 Học viên thực luận văn Trần Danh Hưng ii LỜI CẢ ƠN Tôi xin trân trọng cảm ơn thầy Lê Trung Quân, giáo viên hƣớng dẫn tôi, ngƣời bảo, hƣớng dẫn, động viên suốt trình thực luận văn Nhờ hƣớng dẫn tận tình thầy mà tơi vƣợt qua khó khăn chun mơn q trình thực luận văn Tơi xin gửi lời cảm ơn đến quý thầy cô trƣờng Học viện Công nghệ Bƣu Viễn thơng tạo điều kiện học tập truyền đạt nhiều kiến thức quý báu trình học cao học Xin cảm ơn bạn lớp Cao học Hệ thống thông tin M14CQIS01-N, đặc biệt ban cán lớp, đồng hành hỗ trợ tơi suốt q trình học Cuối tơi xin cảm ơn gia đình đồng nghiệp tơi giúp đỡ tơi q trình thực luận văn Tp HCM, ngày 01 tháng 09 năm 2016 Học viên thực luận văn Trần Danh Hưng iii MỤC LỤC LỜI CAM ĐOAN .i LỜI CẢM ƠN ii MỤC LỤC iii DANH MỤC CÁC KÍ HIỆU, CÁC CHỮ VIẾT TẮT v DANH MỤC CÁC BẢNG .vi DANH MỤC CÁC HÌNH vii CHƢƠNG - TỔNG QUAN T NH H NH NGHI N C U APE TESTBED V MỤC TI U LUẬN VĂN Tổng quan 1.1 1.1.1 Mạng di động Adhoc (MANET) 1.1.2 APE testbed 1.1.3 So sánh APE testbed công cụ hỗ trợ kiểm thử mạng MANET khác 1.1.4 Tình hình nghiên cứu/phát triển APE testbed 1.2 Mục tiêu luận văn 1.3 Tóm tắt phƣơng pháp luận, kết đạt đƣợc 1.4 Phạm vi, giới hạn đề tài 1.5 Cấu trúc Luận văn CHƢƠNG 2.1 Thực cập nhật công cụ APE testbed Phân tích APE testbed 2.1.1 Cấu trúc APE testbed 2.1.2 Các thành phần cần đƣợc cập nhật 11 2.1.3 Phân tích Kernel patches 13 2.1.3.1 MacKill 15 2.1.3.2 Wireless driver hook 16 2.1.4 Các giao thức định tuyến 18 iv Tiến hành cập nhật APE testbed 19 2.2 2.2.1 Cập nhật MacKill 19 2.2.2 Cập nhật Wireless driver hook 22 2.2.2.1 Nguyên tắc chung 22 2.2.2.2 ath9k 22 2.2.2.3 rt2800usb 29 2.2.2.4 Phƣơng pháp không cần driver hook 30 2.2.3 Cập nhật giao thức định tuyến 33 CHƢƠNG 3.1 Đánh giá kết 34 Cập nhật ath9k 34 3.1.1 Cập nhật mã nguồn 34 3.1.2 Đánh giá 35 3.2 Cập nhật giao thức định tuyến 37 3.2.1 Cập nhật mã nguồn 37 3.2.2 Đánh giá 39 3.2.3 Đánh giá tổng quan 40 CHƢƠNG - Kết luận 41 DANH MỤC T I LIỆU THAM KHẢO 42 PHỤ LỤC 43 v DANH MỤC CÁC KÍ HIỆU, CÁC CHỮ VIẾT TẮT Viết tắt Tiếng Anh Tiếng Việt MANET Mobile ad-hoc network Mạng di động Ad-hoc AODV Ad hoc On-Demand Distance Vector Định tuyến Adhoc dựa vector Routing khoảng cách cần DSR Dynamic Source Routing Định tuyến nguồn động OLSR Optimized LUNAR SNR Link State Routing Giao thức định tuyến trạng thái Protocol đƣờng nối tối ƣu Lightweight Underlay Network Ad Định tuyến Ad-hoc mạng tảng hoc Routing đơn giản Signal-to-noise ratio Tỉ số tín hiệu nhiễu MAC address Media access control address Địa điều khiển truy cập thiết bị vi DANH MỤC CÁC BẢNG Bảng 2.1: So sánh công cụ kiểm thử mạng di động adhoc Bảng 3.1: So sánh thông tin từ tài liệu APE testbed thực tế 18 Bảng 4.1: Danh sách API cần thay 37 vii DANH MỤC CÁC HÌNH Hình 1.1: Sơ đồ mạng di động adhoc Hình 1.2: Sơ đồ hoạt động cơng cụ APE testbed Hình 3.1: Danh sách file thƣ mục dist Hình 3.2: Danh sách file dƣới thƣ mục kernel 10 Hình 3.3: Danh sách file dƣới thƣ mục src 11 Hình 3.4: Các patch cho kernel 14 Hình 3.5: Cấu trúc MacKill 15 Hình 3.6: Cấu trúc driver hook 16 Hình 3.7: Cấu trúc MacKill cách MacKill xử lý 19 Hình 3.8: So sánh sk_buff kernel version 20 Hình 3.9: Minh họa cấu trúc driver ath9k 23 Hình 3.10: Danh sách file ath9k 24 Hình 3.11: Danh sách kernel module quan hệ ath9k 24 Hình 4.1: Kết build sau cập nhật ath9k 35 Hình 4.2: Kết cập nhật cho ath9k 36 CHƯƠNG - T NG QUAN T NH H NH NGHI N C U APE TESTBED V 1.1 ỤC TI U LUẬN VĂN T ng quan APE Testbed công cụ phần mềm hỗ trợ kiểm thử mạng di động Ad-hoc (MANET) 1.1.1 Mạng di động Adhoc (MANET) Mạng di động ad-hoc (mobile ad-hoc network – MANET [3]) loại hình mạng khơng dây thiết bị di động có khả tự cấu hình liên tục Di động khơng phải nói tới loại điện thoại di động, mà có nghĩa thiết bị mạng di chuyển đƣợc Khác với mạng không dây thƣờng gặp với thiết bị kết nối trực tiếp với Wifi router trung tâm, mạng di động ad-hoc thiết bị khơng có trung tâm mà thay vào chúng kết nối lẫn với vai trị bình đẳng Khi thiết bị di chuyển, thƣờng xuyên thay đổi dƣờng kết nối (đến thiết bị gần lúc di chuyển) H nh 1.1: S ng i ng a h Mạng di động Adhoc đƣợc sử dụng trƣờng hợp sau 4]: 42 DANH MỤC TÀI LIỆU THAM KHẢO [1] Jeroen Hoebeke, Ingrid Moerman, Bart Dhoedt and Piet Demeester (2004), “An overview of mobile ad hoc networks: applications and challenges”, Journal of the Communications Network, volume 3, p.60-66 [2] VipinM and Srikanth S (2010), “Analysis of Open Source Drivers for IEEE 802.11 WLANs”, Wireless Communication and Sensor Computing 2010 [3] https://en.wikipedia.org/wiki/Mobile_ad_hoc_network, truy nhập ngày 20/06/2015 [4] https://en.wikipedia.org/wiki/Vehicular_ad_hoc_network, truy nhập ngày 20/06/2015 [5] http://apetestbed.sourceforge.net/, truy nhập ngày 20/06/2015 [6] https://wiki.emulab.net/Emulab/wiki/software, truy nhập ngày 20/06/2015 [7] http://doplab.unil.ch/sites/default/files/ManetLab.pdf, truy nhập ngày 20/06/2015 [8] https://www.ietf.org/mail-archive/web/manet/current/msg07948.html, truy nhập ngày 20/06/2015 [9] http://permalink.gmane.org/gmane.linux.drivers.ath9k.devel/6103, truy nhập ngày 20/06/2015 [10] Rajni Sobti (2015), “A Study on Challenges and Issues on MANET”, International Journal of Advanced Research in Electrical, Electronics and Instrumentation Engineering Vol 4, Issue [11] H Lundgren, D Lundberg, J Nielsen, E Nordstrom C Tschudin (2002), “A large-scale testbed for reproducible ad hoc protocol evaluations”, Wireless Communications and Networking Conference, 2002 WCNC2002 2002 IEEE 12] David Lundberg(2005), “Ad hoc Protocol Evaluation and Experiences of Real World Ad Hoc Networking” 43 PHỤ LỤC From 579e251d9e7e8aa4c5554c437e952a6238a2000f Mon Sep 17 00:00:00 2001 From: "T.Hung" Date: Sun, 19 Jun 2016 14:27:39 +0700 Subject: [PATCH] Support APE testbed Support APE testbed by expose signal, noise, and MAC address Thông through /proc/net/superspy chung tin APE testbed will read this data and analyse Signed-off-by: T.Hung drivers/net/wireless/ath/ath9k/main.c | 336 ++++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/recv.c | 16 ++ files changed, 352 insertions(+) diff git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index cc15399 9973193 100644 - a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -18,6 +18,57 @@ #include #include "ath9k.h" #include "btcoex.h" +#include + Thêm header cần thiết 44 +#include /* For KERNEL_VERSION */ +#include /* For poll_wait */ + +/**** APE_BEGIN ******/ +/************************************************************************/ +/* These variables, functions, and macros are used for the devimep * + * character device, which will be used to write IP addresses into * + * user space MSI * +* */ +/* the size of the buffer in the character device +#define DEVIMEP_BUFSIZ */ 512 +/* This is used to hold devimeps major number MSI */ +int devimep_major; + +/* This is the wait queue that user space processes can sleep on MSI */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)) +static DECLARE_WAIT_QUEUE_HEAD(devimep_wait); +#else +static struct wait_queue *devimep_wait; +#endif + +/* Macro to check the status of the devimep buffer MSI */ +#define DEVIMEP_BUF_EMPTY (chardev.buf_wpos == chardev.buf_rpos) +/* The character device itself, buffer and access offsets +struct chardev +{ + volatile int buf_wpos; + volatile int buf_rpos; + char *buf; + int open; +} chardev; */ 45 +/* this is just the declaration of the devimep write function */ +int devimep_write(char *buf); +/**************END OF DEVIMEP CHARACTER DEVICE SPECIFICATION*************/ + +inline void +ath9k_superspy_gather (u_char *mac, int8_t signal, int8_t noise); + +#define SUPERSPY_BUFFER_SIZE 2900 + Các khai báo +/* Buffer to hold spy information */ +static char *spy_buffer = NULL; + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) +#define proc_net init_net.proc_net hàm kiểu liệu cần cho APE testbed Chú +#endif ý kích thƣớc + bufer 2900 +/**** APE_END ******/ + static void ath9k_set_assoc_state(struct ath_softc *sc, struct ieee80211_vif *vif); @@ -656,6 +707,232 @@ void ath_reset_work(struct work_struct *work) ath_reset(sc); } + +/******* APE_BEGIN ********/ +/* these are added for the devimep character device MSI */ +int devimep_open(struct inode *inode, struct file *filp) +{ 46 + chardev.buf = (char*)kmalloc(DEVIMEP_BUFSIZ, GFP_KERNEL); + chardev.buf_wpos = chardev.buf_rpos = 0; + chardev.open = 1; + return 0; +} + +int devimep_close(struct inode *inode, struct file *filp) +{ + if(chardev.buf) + + kfree(chardev.buf); return 1; +} + +static ssize_t devimep_read(struct file *filp, char *buf, size_t count, Các + cho devimep loff_t *l) xử lý device (một +{ + int read; device + char temp_buf[4]; trợ) + + // trying to read nothing? + if(!count) return 0; + + // trying to read but not yet opened? + if(chardev.open == 0) return -EAGAIN; + + // trying to read from empty buffer? + if(DEVIMEP_BUF_EMPTY) + return -EAGAIN; + + for(read=0;read= KERNEL_VERSION(2,4,0)) + static struct file_operations devimep_fops = { + owner: THIS_MODULE, + read: devimep_read, + write: NULL, + poll: devimep_poll, + open: devimep_open, + release: devimep_close, +}; +#else +static struct file_operations devimep_fops = +{ + NULL, + devimep_read, + NULL, + NULL, + devimep_poll, + NULL, + NULL, + devimep_open, + NULL, + devimep_close +}; +#endif + +/* /proc entry related stuff: */ 49 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)) +static inline int ath9k_procfile_read (char *buffer, + char **buffer_location, + off_t offset, + int buffer_length, + int *zero, + void *data) +#else +static inline int ath9k_procfile_read (char *buffer, + char **buffer_location, + off_t offset, + int buffer_length, + int zero) lý cho erspy (là nơi +{ char *tmp_buf = ""; APE lấy thông tin + + //printk("APE ath9k: Reading proc file\n"); tình + if (offset > 0) mạng) + return 0; + /* Check if the spy_buffer points at anything useful, + else return empty string */ + if (spy_buffer == NULL) { + *buffer_location = tmp_buf; + return strlen(tmp_buf); + xử /proc/dev/sup +#endif + Các } + + *buffer_location = spy_buffer; + return strlen(spy_buffer); +} +/* Similar to above function, for using with proc_create() */ hình 50 +static int ath9k_procfile_show(struct seq_file *m, void *v) +{ + printk("APE ath9k: proc show\n"); Lấy thông tin + + /* Check if the spy_buffer points at anything useful, từ spy_buffer + else return empty string */ + if (spy_buffer != NULL) { bỏ vào biến m Các + printk("APE ath9k: copy buff\n"); thông + seq_printf(m, "%s", spy_buffer); biến m + } + else + đƣợc đƣa cho user printk("APE ath9k: super spy null\n"); + + tin return 0; +} + +/* For using with proc_create() */ +static int ath9k_procfile_open(struct inode *inode, struct file *file) +{ + printk("APE ath9k: proc open\n"); + return single_open(file, ath9k_procfile_show, NULL); +} +static const struct file_operations ath9k_procfile_fops = { + open = ath9k_procfile_open, + read = seq_read, + llseek = seq_lseek, + release = seq_release, +}; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) +struct proc_dir_entry ath9k_superspy = { 51 + 0, + 8, + "superspy", + S_IFREG | S_IRUGO, + 1, + 0, 0, + 80, + NULL, + ath9k_procfile_read, + NULL +}; +#endif + +inline void +ath9k_superspy_gather (u_char *mac, int8_t signal, int8_t noise) +{ + + struct timeval currentTime; + static int offset = 0; + int len = 0; + char mac_address[18]; + char spy_info[100]; + static int pkt = 0; /* count all packets we spy on */ + //static unsigned long timer; thông tin cần + //static int first = 1; thiết vào biến + /* A buffer to hold info from several packages at once */ + static char buffer[SUPERSPY_BUFFER_SIZE]; + + super_spy_g ather() Thu thập toàn + + Hàm pkt++; /* Inrease the packet counter */ spy_bufer cục 52 + /* Update the spy_buffer pointer so that it points at the buffer */ + spy_buffer = (char*)buffer; + + /* Register time for this packet */ + do_gettimeofday(¤tTime); + + /* Convert Mac address to ASCII */ + sprintf(mac_address, "%02X:%02X:%02X:%02X:%02X:%02X", + (mac[0] & 0xFF), (mac[1] & 0xFF), + (mac[2] & 0xFF), (mac[3] & 0xFF), + (mac[4] & 0xFF), (mac[5] & 0xFF)); super_spy_g ather() + + Hàm /* memcpy(lp->spy_address[0], mac, MAC_ADDR_SIZE); */ làm nhiệm vụ thu thập liệu + + /* Save quality information for this packet */ cần thiết + len = sprintf(spy_info, "%6d %ld.%06ld %s %3d %3d\n", bỏ vào vùng + pkt, nhớ + currentTime.tv_sec, trƣớc + currentTime.tv_usec, toàn + mac_address, spy_buffer) + signal, + noise); + + /* If we have filled the buffer, we loose the first entry to free up + the last */ + if(offset + len > SUPERSPY_BUFFER_SIZE-1) + { + memmove(buffer, buffer+len, SUPERSPY_BUFFER_SIZE-len); + offset = offset - len; + } + offset += sprintf(buffer+offset, spy_info); cho (biến cục 53 +} +/******* APE_END ********/ + + /**********************/ /* mac80211 callbacks */ /**********************/ @@ -669,6 +946,14 @@ static int ath9k_start(struct ieee80211_hw *hw) struct ath9k_channel *init_channel; int r; + /******* APE_BEGIN ********/ + int i; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)) + struct proc_dir_entry *proc; + printk("APE ath9k: ath9k_start\n"); +#endif + /******* APE_END ********/ + ath_dbg(common, CONFIG, "Starting driver with initial channel: %d MHz\n", curchan->center_freq); @@ -743,6 +1028,43 @@ static int ath9k_start(struct ieee80211_hw *hw) ath9k_ps_restore(sc); + /******* APE_BEGIN ********/ + /* setup the devimep character device MSI */ Khởi + printk("APE ath9k: ath9k_start APE begin\n"); devimep + i = register_chrdev(125,"devimep",&devimep_fops); + /* printk("APE ath9k: Registered devimep device\n"); */ tạo 54 + if(i

Ngày đăng: 18/05/2021, 13:31

w