CDP Indicator 
Toru Okatsu 
Technical Leader, TS Japan
CDP Indicator 
Port connected to 
SW2 FastEthernet 0/3 (scrolling) 
192.168.1.21 
Raspberry PI’s IP address 
CDP packets 
8x2 Display 
Mobile Battery
Features 
 Ethernet Interfaceに接続されたデバイスの名前とその 
ポート番号を受信したCDPパケットから取り出して表示 
する。 
 自分自身のデバイス情報をCDPで送信する。 
 DHCPで自分自身に割り当てられたIP addressを表示 
する。
Process Overview 
Main Thread CDP Receiver Thread 
• Message check 
• IP address check 
• CDP send 
• CDP wait 
Peer Device 
Information
SCAPY (CDP Receive) 
ether_filter = 'not ether src '+get_if_hwaddr('eth0') 
cap_pkt = sniff(iface="eth0", 
lfilter=lambda x: x.haslayer(CDPv2_HDR), 
filter=ether_filter, count=1) 
port = cap_pkt[0][CDPMsgPortID].fields["iface"] 
name = cap_pkt[0][CDPMsgDeviceID].fields["val"]
SCAPY (CDP Generate) 
etherframe = Ether() 
etherframe.dst = '01:00:0c:cc:cc:cc' 
etherframe.src = src_mac 
etherframe.type = 0x011e 
: 
: 
cdpPlatform = CDPMsgPlatform() 
cdpPlatform.type = 6 
cdpPlatform.len = 10 
cdpPlatform.val = 'Linux.’ 
cdppacket = 
etherframe/llcFrame/snapFrame/cdpHeader/cdpDeviceID/cdpAddr/cdpPortID/cdpCapabil 
ities/cdpSoftVer/cdpPlatform
Cloudbit
http://littlebits.cc/bits/cloudbit
Clodbit Network 
http://control.littlebitscloud.cc/
Web API of Cloudbit 
 電圧を設定 
curl -i -XPOST  
-H "Authorization: Bearer TOKEN"  
-H "Accept: application/vnd.littlebits.v2+json"  
https://api-http.littlebitscloud.cc/devices/DEVICE_ID/output  
-d percent=50 -d duration_ms=1000 
 電圧変化時のCallbackを設定 
curl -i -XPOST  
-H "Authorization: Bearer TOKEN"  
https://api-http.littlebitscloud.cc/v2/subscriptions  
-d publisher_id=DEVICE_ID  
-d subscriber_id=‘http://some.callback.com?params=stuff’ 
-d publisher_events='["amplitude:delta:ignite"]‘ 
http://developer.littlebitscloud.cc/api-http
IFTTTによるWebサービスとの連携 
http://ifttt.com
P ≠ NP?

CDP Indicator

  • 1.
    CDP Indicator ToruOkatsu Technical Leader, TS Japan
  • 2.
    CDP Indicator Portconnected to SW2 FastEthernet 0/3 (scrolling) 192.168.1.21 Raspberry PI’s IP address CDP packets 8x2 Display Mobile Battery
  • 3.
    Features  EthernetInterfaceに接続されたデバイスの名前とその ポート番号を受信したCDPパケットから取り出して表示 する。  自分自身のデバイス情報をCDPで送信する。  DHCPで自分自身に割り当てられたIP addressを表示 する。
  • 4.
    Process Overview MainThread CDP Receiver Thread • Message check • IP address check • CDP send • CDP wait Peer Device Information
  • 5.
    SCAPY (CDP Receive) ether_filter = 'not ether src '+get_if_hwaddr('eth0') cap_pkt = sniff(iface="eth0", lfilter=lambda x: x.haslayer(CDPv2_HDR), filter=ether_filter, count=1) port = cap_pkt[0][CDPMsgPortID].fields["iface"] name = cap_pkt[0][CDPMsgDeviceID].fields["val"]
  • 6.
    SCAPY (CDP Generate) etherframe = Ether() etherframe.dst = '01:00:0c:cc:cc:cc' etherframe.src = src_mac etherframe.type = 0x011e : : cdpPlatform = CDPMsgPlatform() cdpPlatform.type = 6 cdpPlatform.len = 10 cdpPlatform.val = 'Linux.’ cdppacket = etherframe/llcFrame/snapFrame/cdpHeader/cdpDeviceID/cdpAddr/cdpPortID/cdpCapabil ities/cdpSoftVer/cdpPlatform
  • 7.
  • 8.
  • 9.
  • 10.
    Web API ofCloudbit  電圧を設定 curl -i -XPOST -H "Authorization: Bearer TOKEN" -H "Accept: application/vnd.littlebits.v2+json" https://api-http.littlebitscloud.cc/devices/DEVICE_ID/output -d percent=50 -d duration_ms=1000  電圧変化時のCallbackを設定 curl -i -XPOST -H "Authorization: Bearer TOKEN" https://api-http.littlebitscloud.cc/v2/subscriptions -d publisher_id=DEVICE_ID -d subscriber_id=‘http://some.callback.com?params=stuff’ -d publisher_events='["amplitude:delta:ignite"]‘ http://developer.littlebitscloud.cc/api-http
  • 11.
  • 12.