OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 * The memory necessary for the payload is not allocated: | 215 * The memory necessary for the payload is not allocated: |
216 * it will be allocated at any later point if you attempt | 216 * it will be allocated at any later point if you attempt |
217 * to fragment this packet or to access the zero-filled | 217 * to fragment this packet or to access the zero-filled |
218 * bytes. The packet is allocated with a new uid (as· | 218 * bytes. The packet is allocated with a new uid (as· |
219 * returned by getUid). | 219 * returned by getUid). |
220 *· | 220 *· |
221 * \param size the size of the zero-filled payload | 221 * \param size the size of the zero-filled payload |
222 */ | 222 */ |
223 Packet (uint32_t size); | 223 Packet (uint32_t size); |
224 /** | 224 /** |
| 225 * Create a new packet from the serialized buffer. This new packet· |
| 226 * is identical to the serialized packet contained in the buffer· |
| 227 * and is magically deserialized for you |
| 228 *· |
| 229 * \param buffer the serialized packet to be created |
| 230 * \param size the size of the packet for deserialization |
| 231 * \param magic allows packet deserialization;· |
| 232 * asserts when set to false |
| 233 */ |
| 234 Packet (uint8_t const*buffer, uint32_t size, bool magic); |
| 235 /** |
225 * Create a packet with payload filled with the content | 236 * Create a packet with payload filled with the content |
226 * of this buffer. The input data is copied: the input | 237 * of this buffer. The input data is copied: the input |
227 * buffer is untouched. | 238 * buffer is untouched. |
228 * | 239 * |
229 * \param buffer the data to store in the packet. | 240 * \param buffer the data to store in the packet. |
230 * \param size the size of the input buffer. | 241 * \param size the size of the input buffer. |
231 */ | 242 */ |
232 Packet (uint8_t const*buffer, uint32_t size); | 243 Packet (uint8_t const*buffer, uint32_t size); |
233 /** | 244 /** |
234 * Create a new packet which contains a fragment of the original | 245 * Create a new packet which contains a fragment of the original |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 * this uid into such a counter, because of questions such as what | 383 * this uid into such a counter, because of questions such as what |
373 * should the uid be when the packet is sent over broadcast media, or | 384 * should the uid be when the packet is sent over broadcast media, or |
374 * when fragmentation occurs. If a user wants to trace actual packet | 385 * when fragmentation occurs. If a user wants to trace actual packet |
375 * counts, he or she should look at e.g. the IP ID field or transport | 386 * counts, he or she should look at e.g. the IP ID field or transport |
376 * sequence numbers, or other packet or frame counters at other | 387 * sequence numbers, or other packet or frame counters at other |
377 * protocol layers. | 388 * protocol layers. |
378 * | 389 * |
379 * \returns an integer identifier which uniquely | 390 * \returns an integer identifier which uniquely |
380 * identifies this packet. | 391 * identifies this packet. |
381 */ | 392 */ |
382 uint32_t GetUid (void) const; | 393 uint64_t GetUid (void) const; |
383 | 394 |
384 /** | 395 /** |
385 * \param os output stream in which the data should be printed. | 396 * \param os output stream in which the data should be printed. |
386 * | 397 * |
387 * Iterate over the headers and trailers present in this packet,· | 398 * Iterate over the headers and trailers present in this packet,· |
388 * from the first header to the last trailer and invoke, for | 399 * from the first header to the last trailer and invoke, for |
389 * each of them, the user-provided method Header::DoPrint or· | 400 * each of them, the user-provided method Header::DoPrint or· |
390 * Trailer::DoPrint methods. | 401 * Trailer::DoPrint methods. |
391 */ | 402 */ |
392 void Print (std::ostream &os) const; | 403 void Print (std::ostream &os) const; |
(...skipping 20 matching lines...) Expand all Loading... |
413 * The packet metadata is also used to perform extensive | 424 * The packet metadata is also used to perform extensive |
414 * sanity checks at runtime when performing operations on a· | 425 * sanity checks at runtime when performing operations on a· |
415 * Packet. For example, this metadata is used to verify that | 426 * Packet. For example, this metadata is used to verify that |
416 * when you remove a header from a packet, this same header | 427 * when you remove a header from a packet, this same header |
417 * was actually present at the front of the packet. These | 428 * was actually present at the front of the packet. These |
418 * errors will be detected and will abort the program. | 429 * errors will be detected and will abort the program. |
419 */ | 430 */ |
420 static void EnableChecking (void); | 431 static void EnableChecking (void); |
421 | 432 |
422 /** | 433 /** |
423 * \returns a byte buffer | 434 * For packet serializtion, the total size is checked· |
| 435 * in order to determine the size of the buffer· |
| 436 * required for serialization |
424 * | 437 * |
425 * This method creates a serialized representation of a Packet object | 438 * \returns number of bytes required for packet· |
426 * ready to be transmitted over a network to another system. This | 439 * serialization |
427 * serialized representation contains a copy of the packet byte buffer, | 440 */ |
428 * the tag list, and the packet metadata (if there is one). | 441 uint32_t GetSerializedSize (void) const; |
| 442 |
| 443 /* |
| 444 * \param buffer a raw byte buffer to which the packet will be serialized |
| 445 * \param maxSize the max size of the buffer for bounds checking |
429 * | 446 * |
430 * This method will trigger calls to the Serialize and GetSerializedSize | 447 * A packet is completely serialized and placed into the raw byte buffer |
431 * methods of each tag stored in this packet. | |
432 * | 448 * |
433 * This method will typically be used by parallel simulations where | 449 * \returns zero if buffer size was too small |
434 * the simulated system is partitioned and each partition runs on | |
435 * a different CPU. | |
436 */ | 450 */ |
437 Buffer Serialize (void) const; | 451 uint32_t Serialize (uint8_t* buffer, uint32_t maxSize) const; |
438 /** | |
439 * \param buffer a byte buffer | |
440 * | |
441 * This method reads a byte buffer as created by Packet::Serialize | |
442 * and restores the state of the Packet to what it was prior to | |
443 * calling Serialize. | |
444 * | |
445 * This method will trigger calls to the Deserialize method | |
446 * of each tag stored in this packet. | |
447 * | |
448 * This method will typically be used by parallel simulations where | |
449 * the simulated system is partitioned and each partition runs on | |
450 * a different CPU. | |
451 */ | |
452 void Deserialize (Buffer buffer); | |
453 | 452 |
454 /** | 453 /** |
455 * \param tag the new tag to add to this packet | 454 * \param tag the new tag to add to this packet |
456 * | 455 * |
457 * Tag each byte included in this packet with the | 456 * Tag each byte included in this packet with the |
458 * new tag. | 457 * new tag. |
459 * | 458 * |
460 * Note that adding a tag is a const operation which is pretty· | 459 * Note that adding a tag is a const operation which is pretty· |
461 * un-intuitive. The rationale is that the content and behavior of | 460 * un-intuitive. The rationale is that the content and behavior of |
462 * a packet is _not_ changed when a tag is added to a packet: any | 461 * a packet is _not_ changed when a tag is added to a packet: any |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 * how to associate something specific like nix-vector· | 548 * how to associate something specific like nix-vector· |
550 * with a packet. This design methodology· | 549 * with a packet. This design methodology· |
551 * should _not_ be followed, and is only here as an· | 550 * should _not_ be followed, and is only here as an· |
552 * impetus to fix this general issue. */ | 551 * impetus to fix this general issue. */ |
553 void SetNixVector (Ptr<NixVector>); | 552 void SetNixVector (Ptr<NixVector>); |
554 Ptr<NixVector> GetNixVector (void) const;· | 553 Ptr<NixVector> GetNixVector (void) const;· |
555 | 554 |
556 private: | 555 private: |
557 Packet (const Buffer &buffer, const ByteTagList &byteTagList,· | 556 Packet (const Buffer &buffer, const ByteTagList &byteTagList,· |
558 const PacketTagList &packetTagList, const PacketMetadata &metadata); | 557 const PacketTagList &packetTagList, const PacketMetadata &metadata); |
| 558 |
| 559 uint32_t Deserialize (uint8_t const*buffer, uint32_t size); |
| 560 ·· |
559 Buffer m_buffer; | 561 Buffer m_buffer; |
560 ByteTagList m_byteTagList; | 562 ByteTagList m_byteTagList; |
561 PacketTagList m_packetTagList; | 563 PacketTagList m_packetTagList; |
562 PacketMetadata m_metadata; | 564 PacketMetadata m_metadata; |
563 | 565 |
564 /* Please see comments above about nix-vector */ | 566 /* Please see comments above about nix-vector */ |
565 Ptr<NixVector> m_nixVector; | 567 Ptr<NixVector> m_nixVector; |
566 | 568 |
567 static uint32_t m_globalUid; | 569 static uint32_t m_globalUid; |
568 }; | 570 }; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 * Dirty operations will always be slower than non-dirty operations, | 607 * Dirty operations will always be slower than non-dirty operations, |
606 * sometimes by several orders of magnitude. However, even the | 608 * sometimes by several orders of magnitude. However, even the |
607 * dirty operations have been optimized for common use-cases which | 609 * dirty operations have been optimized for common use-cases which |
608 * means that most of the time, these operations will not trigger | 610 * means that most of the time, these operations will not trigger |
609 * data copies and will thus be still very fast. | 611 * data copies and will thus be still very fast. |
610 */ | 612 */ |
611 | 613 |
612 } // namespace ns3 | 614 } // namespace ns3 |
613 | 615 |
614 #endif /* PACKET_H */ | 616 #endif /* PACKET_H */ |
OLD | NEW |