1 / 12

Demo es2012

Demo es2012. Nhóm 15 – Android Instant Messenger on WLAN & Broadcast IP address. Broadcast IP address. Là địa chỉ IP có thể gửi gói tin datagram vào mà tất cả các host trong mạng đó đều nhận được. IP networking. IPv4: Broadcast address IPv6: được thay thế bởi IP multicast. Definition.

clark
Télécharger la présentation

Demo es2012

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Demo es2012 Nhóm 15 – Android Instant Messenger on WLAN & Broadcast IP address

  2. Broadcast IP address • Là địa chỉ IP có thể gửi gói tin datagram vào mà tất cả các host trong mạng đó đều nhận được.

  3. IP networking • IPv4: Broadcast address • IPv6: được thay thế bởi IP multicast

  4. Definition • Cách xác định thông qua một địa chỉ IP và subnet mask của mạng đó: IP: 192.168.1.100/24 SM: 255.255.255.0 2^8 – 2 = 256 – 2 = 254 (số host tối đa) 2 địa chỉ được lưu trữ là subnet và broadcast address SN: 192.168.1.0 BA: 192.168.1.255

  5. Definition IP: 192.168.1.100/24 SM: 255.255.255.0 IP: 11000000.10101000.00000001.11001000 SM: 11111111.11111111.11111111.00000000 Phép toán AND đối với 24 bit đầu tiên SN: 11000000.10101000.00000001.00000000 BA: 11000000.10101000.00000001.11111111

  6. Java public InetAddress getBroadcast() throws SocketException { System.setProperty("java.net.preferIPv4Stack", "true"); for (Enumeration<NetworkInterface> niEnum = NetworkInterface .getNetworkInterfaces(); niEnum.hasMoreElements();) { NetworkInterface ni = niEnum.nextElement(); if (!ni.isLoopback()) { for (InterfaceAddress interfaceAddress : ni .getInterfaceAddresses()) { return interfaceAddress.getBroadcast(); } } } return null; }

  7. Limited Broadcast Address • Địa chỉ đặc biệt: 255.255.255.255 • Bị giới hạn gói tin không được forward từ local network này sang network khác.

  8. Usages • Broadcast Address được sử dụng trong một số application protocol như ARP, DHCP

  9. DHCP protocol

  10. Project • Do mô hình peer-peer nên các máy cần vừa là server và client • Cần một cơ chế nhận diện sự có mặt các máy trong mạng: sử dụng Udp Broadcast để gửi gói tin vào địa chỉ broadcast

  11. IM WLAN startService(username) handle Bind refresh Get unread msg & handle Bind send message Broadcast userlist Broadcast message Notification(name,ip) Intent(name,ip) Intent start UDP server Broadcast ip + chat TCP server Chatting • Welcome activity • -------------------------------------------------- • + EditText: editName • -------------------------------------------------- • editName.onKey(Enter) • startService(username) • intent (UserList activity, username) finish() • (*) save usename • checkName():trim, remove ‘/’ cancle IMService • UserList activity • ------------------------------------------------------------------------------ • + ListView/Adapter: online user list (user - ip) • + (*) OptionMenu: refresh, change name, project info , exit • ------------------------------------------------------------------------------ • broadcast receiver: • action UPDATE_LIST • get data intent “username”-“ip” • onPause(): unbind service, unregisterreceiver… • onResume(): bind service, registerreceiver, refresh • onServiceConnected(): broadcast refresh • (*) onMenuClick() • refresh, change name, project info , exit = stopService • onItemListClick(): intent(Chat actitivity, user + ip) • Chat activity • ------------------------------------------------------------------------------------------------ • + TextView: textview html message list (user - message) • + EditText: editMessage • ------------------------------------------------------------------------------------------------- broadcast receiver: • action GET_NEW_MESSAGE • filter current user ip • get data intent “IP”-”message” • (*) onPause(): save last n messages, unbind service,unregistryreceiver… • (*) onResume(): show last n messages AND last received messages, get unread messages, bind service, registerreceiver… • editMessage.onKey(Enter): send meassage Thiết kế một chương trình chat đơn giản trong Android

  12. Androidx86 Máy ảo android http://www.android-x86.org/ Download các phiên bản *eeepc.iso để cài trên Vmware hoặc VirtualBox Connect đến máy ảo để lập trình với eclipse bằng câu lệnh: adb connect ip

More Related