If you’ve ever worked with network programming, you know how frustrating it can be when built-in tools feel too restrictive—whether you’re testing firewall rules, troubleshooting custom network behavior, or building a low-level network tool that needs to do things no off-the-shelf software can. That’s where Tins comes in, and as someone who’s worked with this powerful library for years—my team is the go-to Tins supplier for developers and engineers who need reliable, production-ready support—I’ve seen firsthand how it simplifies sending custom packets when every other option falls short. Tins

Let me start by being honest: a lot of people new to packet crafting get intimidated by the layers of network protocols. There’s Ethernet, IP, TCP, UDP, ICMP… and each has its own set of headers and rules. Building a custom packet from scratch in C++ (the language Tins is built for) means manually constructing each byte, making sure checksums are correct, handling endianness, and avoiding common bugs that can make your packet get dropped by routers or firewalls. Tins takes all that complexity and wraps it into a clean, intuitive API, so you can focus on what you’re trying to test or build, not the nitty-gritty of packet formatting.
First, let’s make sure we’re on the same page. Tins is a portable C++ network packet library that supports parsing, crafting, sending, and sniffing packets for dozens of protocols. It’s lightweight, designed to work on Linux, macOS, and Windows, and it’s used by everyone from cybersecurity researchers building penetration testing tools to network engineers testing IoT device communication stacks. As a Tins supplier, I’ve seen users come to us because they’ve tried other libraries—like libnet or raw sockets—only to run into portability issues, bad documentation, or limited support when they hit a problem. Tins solves those pain points, but only if you know how to use it correctly to send custom packets.
Let’s walk through a practical example. Suppose you want to send a custom TCP SYN packet to test whether a port on a remote server is open. That’s a common use case for packet crafting, and it’s surprisingly straightforward with Tins. First, you’ll need to set up your development environment: make sure you have a C++ compiler (GCC, Clang, or MSVC), and you’ll need to install Tins. If you’re working with us as a Tins supplier, we can provide pre-built binaries for all major operating systems, plus detailed setup guides that cut out the guesswork of compiling from source. For this example, let’s assume you’ve got Tins installed and are working in a C++ project.
First, we need to define the network layers of our packet. A TCP SYN packet needs four core layers: Ethernet (for layer 2 communication), IPv4 (or IPv6, if you’re working with newer networks), TCP, and a payload (even if it’s empty for a basic SYN). Tins makes creating each layer trivial. You don’t have to calculate the Ethernet header length or handle MAC address formatting; Tins does that for you. Let’s write the code step by step, so it’s clear:
Start by including the necessary Tins headers:
#include <tins/tins.h>
using namespace Tins;
Next, we’ll create the packet layers. Let’s say our source MAC address is 00:11:22:33:44:55, our source IP is 192.168.1.100, the destination MAC is aa:bb:cc:dd:ee:ff, the destination IP is 192.168.1.200, and we want to test port 80 on the destination.
EthernetII eth = EthernetII("aa:bb:cc:dd:ee:ff", "00:11:22:33:44:55");
IP ip = IP("192.168.1.100", "192.168.1.200");
TCP tcp = TCP();
tcp.sport(12345); // Random source port, we can use any unused port
tcp.dport(80); // Destination port we want to test
tcp.flags(TCP::SYN); // Set the SYN flag, this is what makes this a SYN packet
Wait a second—did you notice that we didn’t set the Ethernet type, the IP checksum, or the TCP checksum? That’s Tins working for you. It automatically calculates all of those values when you send the packet, because it knows that routers and firewalls expect correct checksums to accept the packet. You could manually set them if you needed to, but for most use cases, Tins handles that automatically, which saves you from one of the most common packet crafting mistakes.
Now, we need to combine all the layers into a single packet. Tins uses the concept of PDU (Protocol Data Unit) layers, and when you chain them, it automatically builds the correct encapsulation. So we just need to add the TCP layer to the IP layer, and the IP layer to the Ethernet layer:
PDU::serialization_type packet_data = (eth / ip / tcp).serialize();
Wait, actually, we don’t even need to call serialize() manually—Tins’ sender class will handle that for us, but it’s good to see what’s happening under the hood. Now, we need to create a sender object to send the packet. The sender needs to know which network interface to use. Let’s say our interface is eth0 (you can check your interfaces with tools like ip link on Linux or ifconfig on macOS):
Sender sender("eth0");
// Now send the packet
sender.send(eth / ip / tcp);
That’s it? That’s the core of sending a custom TCP SYN packet with Tins. If you run this code, it will send exactly the packet you built, with all correct headers and checksums, to the destination you specified. No more manual byte counting, no more buggy checksum calculations. As a Tins supplier, I can tell you that this is one of the most common use cases our customers come to us for—building custom scan tools, testing firewall rules, or troubleshooting port communication. And this example works for almost any protocol, too: if you want to send an ICMP echo request (a ping), you just replace the TCP layer with an ICMP layer, set the type to ICMP::ECHO_REQUEST, and you’re done.
But sending custom packets isn’t just about simple TCP or ICMP. A lot of our more advanced customers need to build packets with non-standard headers, modify existing headers, or even build custom protocols for testing. For example, if you’re testing a custom IoT protocol that runs over UDP, you might need to add a custom payload, or even a custom header, that Tins doesn’t have a built-in class for. Tins makes that easy too. Let’s say you want to add a custom 8-byte header to your UDP packet. Tins lets you create a custom PDU class by inheriting from the PDU base class, and you just define how to serialize and deserialize your header. Our team provides support for building these custom PDUs, which is one of the biggest advantages of working with a dedicated Tins supplier—we’ve helped hundreds of customers implement custom protocols without having to reverse-engineer raw packet bytes.
Another common pitfall when sending custom packets is handling network address translation (NAT) or firewalls. A lot of new Tins users build a packet with a source IP that’s not in their network, and wonder why it never arrives. Tins has options to handle that, but it’s important to remember that when you send a packet on a live network, the network interface might modify the packet (like rewriting the source MAC address). If you want to send a raw packet without any modification from the kernel, Tins has a Sender option called cooked mode that skips the kernel’s stack, which is essential for some testing scenarios like penetration testing. We walk our customers through that in detail, because getting that setting wrong can lead to hours of troubleshooting.
Let’s talk about another example that’s useful for network engineers: sending a custom IP fragment. If you want to test how a router handles fragmented packets, Tins lets you split a single IP packet into multiple fragments automatically, or build the fragments manually. That’s something that raw sockets make really difficult, because you have to calculate fragment offsets, set the more fragments flag, and handle all the IP fragmentation rules. With Tins, you just call ip.frag(), and it splits your packet into the correct fragments, ready to send. Our customers in network security often use this to test intrusion detection systems (IDS) that need to reassemble fragmented packets correctly, and Tins’ support for fragments is one of the most reliable parts of the library for that use case.
Now, I should be transparent: Tins isn’t perfect. It’s a C++ library, so you need to have some familiarity with C++ to use it effectively, and while it’s portable, some protocol features work differently on different operating systems. For example, on Windows, you might need to run your code with administrator privileges to send packets, just like on Linux or macOS. That’s a common question we get from customers—they try to run their code without sudo or admin rights, and wonder why the packet isn’t being sent. We provide clear, platform-specific guides for that, which is part of the service we offer as a Tins supplier.
If you’re new to Tins, start small. Don’t jump into building a complex custom protocol right away. Start with the TCP SYN example I walked you through, test it on your local network, and make sure you can send and receive packets correctly. Tins has excellent documentation, but it’s focused on the library API, not on real-world use cases, which is where our team’s support comes in. We’ve built dozens of custom tools using Tins, and we can help you avoid common mistakes that new users make—like forgetting that endianness matters, or not setting the correct flags for a protocol.
For example, another common mistake is when users build a UDP packet and forget to set the UDP length field. Tins usually handles that, but if you’re adding a custom payload, you have to make sure the length includes both the UDP header and the payload size. We’ve seen customers waste days troubleshooting why their UDP packets are being dropped, just because of that one missing line of code. That’s the kind of small, easy-to-miss detail that makes a big difference, and that’s what we help our customers fix quickly.
As a Tins supplier, our goal isn’t just to sell you the library—it’s to make sure you can actually use it to solve your problems. Whether you’re building a custom security tool, testing network infrastructure, or troubleshooting a weird network issue, Tins gives you the power to send exactly the custom packets you need, without all the boilerplate and bugs that come with building packet crafting from scratch.
Let’s wrap this up. Sending custom packets with Tins is about simplifying a complex task, not making it more complicated. You don’t have to be a network protocol expert to use Tins, but it helps to understand the basics of how network layers work. Start with simple packets, test them, and don’t hesitate to reach out if you run into a roadblock. If you’re looking for reliable Tins binaries, production support, or custom implementation help, we’re here to help you get your project off the ground. We can walk you through every step, from setting up your environment to debugging tricky packet issues, so you can focus on what matters most: your application, not the low-level details of packet crafting.
For more information on Tins’ core features, its official documentation provides detailed API references and protocol support lists. Other useful resources include network programming textbooks that cover low-level packet concepts, and community forums where Tins developers share tips and troubleshooting advice. When you’re ready to implement Tins in your project, don’t forget to check the licensing terms, which are available in full on the official Tins website. And if you have specific requirements for custom packets or need help integrating Tins into your workflow, we encourage you to reach out to our team to discuss your needs in detail.

References
- Tins Library Official Documentation
- Stevens, W.R., Fenner, B., Rudoff, A. Unix Network Programming, Volume 1: The Sockets Networking API
- Tins GitHub Repository
Tinplate Sheet (Note: If you would like to discuss implementing custom packets with Tins, or need access to Tins resources and support, please reach out to our team for a consultation.)
Zhangjiagang Great Robust Packing Material Co., Ltd.
Zhangjiagang Great Robust Packing Material Co., Ltd. is one of the most professional tins manufacturers and suppliers in China. We are committed to providing high quality customized products with low price. Please rest assured to wholesale bulk durable tins from our factory. Contact us for pricelist.
Address: No. 16, Xinzha Middle Road, Yangshe Town, Zhangjiagang City, Jiangsu Province
E-mail: robustpacking@vip.163.com
WebSite: https://www.robustpack.com/