本文整理汇总了C++中TCP::altchecksum方法的典型用法代码示例。如果您正苦于以下问题:C++ TCP::altchecksum方法的具体用法?C++ TCP::altchecksum怎么用?C++ TCP::altchecksum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCP
的用法示例。
在下文中一共展示了TCP::altchecksum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]) {
int packet_count, packet_size, test_case;
if(argc != 5) {
std::cout << "Usage: " << *argv << " <output_file> <test_case> <num_packets> <payload_size>" << std::endl;
return 1;
}
else {
test_case = atoi(argv[2]);
packet_count = atoi(argv[3]);
packet_size = atoi(argv[4]);
}
assert(packet_count > 0);
assert(packet_size >= 0);
PacketWriter writer(argv[1], PacketWriter::ETH2);
EthernetII packet;
if(test_case == 1 || test_case == 2) {
packet = EthernetII() / IP() / TCP() / RawPDU(std::string(packet_size, 'A'));
if(test_case == 2) {
TCP::sack_type sack;
sack.push_back(1234);
sack.push_back(5678);
sack.push_back(91011);
TCP *tcp = packet.find_pdu<TCP>();
tcp->mss(1234);
tcp->winscale(123);
tcp->sack_permitted();
tcp->sack(sack);
tcp->timestamp(1, 2);
tcp->altchecksum(TCP::CHK_TCP);
}
}
else if(test_case == 3) {
const uint8_t dns_data[] = {
98, 243, 129, 128, 0, 1, 0, 1, 0, 0, 0, 0, 6, 103, 111, 111,
103, 108, 101, 3, 99, 111, 109, 0, 0, 2, 0, 1, 192, 12, 0, 2,
0, 1, 0, 0, 84, 96, 0, 6, 3, 110, 115, 52, 192, 12
};
packet = EthernetII() / IP() / UDP(52, 53) / DNS(dns_data, sizeof(dns_data));
}
dump_to_file(writer, packet_count, packet);
}
示例2:
TEST_F(TCPTest, AlternateChecksum) {
TCP tcp;
tcp.altchecksum(TCP::CHK_16FLETCHER);
EXPECT_EQ(TCP::CHK_16FLETCHER, tcp.altchecksum());
}