Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Chun Zhang
Thanks Ian! Can you please give some suggestion on how to properly handle this issue? The C++ API cannot be modified. Sincerely, Chun On Monday, November 6, 2017 at 3:25:13 PM UTC-5, Ian Lance Taylor wrote: > > On Mon, Nov 6, 2017 at 10:59 AM, Chun Zhang > wrote: > > >

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Chun Zhang
Hi, The configuration is the structure defined as type Configuration struct { IpToSend string PortToSend string Device string } The json file is { "IpToSend" :"", "PortToSend" :"2075", "Device" : "eth1" } The output of fmt.Sprintf("%T %#v", conf, con

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Chun Zhang
oding the value and retrieving it from the json file. Can you please help me to understand it? Thanks, Chun On Monday, November 6, 2017 at 1:44:54 PM UTC-5, Ian Lance Taylor wrote: > > On Mon, Nov 6, 2017 at 10:29 AM, Chun Zhang > wrote: > > Thank you Ian!! That does make sense. &

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Chun Zhang
Thank you Ian!! That does make sense. Can you please elaborate why hardcoding device = "eth1" works? What is the difference here? Sincerely, Chun On Mon, Nov 6, 2017 at 1:19 PM, Ian Lance Taylor wrote: > On Mon, Nov 6, 2017 at 4:25 AM, Chun Zhang wrote: > > > >

[go-nuts] Re: Passing a string

2017-11-06 Thread Chun Zhang
Best, Chun On Monday, November 6, 2017 at 1:07:46 AM UTC-5, Tamás Gulácsi wrote: > > > 2017. november 6., hétfő 2:11:48 UTC+1 időpontban Chun Zhang a következőt > írta: >> >> Hi, All, >> >> I am trying to read a configuration file using Viper, the config fil

[go-nuts] Passing a string

2017-11-05 Thread Chun Zhang
Hi, All, I am trying to read a configuration file using Viper, the config file is a very simple json file with one line { "device" : "eth1" } I use the following line to read it device := viper.GetString("device") then passing this var further into a C library with swig generated api as ar

Re: [go-nuts] Converting uint to string

2017-11-05 Thread Chun Zhang
Hi, Jan, Thank you very much!! Best, Chun On Sunday, November 5, 2017 at 4:17:43 PM UTC-5, Jan Mercl wrote: > > On Sun, Nov 5, 2017 at 10:09 PM Chun Zhang > wrote: > > > I have a group of integers ranging from 1 to 2^32 that are in the format > of uint32. > > A

[go-nuts] Converting uint to string

2017-11-05 Thread Chun Zhang
Hi, All, I have a group of integers ranging from 1 to 2^32 that are in the format of uint32. I know strconv.Itoa(i) or strconv.FormatUint(i) can definitely give unique representation of each number. So, I can use it as the index of a map[string]interface{}. However, I am wondering if I use st

[go-nuts] Re: afpacket does not get GRE tunneled packets?

2017-10-18 Thread Chun Zhang
I just figured this out. I need to manually set the NIC to promiscuous mode. Now the question is, is there a way to set the NIC to promiscuous mode in code, like in pcap.openlive?? I don't see that option with AF_packet. Thanks, Chun On Tuesday, October 17, 2017 at 6:31:21 PM UTC-4,

[go-nuts] afpacket does not get GRE tunneled packets?

2017-10-17 Thread Chun Zhang
Hi, friends, I am trying to create a very simple network sniffer. Initially I implemented it with libpcap, but I got not only performance issue, but also timing issue. Now I am trying to replace libpcap with afpacket. However, I am not able to get any packet from the GRE tunneled terminated a

[go-nuts] Re: gopacket, libpcap timestamp precison

2017-07-28 Thread Chun Zhang
hether understand your need, but if your need is the reassembly > of TCP packets, you can use the tcpassembly packet in gopacket, I recently > used it in my traffic replay project tcplayer > <https://github.com/feilengcui008/tcplayer>, it seems working just fine. > > 在 2017年7

[go-nuts] gopacket, libpcap timestamp precison

2017-07-27 Thread Chun Zhang
Hi, All, I am trying to write a small program to sniff packets off the wire. These packets are most TCP flows, so I'd expect SYN arrives earlier than SYN-ACK, ACK etc. I used gopacket and basically followed the official guide to get the packet and then read its metadata for timing. But to my

Re: [go-nuts] Re: How fast can gopacket handles?

2017-06-09 Thread Chun Zhang
omponents to find > more granular code bottlenecks. > > On Fri, Jun 9, 2017, 09:47 Chun Zhang > > wrote: > >> Hi, All, >> >> Update on this issue. Based on the suggestion I got earlier, I dedicated >> one thread, which is locked to a os thread to handl

Re: [go-nuts] Re: How fast can gopacket handles?

2017-06-09 Thread Chun Zhang
Decoding Packets Faster http://www.devdungeon.com/content/packet-capture-injection-and-analysis-gopacket I am wondering what further optimization can I do to speed this up? Thanks, Chun On Tuesday, May 30, 2017 at 10:50:50 AM UTC-4, Chun Zhang wrote: > > Thank you Rajanikanth, Kevin an

[go-nuts] How to turn on conditional logging?

2017-06-07 Thread Chun Zhang
Hi, All, I have some piece of code with very high cpu usage, logging is actually pretty cpu intensive, so I tried to turn it off as follows, type myLog struct { *log.Logger enable bool } func (l *myLog) Println(v ...interface{}) { if l.enable == true { l.Out

[go-nuts] Re: Copy map with empty interfaces

2017-06-05 Thread Chun Zhang
Unfortunately it does not give any info. :( Thanks, Chun On Saturday, June 3, 2017 at 1:16:18 PM UTC-4, Egon wrote: > > Does race detector say something useful? > > On Friday, 2 June 2017 21:18:31 UTC+3, Chun Zhang wrote: >> >> I am trying to store some complicated data s

[go-nuts] Re: Copy map with empty interfaces

2017-06-05 Thread Chun Zhang
Hi, Tamas, Thanks for the reply! The key is a string for my current use. After the data v is retrieved, it is compared with a new data coming from the wire. And then based on the comparison, the new data, which is a newly created piece of memory contains same type of data, will be sent to a C

[go-nuts] Copy map with empty interfaces

2017-06-02 Thread Chun Zhang
I am trying to store some complicated data structure with a map, and eventually search and use it. Since the structure can change with different applications, and it has to work with multiple thread, I defined a generic map like follows type IndexedMap struct { sync.RWMutex Data

Re: [go-nuts] Re: How fast can gopacket handles?

2017-05-30 Thread Chun Zhang
Thank you Rajanikanth, Kevin and Egon! I will explore the ideas you guys provided and keep you updated. Best Regards, Chun On Sunday, May 28, 2017 at 2:25:03 AM UTC-4, Egon wrote: > > > > On Saturday, 27 May 2017 14:05:11 UTC+3, Chun Zhang wrote: >> >> Thanks Kevin an

Re: [go-nuts] Re: How fast can gopacket handles?

2017-05-27 Thread Chun Zhang
istics like a file or syslog over UDP. > > On Fri, May 26, 2017 at 3:59 PM Egon > > wrote: > >> On Friday, 26 May 2017 20:51:55 UTC+3, Chun Zhang wrote: >>> >>> Good point. >>> as a comparison: tcpdump -w /dev/null can handle up to 750Mbps, where >

[go-nuts] Re: How fast can gopacket handles?

2017-05-26 Thread Chun Zhang
hub.com/miekg/pcap > > + Egon > > On Friday, 26 May 2017 19:01:20 UTC+3, Chun Zhang wrote: >> >> Hi, All, >> >> I am trying to write a small program to handle packets coming from a GigE >> wire. The testing code snip is as below. >> >> The proble

[go-nuts] How fast can gopacket handles?

2017-05-26 Thread Chun Zhang
Hi, All, I am trying to write a small program to handle packets coming from a GigE wire. The testing code snip is as below. The problem I am facing is that this is extremely slow, can only handle up to 250Mbps-ish traffic with normal ipv4 sized packets, anything above that resulting signific

[go-nuts] gopacket.Newpacket does not provide MetaData for the new packet??

2017-04-24 Thread Chun Zhang
Hi, all, I am trying to capture a GRE tunneled packet and get rid off the GRE header to retrieve the encapsulated packet. The code is quite simple, I basically grabs the GRE tunneled packet and build a new one from its payload. The problem I have here is the MetaData of the packet1 channel is

[go-nuts] Re: Linking static c++ library with Go using SWIG

2017-03-01 Thread Chun Zhang
Quick update: The issue was resolved after a `go clean`... Now everything build just as if the directives are passed through the CLI. I don't know what happened... Thank all for your help! On Tuesday, February 28, 2017 at 2:06:20 PM UTC-5, Chun Zhang wrote: > > Hi, All, > &g

[go-nuts] Re: Linking static c++ library with Go using SWIG

2017-03-01 Thread Chun Zhang
; to see how go would invoke "link" > > and maybe you need to link against "libboost_system" and "libxml2" as > well, if "libCOLOR" really depends on it. > > > Am Mittwoch, 1. März 2017 20:04:50 UTC+1 schrieb Chun Zhang: >> &g

[go-nuts] Re: Linking static c++ library with Go using SWIG

2017-03-01 Thread Chun Zhang
ithout the ".a" suffix in the LDFLAGS? > > Am Dienstag, 28. Februar 2017 20:06:20 UTC+1 schrieb Chun Zhang: >> >> Hi, All, >> >> I have googled quite a bit about this issue, there are some tutorials >> online. But most of them targeted either at o

Re: [go-nuts] Linking static c++ library with Go using SWIG

2017-03-01 Thread Chun Zhang
script and passing all compiler parameters explicitly. But this does not seem to be an optimal solution. If there is anything else that I can try, please let me know. Thanks, Chun On Wednesday, March 1, 2017 at 1:20:16 PM UTC-5, Ian Lance Taylor wrote: > > On Wed, Mar 1, 2017 at 10:1

Re: [go-nuts] Linking static c++ library with Go using SWIG

2017-03-01 Thread Chun Zhang
-switches" in the `go env` output has the -fdebug-prefix-map changed each and everytime, is that expected? go version go1.7.1 linux/amd64 Best Regards, Chun On Wednesday, March 1, 2017 at 1:01:45 PM UTC-5, Ian Lance Taylor wrote: > > On Wed, Mar 1, 2017 at 8:13 AM, Chun Zhang >

Re: [go-nuts] Linking static c++ library with Go using SWIG

2017-03-01 Thread Chun Zhang
ll be appreciated. Thanks, Chun On Tuesday, February 28, 2017 at 2:49:19 PM UTC-5, Chun Zhang wrote: > > Thank you for your reply! I read a few posts between you and Stephen > before posting this. > > Sorry, it was a bad copy and paste. > > I did have the import "C" l

Re: [go-nuts] Linking static c++ library with Go using SWIG

2017-02-28 Thread Chun Zhang
to build the whole library. Best Regards, Chun On Tuesday, February 28, 2017 at 2:44:21 PM UTC-5, Ian Lance Taylor wrote: > > On Tue, Feb 28, 2017 at 11:04 AM, Chun Zhang > wrote: > > > > An empty libcolor.go file with the following lines was manually created > >

[go-nuts] Linking static c++ library with Go using SWIG

2017-02-28 Thread Chun Zhang
Hi, All, I have googled quite a bit about this issue, there are some tutorials online. But most of them targeted either at older go releases or C instead of C++. Can somebody please help me to figure out how to solve the following issues? I have to use a static library, wrote in C++ in a go