220 likes | 450 Views
Overlay Network and Packet header. P resenter : 曾家豪 695430054. outline. O verview Overlay Network Overlay Network Architecture in Project P2P module in NS2 :GnutellaSim K-cube in Overlay Network About Packet Header Packet Class A ssign or Change Data to Header fields
E N D
Overlay Network and Packet header Presenter: 曾家豪 695430054
outline • Overview Overlay Network • Overlay Network Architecture in Project • P2P module in NS2 :GnutellaSim • K-cube in Overlay Network • About Packet Header • Packet Class • Assign or Change Data to Header fields • How to add own Packet Header fields
Overview Overlay Network Overlay: a network on top of another (IP) networks – links on one layer are network segments of lower layers – tunneling, application adaptor, transparent router Make the application control the routing
P2P module in NS2 :GnutellaSim • http://www.cc.gatech.edu/computing/compass/gnutella/install.html
GnutellaSim Part I: Application Layer PeerApp-------------------GnutellaApp ActivityController PeerSys BootstrapControl--------SmpBootServer • PDNSBootServer Part II: Protocol Layer PeerAgent-----------------GnutellaAgent MsgParser-----------------GnutellaMsg Part III: Socket Adaptation Layer NSSocket • PrioSocket AdvwTcp • SocketTcp
010 XOR) 110 100 010 XOR) 000 010 010 XOR) 100 110 K-cube algorithmin Overlay Network 011 111 S 010 110 001 101 000 100
封包傳送出去之流程 Application/FTP start Agent(Agent/TCP) ;:send(p,h) Classifier ::recv(p,h) RTAgent ::recv(p,h) LL ::sendDown(p,h) Mac ::recv(p,h)
Packet Header在NS2中的特性 • By default, ns includes ALL packet headers of ALL protocols in ns in EVERY packet in your simulation. If you are doing large-scale web traffic simulation with many big fat pipes, reducing unused packet headers can lead to major memory saving. The size of packet headers of all protocols in ns is about 1.9KB; however,if you turn on only the common header, the IP header and the TCP header, they add up to about 100 bytes. remove-packet-header AODV ARP ...... set ns [new Simulator] remove-all-packet-headers add-packet-header IP TCP ...... set ns [new Simulator]
如何增加自己的Packet Header fields 1.要增加Header fields於哪裡? • Common header • IP header • TCP or RTP header • New your packet type, protocol 2.是否有定義新增的Header fields offset_與access方式 3.Assign 值的方式
EX: 設定或修改field的值 PriQueue::recv(Packet *p, Handler *h) { struct hdr_cmn *ch = HDR_CMN(p); struct hdr_ip *ih = HDR_IP(p); struct forkcube fk; if(Prefer_Routing_Protocols) { switch(ch->ptype()) { … default: Queue::recv(p, h); fk.uid = ch->uid(); fk.uid = fk.uid+1 cout<<"the unique id "<<fk.uid <<endl; cout<<"the source "<<( fk.srcaddr = ih->saddr() )<<endl; cout<<"the destination "<<( fk.dstaddr = ih->daddr() )<<endl; In ns-2.31/queue/priqueue.cc #include “packet.h“ #include “ip.h“ #include "priqueue.h" using namespace std; struct forkcube { int32_t srcaddr; int32_t dstaddr; int uid; };
Packet type & packet header type In packet.h enum packet_t { PT_TCP, PT_UDP, PT_CBR, PT_AUDIO, PT_VIDEO, PT_ACK, PT_START, PT_STOP, PT_PRUNE, PT_GRAFT, PT_GRAFTACK, PT_JOIN, …… In ns-packet.tcl foreach prot { Common Flags IP # IP # Routing Protocols: NV # NixVector classifier for stateless routing rtProtoDV # distance vector routing protocol rtProtoLS # link state routing protocol SR # source routing, dsr/hdr_sr.cc Src_rt # source routing, src_rtg/hdr_src.cc # Routers: LDP # mpls/ldp.cc MPLS # MPLS, MultiProtocol Label Switching ……
Next week 抽考 • 把common header的unique id與timestamp隨著每個封包傳送,利用cout印出來。