# Packetbeat:How to add a new protocol?

**URL:** <https://discuss.elastic.co/t/packetbeat-how-to-add-a-new-protocol/48372>\
**Category:** Beats\
**Tags:** packetbeat\
**Created:** [April 26, 2016, 2:20am UTC](https://discuss.elastic.co/t/packetbeat-how-to-add-a-new-protocol/48372 "2016-04-26T02:20:54Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![billzy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/billzy/32/9967_2.png) [@billzy](https://discuss.elastic.co/u/billzy)\
**Post date:** [May 26, 2016, 1:18pm UTC](https://discuss.elastic.co/t/packetbeat-how-to-add-a-new-protocol/48372/8 "2016-05-26T13:18:13Z")

</div>

I had the same problem and after a few research of the existing http protocol, I found following steps were needed when developing a new protocol. This simple guide is based on packetbeat version 1.2.1

- Import your package  
In beat/packetbeat/main.go, add a line in the import section to import your protocol  
for example

- Create a new folder beats/packetbeat/protos/newProtocol and start writing you go file e.g. newProtocol.go

- Register your plugin  
in the newProtocol.go file, create method init() which will be called for initialization

`The Register function will register your protocol and call function New which is the second parameter, so you need to implement the function New in next step`

- Create method New or make a copy from http.go in http package, you can find the prototype of function New which is type ProtocolPlugin in beats/packetbeat/protos/registry.go

- Implement plugin interface  
If your protocol is based on TCP, you need to implement the TcpPlugin interface (TcpPlugin is defined in beats/packetbeat/protos/registry.go)  
If your case is UDP, implement UdpPlugin

---

_[View the full topic](https://discuss.elastic.co/t/packetbeat-how-to-add-a-new-protocol/48372)._
